从Webpack 3迁移到Webpack 4-babel-loader ReferenceError:未知插件“ syntax-dynamic-import”

时间:2019-01-17 10:53:22

标签: javascript webpack migration webpack-4

我正在从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
  ]
}

0 个答案:

没有答案