Skip to content

Commit 99a5b73

Browse files
committed
loader: return empty globalPreload when not using off-thread loader
1 parent 92c3ce3 commit 99a5b73

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

esm.mjs

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { fileURLToPath } from 'url';
22
import { createRequire } from 'module';
3+
import { versionGteLt } from './dist/util.js';
34
const require = createRequire(fileURLToPath(import.meta.url));
45

56
/** @type {import('./dist/esm')} */
@@ -8,7 +9,11 @@ export const { resolve, load, getFormat, transformSource } =
89
esm.registerAndCreateEsmHooks();
910

1011
// Affordance for node 20, where load() happens in an isolated thread
12+
const offThreadLoader = versionGteLt(process.versions.node, '20.0.0');
1113
export const globalPreload = () => {
14+
if (!offThreadLoader) {
15+
return '';
16+
}
1217
const self = fileURLToPath(import.meta.url);
1318
return `
1419
const { createRequire } = getBuiltin('module');

0 commit comments

Comments
 (0)