import-in-the-middle 1.14.0 → 1.14.2
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/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/hook.js +10 -6
- package/package.json +1 -1
- package/test/fixtures/invalid-identifier.js +8 -0
- package/test/fixtures/module-exports-cjs-shim.mjs +7 -0
- package/test/hook/v16-fake-cjs-export.mjs +4 -0
- package/test/hook/v16-invalid-identifier.mjs +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.14.2](https://github.com/nodejs/import-in-the-middle/compare/import-in-the-middle-v1.14.1...import-in-the-middle-v1.14.2) (2025-06-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* do not replace dollar sign in shim variable name ([#200](https://github.com/nodejs/import-in-the-middle/issues/200)) ([20bf0e5](https://github.com/nodejs/import-in-the-middle/commit/20bf0e5c5f6f44f42a8618ad45d08622a63d4d45))
|
|
9
|
+
|
|
10
|
+
## [1.14.1](https://github.com/nodejs/import-in-the-middle/compare/import-in-the-middle-v1.14.0...import-in-the-middle-v1.14.1) (2025-06-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Account for invalid identifiers ([#198](https://github.com/nodejs/import-in-the-middle/issues/198)) ([2cc8207](https://github.com/nodejs/import-in-the-middle/commit/2cc82070a5ca947463b70f28647b03496a9526f0))
|
|
16
|
+
|
|
3
17
|
## [1.14.0](https://github.com/nodejs/import-in-the-middle/compare/import-in-the-middle-v1.13.2...import-in-the-middle-v1.14.0) (2025-05-24)
|
|
4
18
|
|
|
5
19
|
|
package/hook.js
CHANGED
|
@@ -254,19 +254,23 @@ async function processModule ({ srcUrl, context, parentGetSource, parentResolve,
|
|
|
254
254
|
addSetter(name, setter, true)
|
|
255
255
|
}
|
|
256
256
|
} else {
|
|
257
|
+
const variableName = `$${n.replace(/[^a-zA-Z0-9_$]/g, '_')}`
|
|
258
|
+
const objectKey = JSON.stringify(n)
|
|
259
|
+
const reExportedName = n === 'default' || NODE_MAJOR < 16 ? n : objectKey
|
|
260
|
+
|
|
257
261
|
addSetter(n, `
|
|
258
|
-
let
|
|
262
|
+
let ${variableName}
|
|
259
263
|
try {
|
|
260
|
-
|
|
264
|
+
${variableName} = _[${objectKey}] = namespace[${objectKey}]
|
|
261
265
|
} catch (err) {
|
|
262
266
|
if (!(err instanceof ReferenceError)) throw err
|
|
263
267
|
}
|
|
264
|
-
export {
|
|
265
|
-
set
|
|
266
|
-
|
|
268
|
+
export { ${variableName} as ${reExportedName} }
|
|
269
|
+
set[${objectKey}] = (v) => {
|
|
270
|
+
${variableName} = v
|
|
267
271
|
return true
|
|
268
272
|
}
|
|
269
|
-
get
|
|
273
|
+
get[${objectKey}] = () => ${variableName}
|
|
270
274
|
`)
|
|
271
275
|
}
|
|
272
276
|
}
|
package/package.json
CHANGED