question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to import sucrase since vite2.8

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nihgwucommented, Apr 14, 2022

I think we can close this ticket as it’s fixed from the package side

1reaction
nihgwucommented, Mar 11, 2022

I forced vite/esbuild to import cjs version instead via alias sucrase: 'sucrase/dist/index.js', to solve the problem right now

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found