-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
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
使用import {xxx}导入commonjs的module.exports导出的对象语法报错 , does not provide an export name “name” #15
Comments
我是将vue-cli项目升级为vite,由于webpack支持esm和commonjs混合写法,所以我们项目里面有很多地方是这样写的。升级为vite后不想每个地方都去改一次。 |
那你可以试试这个:https://github.com/originjs/webpack-to-vite#vue-cli-conversion |
还有一个问题,在计算属性里面require 图片会提示require is not defuned。 computed:{ 抱歉,手机敲得代码,公司电脑无法登录github。 |
抱歉,动态的导入,我们没有处理,也处理不了, 你知道vite项目只能使用ESM,所以我们必须把require转换成import,而import后面只能是一个常量字符串,如果使用动态导入 |
好的,谢谢,那我还是全局正则替换吧 |
好的,转换过程中有疑问可以找我们一起讨论。 前面那个问题我在考虑要不要把 vite-plugins/packages/vite-plugin-commonjs/src/index.ts Lines 56 to 62 in 4b24ab7
|
好的,谢谢,如果解决了上面的commonjs和esm混用的问题麻烦说一下哇。我将包升级,这样就不需要每个地方去修改了。 |
Versions
Reproduction
Additional Details
Steps to reproduce
What is Expected?
What is actually happening?
导入处代码main.js:
import {name} from ./demo
导出处代码demo.js:
module.exports={
name:1111
}
提示报错:does not provide an export name “name”
The text was updated successfully, but these errors were encountered: