import-in-the-middle 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/hook.js CHANGED
@@ -14,7 +14,8 @@ const NODE_MINOR = Number(NODE_VERSION[1])
14
14
 
15
15
  let entrypoint
16
16
 
17
- if (NODE_MAJOR >= 20) {
17
+ let getExports
18
+ if (NODE_MAJOR >= 20 || (NODE_MAJOR == 18 && NODE_MINOR >= 19)) {
18
19
  getExports = require('./lib/get-exports.js')
19
20
  } else {
20
21
  getExports = (url) => import(url).then(Object.keys)
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "import-in-the-middle",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Intercept imports in Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,3 @@
1
+ // v18.19.0 backported ESM hook execution to a separate thread,
2
+ // thus being equivalent to >=v20.
3
+ require('./v20-get-esm-exports')
@@ -6,9 +6,10 @@ import { rejects } from 'assert'
6
6
  (async () => {
7
7
  const [processMajor, processMinor] = process.versions.node.split('.').map(Number)
8
8
  const extensionlessSupported = processMajor >= 21 ||
9
- (processMajor === 20 && processMinor >= 10)
9
+ (processMajor === 20 && processMinor >= 10) ||
10
+ (processMajor === 18 && processMinor >= 19)
10
11
  if (extensionlessSupported) {
11
- // Files without extension are supported in Node.js >= 20.10.0
12
+ // Files without extension are supported in Node.js ^21, ^20.10.0, and ^18.19.0
12
13
  return
13
14
  }
14
15
  await rejects(() => import('./executable'), {
package/test/runtest CHANGED
@@ -16,14 +16,19 @@ const args = [
16
16
  ...process.argv.slice(2)
17
17
  ]
18
18
 
19
- const [processMajor] = process.versions.node.split('.').map(Number)
19
+ const [processMajor, processMinor] = process.versions.node.split('.').map(Number)
20
20
 
21
- const match = filename.match(/v([0-9]+)/)
21
+ const match = filename.match(/v([0-9]+)(?:\.([0-9]+))?/)
22
22
 
23
- const versionRequirement = match ? match[1] : 0;
23
+ const majorRequirement = match ? match[1] : 0;
24
+ const minorRequirement = match && match[2];
24
25
 
25
- if (processMajor < versionRequirement) {
26
- console.log(`skipping ${filename} as this is Node.js v${processMajor} and test wants v${versionRequirement}`);
26
+ if (processMajor < majorRequirement && minorRequirement === undefined) {
27
+ console.log(`skipping ${filename} as this is Node.js v${processMajor} and test wants v${majorRequirement}`);
28
+ process.exit(0);
29
+ }
30
+ if (processMajor < majorRequirement && processMinor < minorRequirement) {
31
+ console.log(`skipping ${filename} as this is Node.js v${processMajor}.${processMinor} and test wants >=v${majorRequirement}.${minorRequirement}`);
27
32
  process.exit(0);
28
33
  }
29
34