import-in-the-middle 2.0.1 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.0.2](https://github.com/nodejs/import-in-the-middle/compare/import-in-the-middle-v2.0.1...import-in-the-middle-v2.0.2) (2026-01-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * grammar issue in README.md ([#216](https://github.com/nodejs/import-in-the-middle/issues/216)) ([46e4a2a](https://github.com/nodejs/import-in-the-middle/commit/46e4a2a9ad250c06fb52c9b782370071a6d1f3cc))
9
+ * properly handle internals when specifier matches ([#220](https://github.com/nodejs/import-in-the-middle/issues/220)) ([05e4216](https://github.com/nodejs/import-in-the-middle/commit/05e4216e10d11c7eb996d4124f36e476f3a6d42f))
10
+
3
11
  ## [2.0.1](https://github.com/nodejs/import-in-the-middle/compare/import-in-the-middle-v2.0.0...import-in-the-middle-v2.0.1) (2025-12-18)
4
12
 
5
13
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # import-in-the-middle
2
2
 
3
- **`import-in-the-middle`** is an module loading interceptor inspired by
3
+ **`import-in-the-middle`** is a module loading interceptor inspired by
4
4
  [`require-in-the-middle`](https://npm.im/require-in-the-middle), but
5
5
  specifically for ESM modules. In fact, it can even modify modules after loading
6
6
  time.
package/index.js CHANGED
@@ -140,14 +140,16 @@ function Hook (modules, options, hookFn) {
140
140
 
141
141
  if (modules) {
142
142
  for (const moduleName of modules) {
143
- if (moduleName === specifier) {
144
- callHookFn(hookFn, namespace, name, baseDir)
145
- } else if (moduleName === name) {
143
+ const nameMatch = moduleName === name
144
+ const specMatch = moduleName === specifier
145
+ if (nameMatch || specMatch) {
146
146
  if (baseDir) {
147
147
  if (internals) {
148
148
  name = name + path.sep + path.relative(baseDir, fileURLToPath(filename))
149
149
  } else {
150
- if (!getExperimentalPatchInternals() && !baseDir.endsWith(specifiers.get(filename))) continue
150
+ if (!getExperimentalPatchInternals() && !specMatch && !baseDir.endsWith(specifiers.get(filename))) {
151
+ continue
152
+ }
151
153
  }
152
154
  }
153
155
  callHookFn(hookFn, namespace, name, baseDir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "import-in-the-middle",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Intercept imports in Node.js",
5
5
  "main": "index.js",
6
6
  "scripts": {