李恒道 发表于 2022-3-25 00:15:16

webpackjsonp修改命名以及命名问题

# 参考资料

https://webpack.js.org/blog/2020-10-10-webpack-5-release/#changes-to-the-structure

```
Automatic unique naming
In webpack 4 multiple webpack runtimes could conflict on the same HTML page, because they use the same global variable for chunk loading. To fix that it was needed to provide a custom name to the output.jsonpFunction configuration.

Webpack 5 does automatically infer a unique name for the build from package.json name and uses this as default for output.uniqueName.

This value is used to make all potential conflicting globals unique.

MIGRATION: Remove output.jsonpFunction in favor of a unique name in your package.json.
```

翻译

```
自动唯一命名

在webpack4 同一页面中多个webpack运行可能会产生冲突,因为他们使用了相同全局变量在chunk加载时,修复这个问题我们需要提供一个自定义名字在webpack.config.js中的output选项中配置jsonpFunction选项

而在webpack5中会自动推断唯一名字在构建过程中,名字取决于package.json的名字作为默认名字,用于output.uniqueName项

这个值用于所有潜在冲突的全局变量

迁移提示:移除output.jsonpFunction 去使用唯一名字在你的package.json文件中
```
页: [1]
查看完整版本: webpackjsonp修改命名以及命名问题