|
|
@@ -20,10 +20,13 @@ module.exports = {
|
|
|
maxEntrypointSize: 2000000
|
|
|
},
|
|
|
resolve: {
|
|
|
- // xlsx 依赖的 sax 里有一行 require('stream')(仅流式解析用,浏览器走不到),
|
|
|
- // webpack5 默认不打包 node 内置模块,显式置空消掉构建警告
|
|
|
- fallback: {
|
|
|
- stream: false
|
|
|
+ // webpack5 默认不打包 node 内置模块:sax 在模块加载阶段就会 require('stream'),
|
|
|
+ // 若把 stream 置空(fallback: { stream: false }),require 不会抛错但取到的
|
|
|
+ // .Stream 是 undefined,sax 执行 Stream.prototype 时会报
|
|
|
+ // “Cannot read properties of undefined (reading 'prototype')”,导致应用启动即崩。
|
|
|
+ // 这里改为指向一个最小实现的桩模块,既消掉构建告警,也保证运行期不报错。
|
|
|
+ alias: {
|
|
|
+ stream: path.resolve(__dirname, 'build/stream-stub.js')
|
|
|
}
|
|
|
},
|
|
|
output: {
|