feat: add export replacement capabilities to hooks - #292
Draft
BridgeAR wants to merge 2 commits into
Draft
Conversation
Hooks that only mutate nested module values currently force IITM to create and synchronize a local cell for every export. This breaks delayed live bindings such as `class Sub extends Late` and adds startup work for export-heavy ESM modules. This adds `replaceExports`: omitted keeps wildcard legacy behavior, an empty list preserves source live bindings, and named entries limit replacement to those bindings. The empty-list ESM fast path uses native re-exports and avoids per-export wrapper state; on 40 ESM modules with 251 exports it reduced import time 61–64% with sync hooks and 48–51% with async hooks across repeated trimmed trials. CommonJS, builtins, and named replacement sets retain the existing compatibility path. Refs: #280
Node can expose CommonJS properties that are absent from a builtin's fixed ESM facade. Derived re-exports then fail during wrapper instantiation. A distinct wrapper URL keeps native passthrough bindings live without resolving them back to the wrapper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hooks that only mutate nested module values currently force IITM to create and synchronize a local cell for every export. This breaks delayed live bindings such as
class Sub extends Lateand adds startup work for export-heavy ESM modules.This adds
replaceExports: omitted keeps wildcard legacy behavior, an empty list preserves source live bindings, and named entries limit replacement to those bindings. The empty-list ESM fast path uses native re-exports and avoids per-export wrapper state; on 40 ESM modules with 251 exports it reduced import time 61–64% with sync hooks and 48–51% with async hooks across repeated trimmed trials. CommonJS, builtins, and named replacement sets retain the existing compatibility path.Refs: #280