-
-
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
[Bug]: .esm.js is ignored in extensionsToTreatAsEsm #11809
Comments
That is how file extensions work. https://en.wikipedia.org/wiki/Filename_extension
I guess we could add some validation to For your use case I recommend using |
Of course I would use |
Ironically, the article you linked also contains this nugget:
(emphasis mine). |
Also, TypeScript’s Of course, jest could also be smart enough to recognize that tslib’s |
We have also come across this issue because Swiper v7 uses |
If you use
Jest respects https://github.com/microsoft/tslib/blob/c827964226e85118e2fd35b1cc68d4a5ad867f39/package.json#L32
Almost the same thing, but e.g. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
27.1.0
Steps to reproduce
extensionsToTreatAsEsm
to['.esm.js']
.something.esm.js
.Expected behavior
The imported file should be treated as esm.
Actual behavior
The imported file will be treated as CommonJS.
Additional context
AFAICT the culprit is this snippet in
packages/jest-resolve/src/shouldLoadAsEsm.ts
:Which assumes only the last part of the file name needs to be checked against the configured extensions.
Environment
The text was updated successfully, but these errors were encountered: