import-in-the-middle
Advanced tools
Comparing version 1.3.5 to 1.4.0
19
hook.js
@@ -17,2 +17,8 @@ // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2.0 License. | ||
if (NODE_MAJOR >= 20) { | ||
getExports = require('./lib/get-exports.js') | ||
} else { | ||
getExports = (url) => import(url).then(Object.keys) | ||
} | ||
function hasIitm (url) { | ||
@@ -107,3 +113,4 @@ try { | ||
url: addIitm(url.url), | ||
shortCircuit: true | ||
shortCircuit: true, | ||
format: url.format | ||
} | ||
@@ -116,4 +123,3 @@ } | ||
const realUrl = deleteIitm(url) | ||
const realModule = await import(realUrl) | ||
const exportNames = Object.keys(realModule) | ||
const exportNames = await getExports(realUrl, context, parentGetSource) | ||
return { | ||
@@ -143,3 +149,3 @@ source: ` | ||
if (hasIitm(url)) { | ||
const { source } = await getSource(url, context) | ||
const { source } = await getSource(url, context, parentLoad) | ||
return { | ||
@@ -155,6 +161,3 @@ source, | ||
if (NODE_MAJOR >= 20) { | ||
process.emitWarning('import-in-the-middle is currently unsupported on Node.js v20 and has been disabled.') | ||
return {} // TODO: Add support for Node >=20 | ||
} else if (NODE_MAJOR >= 17 || (NODE_MAJOR === 16 && NODE_MINOR >= 12)) { | ||
if (NODE_MAJOR >= 17 || (NODE_MAJOR === 16 && NODE_MINOR >= 12)) { | ||
return { load, resolve } | ||
@@ -161,0 +164,0 @@ } else { |
{ | ||
"name": "import-in-the-middle", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "Intercept imports in Node.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "c8 --check-coverage --lines 85 imhotap --runner test/runtest --files test/{hook,low-level,other}/*", | ||
"test:unsupported": "imhotap --runner test/runtest --files test/hook/loader.mjs", | ||
"test-win": "c8 --check-coverage --lines 85 imhotap --runner test\\runtest.bat --files test/{hook,low-level,other}/*", | ||
"test": "c8 --check-coverage --lines 85 imhotap --runner test/runtest --files test/{hook,low-level,other,get-esm-exports}/*", | ||
"test-win": "c8 --check-coverage --lines 85 imhotap --runner test\\runtest.bat --files test/{hook,low-level,other,get-esm-exports}/*", | ||
"test:ts": "c8 imhotap --runner test/runtest --files test/typescript/*.test.mts", | ||
"test-win:ts": "c8 imhotap --runner test\\runtest.bat --files test/typescript/*.test.mts", | ||
"coverage": "c8 --reporter html imhotap --runner test/runtest --files test/{hook,low-level,other}/* && echo '\nNow open coverage/index.html\n'" | ||
"coverage": "c8 --reporter html imhotap --runner test/runtest --files test/{hook,low-level,other,get-esm-exports}/* && echo '\nNow open coverage/index.html\n'" | ||
}, | ||
@@ -40,4 +39,7 @@ "repository": { | ||
"dependencies": { | ||
"acorn": "^8.8.2", | ||
"acorn-import-assertions": "^1.9.0", | ||
"cjs-module-lexer": "^1.2.2", | ||
"module-details-from-path": "^1.0.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41199
50
931
4
4
+ Addedacorn@^8.8.2
+ Addedcjs-module-lexer@^1.2.2
+ Addedacorn@8.14.0(transitive)
+ Addedacorn-import-assertions@1.9.0(transitive)
+ Addedcjs-module-lexer@1.4.1(transitive)