-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Expected behaviour
Using babel-loader and html-webpack-plugin shouldn't require any special configuration.
Current behaviour
Webpack throws the following error with a minimal repro using only webpack, babel-loader and html-webpack-plugin:
TypeError: __webpack_require__(...) is not a function
- index.html:1718 Module../node_modules/webpack/buildin/harmony-module.js
Environment
Node.js v12.1.0
darwin 18.6.0
npm 6.9.0
[email protected] .../webpack-issue
└── [email protected]
[email protected] .../webpack-issue
└── [email protected].
Config
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = function(env) {
return {
mode: 'development',
entry: {
app: './index.js',
},
output: {
path: __dirname + '/dist',
filename: 'index.js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
}),
],
bail: true,
devServer: {
contentBase: 'public',
inline: true,
port: 3000,
}
}
}
Relevant Links
Repository with minimal repro repository
Possibly related:
- babel-loader transform-runtime causes TypeError: __webpack_require__(...) is not a function #637
- ERROR in Template execution failed: ReferenceError: __webpack_require__ is not defined #676
- feat: drop workaround for "Uncaught TypeError: __webpack_require__(….) is not a function" to be compatible with webpack 5 #1102
Workaround
diff --git a/webpack.config.js b/webpack.config.js
index 34e17ce..8bf6b03 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -20,6 +20,9 @@ module.exports = function(env) {
rules: [
{
test: /\.js$/,
+ exclude: [
+ /node_modules\/(webpack|html-webpack-plugin)\//,
+ ],
loader: 'babel-loader',
},
],
Akiyamka
Metadata
Metadata
Assignees
Labels
No labels