-
Notifications
You must be signed in to change notification settings - Fork 116
-
Notifications
You must be signed in to change notification settings - Fork 116
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
[Bug]: require.context issue #3486
Comments
Hello @yc0123450. Please provide a reproduction repository or online demo. For background, see Why reproductions are required. Thanks ❤️ |
@chenjiahan 已经补充仓库demo地址,因为项目比较复杂,精简后没有本地运行测试,只是测试了打包后用yarn preview进行预览,控制台就能看到报错内容,打包预计2分钟。完整项目就和我描述的一样,本地运行正常,就是打包后报错。 |
This error is caused by the class name being compressed, To solve this problem you can set (Why not
source code: class VectorLineModel {
constructor() {
console.log('init VectorLineModel')
}
getHighwayCodeList() {
console.log('VectorLineModel')
}
}
export default VectorLineModel |
@9aoy thanks,set |
Version
Details
我的项目中使用了require.context动态加载一些模块,然后默认导出给别的地方引用使用,本地运行没有问题,打包上线后报错如下图。就算改成使用import.meta.webpackContext也一样报错。动态加载的文件都会默认导出一个类似xxxModel对象,然后动态加载后全部导出,在其他地方引入对应xxxModel使用。
Reproduce link
https://gitee.com/ychaoweb/test-demo
Reproduce Steps
npm i yarn -g
yarn
yarn build
yarn preview
使用yarn进行的包管理,打包后预览就能看到报错了
The text was updated successfully, but these errors were encountered: