-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support importing CommonJS from ESM files #9842
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9842 +/- ##
==========================================
- Coverage 64.52% 64.45% -0.08%
==========================================
Files 290 290
Lines 12325 12336 +11
Branches 3048 3052 +4
==========================================
- Hits 7953 7951 -2
- Misses 3732 3744 +12
- Partials 640 641 +1
Continue to review full report at Codecov.
|
initializeImportMeta(meta: ImportMeta) { | ||
meta.url = pathToFileURL(modulePath).href; | ||
}, | ||
}); | ||
|
||
this._esmoduleRegistry.set(cacheKey, module); | ||
|
||
await module.link((specifier: string, referencingModule: VMModule) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually quite the bugfix moving this in here, dynamic import of ESM didn't work unless it was cached already 😀 (modules must be linked and evaluated before being returned)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Luckily importing CJS from ESM should use the normal
require
caching mechanisms, so we can just hook into the code we already have for this.Test plan
E2E test expanded with new test cases.