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

Commit c45a750

Browse files
committed
fix: createRequire from loader context
1 parent 220a145 commit c45a750

File tree

2 files changed

+1
-15
lines changed

2 files changed

+1
-15
lines changed

src/loaders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let mainThreadPort: MessagePort | undefined;
4242
export const globalPreload: GlobalPreloadHook = ({ port }) => {
4343
mainThreadPort = port;
4444
return `
45-
const require = getBuiltin('module').createRequire(getBuiltin('process').cwd() + '/<preload>');
45+
const require = getBuiltin('module').createRequire(${JSON.stringify(import.meta.url)});
4646
require('@esbuild-kit/core-utils').installSourceMapSupport(port);
4747
port.unref(); // Allows process to exit without waiting for port to close
4848
`;

tests/specs/typescript/tsconfig.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import path from 'path';
2-
import fs from 'fs/promises';
31
import { testSuite, expect } from 'manten';
42
import { createFixture } from 'fs-fixture';
53
import type { NodeApis } from '../../utils/node-with-loader.js';
@@ -39,12 +37,6 @@ export default testSuite(async ({ describe }, node: NodeApis) => {
3937
},
4038
});
4139

42-
await fs.symlink(
43-
path.resolve('node_modules'),
44-
path.join(fixture.path, 'node_modules'),
45-
'dir',
46-
);
47-
4840
onTestFinish(async () => await fixture.rm());
4941

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

82-
await fs.symlink(
83-
path.resolve('node_modules'),
84-
path.join(fixture.path, 'node_modules'),
85-
'dir',
86-
);
87-
8874
onTestFinish(async () => await fixture.rm());
8975

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

0 commit comments

Comments
 (0)