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-12-05.
1 breaking4 new APIs and options6 performance2 behavior and defaults31 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initimport-in-the-middle 330 changes
Breaking changes 1
Support for Node.js versions below 18 has been dropped.
New APIs and options 4
Callbacks can now access the module format.
CJS source stripping can now be disabled.
Adds a predicate for matching consumer-owned modules.
Adds synchronous loader hooks via module.registerHooks.
Performance 5
Resolves module details once per load.
The loader avoids redundant URL and filter work.
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 18
Preserves initialization for circular re-exports.
Preserves values for circular star exports.
Resolves TypeScript declarations for synchronous hooks.
The ESM loader now ignores source supplied for builtin modules.
The loader now preserves the resolved format for extensionless entrypoints.
Hooks now match scoped packages on Windows.
TypeScript is stripped before export discovery.
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.