0.17.0 regression: named imports of commonjs lib raise error
See original GitHub issueEnv Node v16.13.0 nite-ssg 0.17.0
While playing with vitesse templates, I try third party UI components, after pnpm i -S naive-ui
, I import component by add one liner inside pages/index.vue
import {NButton} from naive-ui
while npm run build
raise the following error:
[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
file:///home/fang/Project/web/vitesse-main/.vite-ssg-temp/main.mjs:27
import { NButton } from "naive-ui";
^^^^^^^
SyntaxError: Named export 'NButton' not found. The requested module 'naive-ui' 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:
vite-ssg 0.16.2 give green light on npm run build
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Node.js now supports named imports from CommonJS ...
The Workaround: What to do when named imports don't work for a CJS module. The good news is that, as the error message...
Read more >rollup changelog
Fix a situation where invalid code was rendered when dynamically importing a module with synthetic named exports when preserving modules (#3738) ...
Read more >steal-rollup | Yarn - Package Manager
Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library...
Read more >node_modules/rollup/CHANGELOG.md · feature/npm-module
Generate proper namespace objects when dynamically importing external dependencies for AMD or CJS formats (#2954) · Fix dynamically imported variables not being ...
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
... fails with error message" status:RESOLVED resolution:OBSOLETE severity:normal ... Bug:96449 - "New: fusd A library and kernel module to create userpsace ...
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
same proplem !! Isn’t this what evan recommended? Are there any other options besides cjs? Because I also need to use swiper,it only supports esm mode 😮💨 it’s really hard to choose😭
Try set
in your vite.config.js with v0.17.2