React-map-gl: Built failed with babel-loader 8.x | babel 7.x?

Created on 7 Mar 2018  路  5Comments  路  Source: visgl/react-map-gl

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:
screen shot 2018-03-07 at 5 25 53 am

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,

Most helpful comment

npm i babel-loader@7 -D

All 5 comments

@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

image

image

my solution was this

image

image

Where do I put the rules? I am new to web dev.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jwarning picture jwarning  路  17Comments

lopno picture lopno  路  11Comments

schlesingermatthias picture schlesingermatthias  路  14Comments

ibgreen picture ibgreen  路  27Comments

sachinshettigar picture sachinshettigar  路  13Comments