We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I found I can only read the default export from a cjs package.
Reproduction: https://github.com/Jinjiang/reproductions/tree/vite-plugin-commonjs-20230825
e.g.:
// // it works // import { a } from 'local-debug/foo' // it doens't work const { a } = require('local-debug/foo') console.log({ a })
Thanks.
The text was updated successfully, but these errors were encountered:
After more digging, I found the require() statement would be converted into code like
require()
import __vite__cjsImportX__foo from "foo"; const __CJS__import__X__ = __vite__cjsImportX__foo; const x = __CJS__import__X__.default || __CJS__import__X__;
which would overwrite the named imports with the default import, and then cause the issue. (If I'm not wrong).
Do you think there is any better ways to support this case?
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
I found I can only read the default export from a cjs package.
Reproduction:
https://github.com/Jinjiang/reproductions/tree/vite-plugin-commonjs-20230825
e.g.:
Thanks.
The text was updated successfully, but these errors were encountered: