[英]Uncaught TypeError: __webpack_require__.e is not a function
I get the error Uncaught TypeError: __webpack_require__.e is not a function
when loading my Chrome extension.我在加载 Chrome 扩展程序时收到错误
Uncaught TypeError: __webpack_require__.e is not a function
。 The error is triggered when loading the background.js
script.加载
background.js
脚本时触发错误。
/******/ /* webpack/runtime/eagerly load chunks */
/******/ (() => {
/******/ __webpack_require__.e(352) //Error trigged at this line.
/******/ })();
Their is already a question on this topic.他们已经是关于这个话题的一个问题。 I am not sure how to apply the proposed solution.
我不确定如何应用建议的解决方案。 Do I need to create a cache group for all dependencies?
我需要为所有依赖项创建一个缓存组吗?
Also, how do I know which modules is being imported?另外,我怎么知道正在导入哪些模块? (module ref 352)
(模块参考 352)
package.json package.json
...
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
"vue": "^2.6.11",
"vue-loader": "^15.8.3",
"vue-template-compiler": "^2.6.11",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.9.3",
"webpack-target-webextension": "^1.0.3"
}
...
webpack.config.js webpack.config.js
const WebExtension = require('webpack-target-webextension');
const CopyPlugin = require("copy-webpack-plugin");
const webpack = require('webpack');
const path = require('path');
/** @type {webpack.Configuration} */
const config = {
// No eval allowed in MV3
devtool: 'cheap-source-map',
entry: {
background: path.join(__dirname, './src/background.js'),
/*options: path.join(__dirname, './src/options.js'),
popup: path.join(__dirname, './src/popup.js'),*/
},
optimization: {
minimize: false,
},
output: {
path: path.join(__dirname, './dist'),
// Our assets are emitted in /dist folder of our web extension.
publicPath: '/dist/',
},
resolve: {
alias: {
core: path.join(__dirname, 'background'),
},
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "./src/manifest.json"},
{
from: "src/*.html",
to({ context, absoluteFilename }) {
return "./[name][ext]";
},
}
],
}),
new WebExtension({
background: {
entry: 'background',
manifest: 3,
weakRuntimeCheck: true,
},
}),
],
// Add devServer.hot = true or "only" to enable HMR.
devServer: {
hot: 'only',
},
}
module.exports = config
My code project is available here: https://github.com/h3xstream/test-extension我的代码项目在这里可用: https://github.com/h3xstream/test-extension
npm install
npm run build
Looks like the issue is sticking with package webpack-target-webextension
itself.看起来问题在于 package
webpack-target-webextension
本身。 I quickly checked its repo and apparently there's an opening issue on the repo which suggests you to have a dynamic import in your file as a hackaround way.我很快检查了它的 repo,显然 repo 上有一个开放问题,这表明你在文件中动态导入作为一种hackaround方式。 But looks like there's another way to fix that by turning off
eagerChunkLoading
:但看起来还有另一种方法可以通过关闭
eagerChunkLoading
来解决这个问题:
new WebExtension({
background: {
// ...
eagerChunkLoading: false,
},
}),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.