diff --git a/hook.js b/hook.js index e446457..0ec34a4 100644 --- a/hook.js +++ b/hook.js @@ -115,7 +115,7 @@ function createHook (meta) { specifiers.set(url.url, specifier) return { - url: url.format !== 'module' ? addIitm(url.url) : url.url, + url: url.format !== 'module' || NODE_MAJOR < 16 ? addIitm(url.url) : url.url, shortCircuit: true, format: url.format } @@ -143,7 +143,7 @@ register(${JSON.stringify(realUrl)}, namespace, set, ${JSON.stringify(specifiers ` } } - else if (context.format === 'module') { + else if (context.format === 'module' && NODE_MAJOR >= 16) { let fileContents try { fileContents = fs.readFileSync(fileURLToPath(url), 'utf8') diff --git a/test/get-esm-exports/v20-get-esm-exports.js b/test/get-esm-exports/v16-get-esm-exports.js similarity index 100% rename from test/get-esm-exports/v20-get-esm-exports.js rename to test/get-esm-exports/v16-get-esm-exports.js diff --git a/test/hook/v20-declaration-exports.mjs b/test/hook/v16-declaration-exports.mjs similarity index 100% rename from test/hook/v20-declaration-exports.mjs rename to test/hook/v16-declaration-exports.mjs diff --git a/test/hook/v20-default-exports.mjs b/test/hook/v16-default-exports.mjs similarity index 100% rename from test/hook/v20-default-exports.mjs rename to test/hook/v16-default-exports.mjs diff --git a/test/hook/v20-list-exports.mjs b/test/hook/v16-list-exports.mjs similarity index 100% rename from test/hook/v20-list-exports.mjs rename to test/hook/v16-list-exports.mjs diff --git a/test/hook/v18-static-import-assert.mjs b/test/hook/v16-static-import-assert.mjs similarity index 100% rename from test/hook/v18-static-import-assert.mjs rename to test/hook/v16-static-import-assert.mjs diff --git a/test/other/cyclical-dependency.mjs b/test/other/v16-cyclical-dependency.mjs similarity index 100% rename from test/other/cyclical-dependency.mjs rename to test/other/v16-cyclical-dependency.mjs