简体   繁体   English

未捕获的类型错误:__webpack_require__.e 不是 function

[英]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)

Source Code源代码

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.

相关问题 未捕获的类型错误:__webpack_require__.r 不是函数 - Uncaught TypeError: __webpack_require__.r is not a function 未捕获的类型错误:__webpack_require__(...).context 不是 function - Uncaught TypeError: __webpack_require__(...).context is not a function 诊断未捕获的TypeError:__webpack_require __(…).createServer不是函数? - Diagnosing Uncaught TypeError: __webpack_require__(…).createServer is not a function? jQuery 浮图使用 webpack 生成“Uncaught TypeError: e.setTimeout is not a function” - jQuery flot charts generate "Uncaught TypeError: e.setTimeout is not a function" with webpack Uncaught TypeError: Object(...) is not a function 当与 WebPack 4 捆绑时 - Uncaught TypeError: Object(...) is not a function when bundling with WebPack 4 使用 webpack 获取“未捕获的类型错误:$(...).tablesorter is not a function” - Getting 'Uncaught TypeError: $(...).tablesorter is not a function' using webpack Require.js Uncaught TypeError:undefined不是函数 - Require.js Uncaught TypeError: undefined is not a function Require.js未被捕获的TypeError:jqOAuth不是一个函数 - Require.js Uncaught TypeError: jqOAuth is not a function 未捕获的类型错误:无法读取 __webpack_require__ 处未定义的属性“调用” - Uncaught TypeError: Cannot read property 'call' of undefined at __webpack_require__ 未捕获的TypeError:e不是小书签的JS函数上的函数 - Uncaught TypeError: e is not a function on a JS function for a bookmarklet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM