import-in-the-middle 1.4.2 → 1.5.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
@@ -100,7 +100,11 @@ function createHook (meta) {
100
100
  return url
101
101
  }
102
102
 
103
- if (context.importAssertions && context.importAssertions.type === 'json') {
103
+ // Node.js v21 renames importAssertions to importAttributes
104
+ if (
105
+ (context.importAssertions && context.importAssertions.type === 'json') ||
106
+ (context.importAttributes && context.importAttributes.type === 'json')
107
+ ) {
104
108
  return url
105
109
  }
106
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "import-in-the-middle",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Intercept imports in Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -4,6 +4,13 @@
4
4
 
5
5
  import { rejects } from 'assert'
6
6
  (async () => {
7
+ const [processMajor, processMinor] = process.versions.node.split('.').map(Number)
8
+ const extensionlessSupported = processMajor >= 21 ||
9
+ (processMajor === 20 && processMinor >= 10)
10
+ if (extensionlessSupported) {
11
+ // Files without extension are supported in Node.js >= 20.10.0
12
+ return
13
+ }
7
14
  await rejects(() => import('./executable'), {
8
15
  name: 'TypeError',
9
16
  code: 'ERR_UNKNOWN_FILE_EXTENSION'