웹 페이지 패키지 오류 플러그인/Preset files are not allowed to export objects, only functions

2763 단어
패키지 오류 플러그인/Preset files are not allowed to export objects, only functions
ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/xxx/node_modules/babel-preset-es2015/lib/index.js

내 거.babelrc 파일은
{
  "presets": ["es2015"],
  "plugins": [
    [ "transform-runtime", {
      "helpers": false,
      "polyfill": false
      }
    ]
  ]
}

webpack.config.js 설정은
'use strict'

const path = require('path')
const webpack = require('webpack')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

const resolve = dir => path.join(__dirname, '.', dir)
const isProd = process.env.NODE_ENV === 'production'
module.exports = {
  entry: {
    index: './src/index.js'
  },
  output: {
    path: isProd?resolve('dist'): resolve(''), //  
    filename: isProd?'[name].min.js':'[name].js', //  
    libraryTarget: 'umd', //  
    library: 'lagou-bridge-sdk', //  
    libraryExport: 'default', //   ES6(ES2015)  、CommonJS   AMD  
    globalObject: 'this' //  node , window is not undefined 
  },
  devtool: '#source-map',
  devServer: {
    hot: true,
    // ...
  },
  module: {
    rules: [
      {
        test: /\.(js)$/,
        loader: 'eslint-loader',
        enforce: 'pre',
        include: [resolve('src'), resolve('test')],
        options: {
          formatter: require('eslint-friendly-formatter')
        }
      },
      {
        test: /\.js?$/,
        exclude: /(node_modules|dist)/,
        loader: 'babel-loader',
        
      }
    ]
  },
  plugins: isProd
    ? [
      new UglifyJsPlugin({
        parallel: true,
        uglifyOptions: {
          warnings: false,
          mangle: true
        },
        sourceMap: true
      }),
    ]
    : [
      new webpack.NamedModulesPlugin(),
      new webpack.NoEmitOnErrorsPlugin()
    ]
}

내 거.babelrc 파일 수정 삭제es2015
{
  "presets": ["@babel/preset-env"],
  "plugins": [
    [ "transform-runtime", {
      "helpers": false,
      "polyfill": false
      }
    ]
  ]
}

잘못 보고하다
ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /Users/xxx/src/index.js: this.setDynamic is not a function

babelrc 파일 수정plugins를 제거하고 컴파일로 수정 성공
  "presets": ["@babel/preset-env"],

좋은 웹페이지 즐겨찾기