[0.20.2]: Tets fails if importing `tslib`
See original GitHub issueDescribe the bug
After upgrading to v0.20.x, most of my tests are now failing with:
SyntaxError: Named export '__assign' not found. The requested module 'tslib' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'tslib';
const { __assign } = pkg;
It’s caused by framer-motion using tslib. The package does include an exports field and module support, so a bit weird why this is popping up. Thinking it’s related to how node modules are resolved now after #1673.
Reproduction
The issue can be replicated by importing <framer-motion>
in a test file.
https://stackblitz.com/edit/vitest-dev-vitest-ue9bu2?file=test/App.test.tsx
System Info
System:
OS: Linux 5.0 undefined
CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.10 - /bin/yarn
npm: 7.17.0 - /bin/npm
npmPackages:
@vitejs/plugin-react: ^1.3.2 => 1.3.2
vite: ^2.9.9 => 2.9.14
vitest: 0.20.2 => 0.20.2
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:10 (3 by maintainers)
Top Results From Across the Web
tslib should follow standards for ESM/CJS detection · Issue #173
Due to lack of standards support, it has to be special-cased in a number ... [0.20.2]: Tets fails if importing tslib vitest-dev/vitest#1753.
Read more >"This syntax requires an imported helper but module 'tslib ...
If you see this error the first time you open a new project or repository, you probably simply haven't installed the app's required...
Read more >Release Notes — pandas 0.20.2 documentation - PyData |
This is the list of changes to pandas between each release. ... Panel.to_frame() no longer fails when major_axis is a MultiIndex (GH5402).
Read more >This syntax requires an imported helper but module 'tslib ...
To solve the error "This syntax requires an imported helper but module 'tslib' cannot be found", install tslib by running npm install -D...
Read more >jasmine an error was thrown in afterall - You.com
If you don't know which test is causing the error, you can write xdescribe instead of describe for all tests and this will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Setting deps.registerNodeLoader to
false
(to skip the new Node logic) allows the test to run again.Technically this PR should also work with
registerNodeLoader
enabled, but performance might suffer for now.