You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chrome扩展加载background.js时出现__webpack_require__.e is not a function错误

Chrome扩展加载错误:Uncaught TypeError: __webpack_require__.e is not a function

加载background.js脚本时触发上述错误,错误具体触发位置在Webpack运行时代码中:

/******/    /* webpack/runtime/eagerly load chunks */
/******/    (() => {
/******/        __webpack_require__.e(352) // 错误触发此行
/******/    })();

已知相关解决方案,但不清楚如何应用,存在以下疑问:

  • 是否需要为所有依赖创建缓存组?
  • 如何确定引用编号352对应的模块?

源码信息

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

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

运行命令

npm install
npm run build

内容的提问来源于stack exchange,提问作者h3xStream

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 16:09:45