vuejs/vue-cli

打包成lib库后,导入主应用中,浏览器一直报Uncaught TypeError: Cannot read properties of undefined (reading 'pushScopeId')

VVzhouxiaobai opened this issue · 3 comments

Version

5.0.8

Environment info

package.json配置vue-cli-service build --mode production --dest dist --target lib --name sjzl ./src/entry.js

Steps to reproduce

直接npm run build后把打包的库通过script链接和link样式引入主应用中,然后就报上述错误

What is expected?

我发现那个错误就是打包后的__webpack_require__(7203)这句没有获取到

What is actually happening?

就是vue3+webpack打包后在引用就报上述错误

我测试了几个版本
最开始我以为是ts问题
用webpack+ts 和webpack+js都试了一下webpack都没问题
当我回到vite+ts 就有问题了 最开始报错是找不到导出语句 后来我换了导入语句
import * as datav from 'echarts-screen-libs'
果然不报错
但是浏览器还是不能运行
报错如下
screendatav.js:11 Uncaught TypeError: Cannot read properties of undefined (reading 'pushScopeId')
at _withScopeId (screendatav.js:11:36)
at screendatav.js:13:38
at screendatav.js:4:101
at screendatav.js:5:3

还是没解决 如果还是不行 我就不用vite了用webpack去了

最新解决 我刚刚看到一篇文章 rollup不支持 scoped了 去掉scoped后 报错变成了 Cannot read properties of undefined (reading 'createElementVNode')