我的应用程序可以在其他浏览器上运行,但不能(在 v44 上)如果我删除延迟加载,它可以正常工作。
我正在使用React.lazy
并Suspense
拆分我的代码。
- 通天塔 7.5.0
- 网络包 4.28.3
- 反应 16.7.0
尝试过搞乱 webpack 和 babel 配置。似乎错误是由 eval 中的以下代码引发的。我认为这是杀死它的传播语法。但是,我不知道如何让 babel 将其转换为 es5 作为其 webpack 代码本身。
function reduce(state = {}, action) {
return {
dirtyHandlerIds: Object(_dirtyHandlerIds__WEBPACK_IMPORTED_MODULE_3__["default"])(state.dirtyHandlerIds, {
type: action.type,
payload: {
...action.payload,
prevTargetIds: Object(_utils_js_utils__WEBPACK_IMPORTED_MODULE_5__["get"])(state, 'dragOperation.targetIds', []),
},
}),
dragOffset: Object(_dragOffset__WEBPACK_IMPORTED_MODULE_0__["default"])(state.dragOffset, action),
refCount: Object(_refCount__WEBPACK_IMPORTED_MODULE_2__["default"])(state.refCount, action),
dragOperation: Object(_dragOperation__WEBPACK_IMPORTED_MODULE_1__["default"])(state.dragOperation, action),
stateId: Object(_stateId__WEBPACK_IMPORTED_MODULE_4__["default"])(state.stateId),
};
}
网络包配置:
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, '../build'),
publicPath: '/',
chunkFilename: '[name].bundle.js',
filename: 'bundle.js'
},
optimization: {
sideEffects: true
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'] // loads js
},
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: ['ts-loader'] // loads ts
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'] // handles css
}
]
},
// gets it to bundle index.html
plugins: [
new HtmlWebpackPlugin({
template: path.resolve('./public/index.html')
})
],
// makes it able to resolve .jsx calls without explicit suffix
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
};
通天塔配置
module.exports = {
presets: [
'@babel/preset-env',
'@babel/react'
],
plugins: [
'@babel/plugin-proposal-class-properties',
'@babel/plugin-syntax-dynamic-import',
[
'import',
{
libraryName: 'antd',
style: true
}
]
],
env: {
test: {
plugins: [
'transform-es2015-modules-commonjs'
]
}
}
};
预期:像其他浏览器一样在边缘工作
实际:一旦你碰到触发延迟加载的东西就会死亡