unable to import sucrase since vite2.8
See original GitHub issueDescribe the bug
got the error TypeError: import_NameManager.default is not a constructor
, and I inspected a bit, the problem is that sucrase
uses index.mjs
as esm module entry, but then vite will import sub modules from .js
files instead of .mjs
files, whilst sucrase
imports esm module without extension, it will work if I use import_NameManager.default.default
, right now I have to use resolve.alias
to sucrase: 'sucrase/dist/index.js',
as a workaround, and the problem only happens with dev
but works with build
, and only since vite@2.8
Reproduction
https://stackblitz.com/edit/vitejs-vite-ntzpyn?file=main.js&terminal=dev
System Info
Binaries:
Node: 14.19.0 - /usr/local/bin/node
Yarn: 1.22.10 - /bin/yarn
npm: 7.17.0 - /bin/npm
npmPackages:
vite: ^2.8.0 => 2.8.4
Used Package Manager
npm
Logs
No response
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.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- 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 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
SyntaxError: Cannot use import statement outside a module
It's async and so can't be used to import anything at the file level. Which makes trying to access es6 modules from CommonJS...
Read more >sucrase - npm
Start using sucrase in your project by running `npm i sucrase`. ... If preserveDynamicImport is not specified, import expressions are ...
Read more >A curated list of awesome things related to Vite.js - Morioh
In this library, we will learn about Awesome Vite.js: A Curated List Of Awesome Things Related to Vite.js.
Read more >high meat diet: Topics by Science.gov
Also, the MEAT diet caused an 8% higher HDL-cholesterol concentration (P < 0.001) and a 4% higher apo A-I concentration (P = 0.033)...
Read more >Untitled
Caderno 1/4 espiral, Gallant zebra ep zip, Tomee netbeans 8, Non-urgent pap test ... Best time cycle not get pregnant, Import brushes in...
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 FreeTop 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
Top GitHub Comments
I think we can close this ticket as it’s fixed from the package side
I forced vite/esbuild to import cjs version instead via alias
sucrase: 'sucrase/dist/index.js',
to solve the problem right now