Hi,
I am using webpack 4 | babel-loader 8.x | babel 7.x and I can't do import ReactMapGL from 'react-map-gl'. (webpack 4 | babel-loader 7.x | babel 7.x works just fine)
It gave the error below:

Has anyone met the same error?
// My webpack config
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
module.exports = {
mode: 'development',
entry: {
app: [
'webpack-hot-middleware/client',
'./src/index.js',
]
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
devtool: 'inline-source-map',
plugins: [
new HtmlWebpackPlugin({
template: 'template/index.html',
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /\/node_modules$/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react',
'@babel/preset-stage-2'
]
}
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
'file-loader'
]
}
]
}
};
Thanks,
@ibgreen
babel-loader 8 is still in beta. Not all existing webpack loaders are compatible with it. Suggest you comment out your loaders one by one to see which one is breaking.
Also, I opened a PR that upgrades react-map-gl main example to babel-loader 8, so hopefully that can be a working baseline.
npm i babel-loader@7 -D
my solution was this


my solution was this
Where do I put the rules? I am new to web dev.
Most helpful comment
npm i babel-loader@7 -D