Skip to content
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

compat: cjs to esm translation is not applied when a commonjs module is dynamically imported with file:// scheme #13790

Closed
kt3k opened this issue Feb 28, 2022 · 1 comment · Fixed by #13792
Assignees
Labels
bug Something isn't working correctly node compat

Comments

@kt3k
Copy link
Member

kt3k commented Feb 28, 2022

mocha formats the importing specifier to file://-scheme url before calling import() ref: https://github.com/mochajs/mocha/blob/547ffd73535088322579d3d2026432112eae3d4b/lib/nodejs/esm-utils.js#L7

If the file url is passed to import() and the module is a commonjs, then cjs->esm translation is not applied to that file in compat mode.

@kt3k kt3k changed the title compat: cjs to esm translation is not applied when a commonjs module is loaded with file:// scheme compat: cjs to esm translation is not applied when a commonjs module is dynamically imported with file:// scheme Feb 28, 2022
@bartlomieju bartlomieju self-assigned this Feb 28, 2022
@bartlomieju bartlomieju added node compat bug Something isn't working correctly labels Feb 28, 2022
@bartlomieju
Copy link
Member

bartlomieju commented Feb 28, 2022

@kt3k I'm gonna need some more data points for this one. I opened #13792 that does what you described and it works fine.

Ooops, I made mistake in test code, I can reproduce after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants