-
-
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]: default import not importing properly with esm + ts-jest #12571
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
Hi @blainelewis1 did you resolve this by any chance? I'm coming across the same issue where emotion/styled seems to be wrapped in 2 default keys. |
@maddijoyce unfortunately I wasn't able to resolve the issue. It's for a side project so I haven't had much time (or really any idea where to start). I was wondering if maybe the ts compiler is reading the wrong tsconfig file and ignoring a setting like |
Alrighty @blainelewis1 I'm circling back around on this, since I did a bit more investigation. I managed to reproduce the issue using just emotion/styled and an esm package in node 16 - https://github.com/maddijoyce/emotion-esm-issue - so it looks to be an issue with how emotion works with the newer node esm stuff. I'm going to throw up an issue on the emotion repo. In the meantime, if you're looking to resolve this issue just in your jest tests (like I am), you can use this fairly hacky workaround 😄 Add a new file (say emotion-styled.js)
Then add to your jest.config:
Alternatively, if your tests don't need to use es modules (mine do), you could just remove this node option |
Yeah, fake default exports (as produced by babel, tsc etc) never work well with native ESM. Regardless, issue in emotion, not here |
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.3
Steps to reproduce
Expected behavior
I expect the package to be imported properly and not hidden behind another layer of
default
. When using other build tools it works properly.It should be able to import and run the file properly.
Actual behavior
The module is not imported properly, the contents are hidden behind a key on an object called
default
.Minimal repro: https://github.com/blainelewis1/jest-default-esm-repro
Additional context
No response
Environment
System: OS: macOS 12.0.1 CPU: (10) arm64 Apple M1 Max Binaries: Node: 17.2.0 - /opt/homebrew/bin/node Yarn: 1.22.17 - /opt/homebrew/bin/yarn npm: 8.1.4 - /opt/homebrew/bin/npm npmPackages: jest: ^27.5.1 => 27.5.1
The text was updated successfully, but these errors were encountered: