[英]Uncaught TypeError: Cannot read properties of undefined (reading 'call') when upgrade to webpack 3
I am developing a google chrome extension, today I tried to upgrade the webpack to verison 3(the legacy was webpack 1.x).我正在开发一个谷歌浏览器扩展,今天我尝试将 webpack 升级到版本 3(旧版是 webpack 1.x)。 Now I am almost complete and the compile works fine, but when I open the google chrome extension popup page, it could not show the UI element.现在我几乎完成并且编译工作正常,但是当我打开谷歌浏览器扩展弹出页面时,它无法显示 UI 元素。 Then I open the popup debbbugger console and shows error log:然后我打开弹出 debbbugger 控制台并显示错误日志:
Uncaught TypeError: Cannot read properties of undefined (reading 'call')
at __webpack_require__ (bootstrap 9e5832947e0eb0ffd7bf:54:1)
at Object.500 (popup.js:115:1)
at __webpack_require__ (bootstrap 9e5832947e0eb0ffd7bf:54:1)
at webpackJsonpCallback (bootstrap 9e5832947e0eb0ffd7bf:25:1)
at webpackJsonpCallback (bootstrap 9e5832947e0eb0ffd7bf:19:1)
at webpackJsonpCallback (commons1.js:20:36)
at popup.js:1:1
I check the bootstrap "bootstrap-sass": "^3.4.1",
version and it was the newest version which last update was 3 years ago.我检查了引导程序"bootstrap-sass": "^3.4.1",
版本,它是最近一次更新是 3 年前的最新版本。 why would this happen?为什么会这样? what should I do to fix this problem?我应该怎么做才能解决这个问题? this is my project package.json
:这是我的项目package.json
:
{
"private": true,
"scripts": {
"xpostinstall": "node ./build/install-pdf-viewer",
"dev": "webpack --config build/webpack.dev.config.js",
"build": "gulp --cwd . --gulpfile build/gulp-build.js",
"test": "karma start build/karma.config.js"
},
"dependencies": {
"bootstrap-sass": "^3.4.1",
"chrome-call": "^1.0.2",
"connect.io": "^3.1.3",
"interact.js": "^1.2.6",
"translation.js": "github:jiangxiaoqiang/translation.js",
"vue": "^1.0.24",
"vue-router": "^0.7.11"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-3": "^6.5.0",
"chrome-env": "^0.0.6",
"css-loader": "^0.23.1",
"del": "^2.2.0",
"download": "^5.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.8.5",
"fs-extra": "^8.1.0",
"gulp": "^3.9.1",
"gulp-clean-css": "^2.3.2",
"gulp-htmlmin": "^2.0.0",
"gulp-jsonmin": "^1.2.0",
"gulp-uglify": "^1.5.3",
"gulp-zip": "^3.2.0",
"isparta-loader": "^2.0.0",
"jasmine-core": "^2.99.1",
"karma": "^6.3.11",
"karma-chrome-launcher": "^1.0.1",
"karma-coverage": "^2.1.0",
"karma-coveralls": "^2.1.0",
"karma-firefox-launcher": "^1.3.0",
"karma-ie-launcher": "^1.0.0",
"karma-jasmine": "^1.1.2",
"karma-phantomjs-launcher": "^1.0.0",
"karma-safari-launcher": "^1.0.0",
"karma-sourcemap-loader": "^0.3.8",
"karma-webpack": "^1.7.0",
"phantomjs-prebuilt": "^2.1.6",
"raw-loader": "^0.5.1",
"sass-loader": "^7.3.1",
"sass": "^1.22.10",
"style-loader": "^0.13.0",
"vue-html-loader": "^1.2.0",
"webpack": "^3.12.0",
"webpack-cli": "^4.9.1"
},
"license": "GPLv3",
}
and this is my webpack config:这是我的 webpack 配置:
const path = require('path');
const webpack = require( 'webpack' ) ,
CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin ,
ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
module.exports = {
entry : {
bg : './src/background-scripts/' ,
content : ['./src/content-scripts/firefox-fix.js', './src/content-scripts/'] ,
options : './src/options/' ,
popup : './src/popup/' ,
'bs-lite' : './src/public/bootstrap-lite.scss'
} ,
output : {
path : path.resolve(__dirname, '../src/bundle') ,
filename : '[name].js'
} ,
module : {
rules : [
{
test : /\.js$/ ,
exclude : [ /node_modules(?!(\/|\\?\\)(translation\.js|selection-widget|connect\.io|chrome-env)\1)/ ] ,
loader : 'babel-loader'
} ,
{
test : /\.woff$/ ,
loader : 'file-loader' ,
query : {
name : '[name].[ext]'
}
} ,
{
test : /\.html$/ ,
loader : 'vue-html-loader'
} ,
{
test : /\.(css|scss)$/ ,
use: ExtractTextPlugin.extract({
fallback :'style-loader',
use: [
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass')
}
}]
})
}
]
} ,
plugins : [
new CommonsChunkPlugin( {
name : 'commons1',
filename : 'commons1.js' ,
allChunks: true,
chunks : [ 'content' , 'popup' ]
}) ,
new CommonsChunkPlugin({
name: 'commons2',
filename :'commons2.js' ,
allChunks: true,
chunks : [ 'commons1.js' , 'options' ]
}) ,
new CommonsChunkPlugin({
name: 'commons3',
filename :'commons3.js' ,
allChunks: true,
chunks : [ 'bg' , 'commons2.js' ]
}) ,
new ExtractTextPlugin( '[name].css' )
]
};
I have no idea about how to fix this problem, anyone facing the same problem?我不知道如何解决这个问题,有人遇到同样的问题吗? I have tried to add allChunks: true
in the CommonsChunkPlugin but did not works.我试图在 CommonsChunkPlugin 中添加allChunks: true
但没有用。 I also tried to move the popup chunk in front of others to control the order like this:我还尝试将弹出块移动到其他人的前面来控制这样的顺序:
new CommonsChunkPlugin( {
name : 'commons1',
filename : 'commons1.js' ,
allChunks: true,
chunks : [ 'popup','content' ],
chunksSortMode: 'manual',
}) ,
still did not work.仍然没有工作。 Any one facing the same problem?有人面临同样的问题吗?
The problem is quite simple.问题很简单。 Probably you are using multiple apps builded via weback on same page.可能您在同一页面上使用通过 weback 构建的多个应用程序。 Solution: Change output.jsonpFunction解决方法: 更改output.jsonpFunction
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.