-
Notifications
You must be signed in to change notification settings - Fork 795
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: upgrade to v2.14.0 breaks jest tests using esm #3251
Comments
Thanks! I'll label this to get ingested into our backlog |
I @alicewriteswrongs - I also created a PR that fixes the issue: I have not tested your fix yet (or looked at the differences between your PR and mine), but will do so when I have the time. |
Ah apologies that I missed that you had already submitted a PR. I haven't taken a thorough look yet, but I'll say first off that the PR I just put up it quite a bit more minimal - it doesn't attempt to leverage Jest's After reading through all of the related code I do think that the intent when the Jest preprocessor and whatnot was written was for |
This adds support for importing from ES modules (w/ the `.mjs` extension) in spec tests by ensuring that 1. files with such an extension are passed to the jest preprocessor (which then runs them through typescript) 2. our typescript helper for string-to-strong transpilation will emit `.mjs` files instead of just dropping them on the floor Together these changes will allow running specs which import `.mjs` files. See #3251 for the original issue report
Thanks for the info @alicewriteswrongs . Browsers support ESM, and jest/node supports ESM; though when I wrote this bug and wrote the fix the node support required the Whether it's a feature or a bug, I just want to be able to use ESM in tests without transpilation to CJS - all our other jest tests and the rest of our codebase have used ESM for over a year. |
Totally understand where you're coming from. We want to get ESM support for Stencil tests stood up too. As I mentioned above, we're starting to do some larger scale planning and work around Stencil's test infrastructure, and while I can't share a definite timeline right now we'll definitely be looking at ESM support as part of that. We'll also keep #3230 open to track the feature request. |
Prerequisites
Stencil Version
2.14.0
Current Behavior
Tests using external
jest.config.js
file (necessary to transform .mjs and .js files using ES modules) work fine using @stencil/core 2.13.0 . Upgrading to 2.14.0 results in errors like:This occurs in tests with dependencies on external ESM files, which have dependencies on other external ESM files.
The external jest config adds support for processing .mjs files, and that's about it:
Expected Behavior
No breaking change in test running when upgrading to @stencil.core 2.14.0
Steps to Reproduce
Yields this error:
To fix, downgrade to @stencil/core version 2.13.0 :
Code Reproduction URL
https://github.com/johncrim/repro-stencil-jest
Additional Information
I found a number of other bug reports in this repo reporting the same error message; however this is a regression from 2.13.0 to 2.14.0, so I felt it warranted a separate bug.
This is topically related to another feature request, which I have started working on: #3230 . However for this bug, everything is running in traditional jest mode (CJS), which means all ES modules have to be transpiled to CJS.
The text was updated successfully, but these errors were encountered: