Babel-loader: Problem using babel-loader and loading babel plugin proposals

Created on 23 May 2019  路  2Comments  路  Source: babel/babel-loader

I'm submitting a bug report
I'm trying to add different babel plugins to my webpack config. They are what used to be the stage-0 plugins. When doing so, I get the following error and can't seem to find what it means by .name as I cannot find it in the webpack config file.

I've checked the link it mentions, but haven't had any luck. When commenting out require('@babel/plugin-proposal-class-properties') it works.

There is no .babelrc file.

ERROR in ./index.js
Module build failed (from /Users/alexvernacchia/tools/create-tool/node_modules/babel-loader/lib/index.js):
ReferenceError: [BABEL] /Users/alexvernacchia/tools/test-project/index.js: Unknown option: .name. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.
  at throwUnknownError (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/validation/options.js:123:11)
at /Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/validation/options.js:107:5
at Array.forEach (<anonymous>)
  at validateNested (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/validation/options.js:83:21)
  at validate (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/validation/options.js:74:10)
  at /Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/full.js:244:36
  at cachedFunction (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/caching.js:33:19)
  at loadPresetDescriptor (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/full.js:235:45)
  at /Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/full.js:77:21
  at Array.reduce (<anonymous>)
    at recurseDescriptors (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/full.js:74:38)
    at loadFullConfig (/Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/config/full.js:108:6)
    at /Users/alexvernacchia/tools/create-tool/node_modules/@babel/core/lib/transform.js:28:33
    at processTicksAndRejections (internal/process/task_queues.js:82:9)
    @ multi webpack-hot-middleware/client ./index.js main[1]

I've posted the rule for the babel-loader below.

{
  test: /\.js$/,
  exclude: /node_modules/,
  loader: 'babel-loader',
  options: {
    presets: [
      [
        require('@babel/preset-env'),
        {
          targets: {
            browsers: ['last 2 versions'],
          },
          modules: false,
        },
      ],
      /* this used to be @babel/preset-stage-0 */
      require('@babel/plugin-proposal-class-properties'),
      // require('@babel/plugin-proposal-decorators'),
      // require('@babel/plugin-proposal-do-expressions'),
      // require('@babel/plugin-proposal-export-default-from'),
      // require('@babel/plugin-proposal-export-namespace-from'),
      // require('@babel/plugin-proposal-function-bind'),
      // require('@babel/plugin-proposal-function-sent'),
      // require('@babel/plugin-proposal-json-strings'),
      // require('@babel/plugin-proposal-logical-assignment-operators'),
      // require('@babel/plugin-proposal-nullish-coalescing-operator'),
      // require('@babel/plugin-proposal-numeric-separator'),
      // require('@babel/plugin-proposal-optional-chaining'),
      // require('@babel/plugin-proposal-pipeline-operator'),
      // require('@babel/plugin-proposal-throw-expressions'),
      // require('@babel/plugin-syntax-dynamic-import'),
      // require('@babel/plugin-syntax-import-meta'),
      /* end @babel/preset-stage-0 */
      require('@babel/preset-react'),
    ],
    plugins: [
      require('@babel/plugin-transform-react-display-name'),

      ...(isProduction ? [] : [require('react-hot-loader/babel')]),
    ],
  },
},

Webpack Version:
4.32.2

Babel Core Version:
"@babel/core": "^7.4.5",

Babel Loader Version:
"babel-loader": "^8.0.6",

Please tell us about your environment:
OSX 10.14

Current behavior:
Errors

Expected/desired behavior:
Not to error

all babel deps

    "@babel/core": "^7.4.5",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.0.0",
    "@babel/plugin-proposal-do-expressions": "^7.0.0",
    "@babel/plugin-proposal-export-default-from": "^7.0.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
    "@babel/plugin-proposal-function-bind": "^7.0.0",
    "@babel/plugin-proposal-function-sent": "^7.0.0",
    "@babel/plugin-proposal-json-strings": "^7.0.0",
    "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
    "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
    "@babel/plugin-proposal-numeric-separator": "^7.0.0",
    "@babel/plugin-proposal-optional-chaining": "^7.0.0",
    "@babel/plugin-proposal-pipeline-operator": "^7.0.0",
    "@babel/plugin-proposal-throw-expressions": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-syntax-import-meta": "^7.0.0",
    "@babel/plugin-transform-react-display-name": "^7.2.0",
    "@babel/polyfill": "7.4.4",
    "@babel/preset-env": "7.4.5",
    "@babel/preset-react": "7.0.0",
    "@deliveroo/express-identity": "0.0.2",
    "babel-jest": "^24.8.0",
    "babel-loader": "^8.0.6",
    "babel-minify-webpack-plugin": "0.3.1",
    "babel-plugin-module-resolver": "^3.0.0",

Most helpful comment

And turns out i was putting the plugins in the preset area. Solved!

All 2 comments

Didn't actually solve it...

And turns out i was putting the plugins in the preset area. Solved!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eoinmurray picture eoinmurray  路  20Comments

MatTheCat picture MatTheCat  路  20Comments

suzuki-shunsuke picture suzuki-shunsuke  路  23Comments

ritz078 picture ritz078  路  29Comments

pkosenko picture pkosenko  路  24Comments