Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
fix: createRequire from loader context
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Sep 11, 2023
1 parent 220a145 commit c45a750
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion src/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let mainThreadPort: MessagePort | undefined;
export const globalPreload: GlobalPreloadHook = ({ port }) => {
mainThreadPort = port;
return `
const require = getBuiltin('module').createRequire(getBuiltin('process').cwd() + '/<preload>');
const require = getBuiltin('module').createRequire(${JSON.stringify(import.meta.url)});
require('@esbuild-kit/core-utils').installSourceMapSupport(port);
port.unref(); // Allows process to exit without waiting for port to close
`;
Expand Down
14 changes: 0 additions & 14 deletions tests/specs/typescript/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import path from 'path';
import fs from 'fs/promises';
import { testSuite, expect } from 'manten';
import { createFixture } from 'fs-fixture';
import type { NodeApis } from '../../utils/node-with-loader.js';
Expand Down Expand Up @@ -39,12 +37,6 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
},
});

await fs.symlink(
path.resolve('node_modules'),
path.join(fixture.path, 'node_modules'),
'dir',
);

onTestFinish(async () => await fixture.rm());

// Strict mode is not tested because ESM is strict by default
Expand Down Expand Up @@ -79,12 +71,6 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
'src/jsx.jsx': checkJsx,
});

await fs.symlink(
path.resolve('node_modules'),
path.join(fixture.path, 'node_modules'),
'dir',
);

onTestFinish(async () => await fixture.rm());

const jsxJs = await node.load('./src/jsx.jsx', {
Expand Down

0 comments on commit c45a750

Please sign in to comment.