Миграция из Webpack 3 в Webpack 4 - babel-loader ReferenceError: Неизвестный плагин "syntax-dynamic-import" - PullRequest
0 голосов
/ 17 января 2019

Я в процессе перехода с Webpack 3 на Webpack 4.

После обновления всех модулей через npm кажется, что 'syntax-dynamic-import' больше не распознается как плагин для babel-loader.

Вот ошибка, которую я получаю:

ERROR in ./client.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
ReferenceError: Unknown plugin "syntax-dynamic-import" specified in "base" at 0, attempted to resolve relative to "C:\\Users\\myPath js update webpack attempt"
    at C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\file\options\option-manager.js:180:17
    at Array.map (<anonymous>)
    at Function.normalisePlugins (C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\file\options\option-manager.js:158:20)
    at OptionManager.mergeOptions (C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\file\options\option-manager.js:234:36)
    at OptionManager.init (C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (C:\Users\myPath js update webpack attempt\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (C:\Users\myPath js update webpack attempt\node_modules\babel-loader\lib\index.js:50:20)
    at Object.module.exports (C:\Users\myPath js update webpack attempt\node_modules\babel-loader\lib\index.js:173:20)

webpack.base.js (часть моей конфигурации Webpack, которую я объединяю с конфигурациями клиента и сервера):

const ExtractCssChunks = require('extract-css-chunks-webpack-plugin')

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            babelrc: false,
            presets: [
              ['es2015', { modules: false }],
              'react',
            ],
            plugins: [
              'syntax-dynamic-import',
              'transform-class-properties',
              'transform-object-assign',
              'react-loadable/babel'
            ],
          }
        },
      },
      {
       use: [
        ExtractCssChunks.loader,
        'css-loader',
        'sass-loader'
        ],
       test: /\.scss$/,
       exclude: /node_modules/,
     },
    ],
  },
  plugins: [
    new ExtractCssChunks
  ]
}
...