npm / import-in-the-middle
import-in-the-middle
What changed in import-in-the-middle 2 to 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-21.
1 breaking3 new APIs and options4 performance2 behavior and defaults24 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initimport-in-the-middle 320 changes
Breaking changes 1
Support for Node.js versions below 18 has been dropped.
New APIs and options 3
CJS source stripping can now be disabled.
Adds a predicate for matching consumer-owned modules.
Adds synchronous loader hooks via module.registerHooks.
Performance 3
Reduces ESM wrapper allocations, improving performance.
Replaces acorn with es-module-lexer for ESM parsing.
Shrinks generated wrapper source.
Behavior and default changes 2
Adds support for es-module-lexer v3, allowing developers to use that version with import-in-the-middle.
Instrumentation now supports type-stripped TypeScript modules.
Fixes and other changes 11
Duplicate TypeScript export names are removed.
Restores compatibility with legacy bundlers.
TypeScript is stripped after loaders normalize the format.
Code generation is skipped on broken maglev.
Loader URLs are escaped in generated wrappers.
Tagged modules are delegated to their owning loader.
Guards against circular recursion when processing export-star declarations.
Keeps get-esm-exports synchronous so require() continues to work.
Resolves re-exported values from the module where they are defined.
Updated proxying logic for builtins used as CJS.
File specifiers from turbopacked packages are handled better.
import-in-the-middle 214 changes
Performance 1
Improves performance by calculating fewer stack frames and using fast paths.
Fixes and other changes 13
Fixes issues with duplicate entries.
The callback name argument is now the module name when matching the module main file, including when the internals option is used.
Builtin modules that require the node: prefix are now properly hooked.
Fixes issues with specifier (submodule) matching.
Recognizes the entrypoint as CommonJS when loader chains add query params to file URLs.
Handles lazy initialization and circular dependencies.
Top-level modules are no longer instrumented.
Removes a small memory leak.
No longer crashes when setters are missing.
Handles undefined exports properly.
Properly handles internals when the specifier matches.
Properly hooks submodule package exports.
Modules running in the loader thread were converted to ESM to work around loader issues.