Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Plugin misconfigured or just invalid usage example in the docs #16395

Closed
1 task done
SharakPL opened this issue Mar 29, 2024 · 3 comments · Fixed by babel/website#2884
Closed
1 task done

[Bug]: Plugin misconfigured or just invalid usage example in the docs #16395

SharakPL opened this issue Mar 29, 2024 · 3 comments · Fixed by babel/website#2884
Labels

Comments

@SharakPL
Copy link

SharakPL commented Mar 29, 2024

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

Anything, may as well be an empty file. It's just about misconfiguration that prevents webpack to use plugin properly.

Configuration file name

babel.config.js

Configuration

babel.config.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage',
        corejs: 3.36,
      },
    ],
  ],
  plugins: [
    '@babel/plugin-proposal-optional-chaining-assign',
    {
      version: '2023-07',
    },
  ],
};

Current and expected behavior

The docs show the usage like this:

"plugins": [
  "@babel/plugin-proposal-optional-chaining-assign",
  {
    "version": "2023-07"
  }
]

But it never works and throws an error in webpack:

ERROR in ./js/theme.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] C:\wamp64\www\myapp_dev\js\theme.js: @babel/plugin-syntax-optional-chaining-assign: '.version' option required, representing the last proposal update. Currently, the only supported value is '2023-07'. (While processing: "C:\wamp64\www\myapp\_dev\node_modules\@babel\plugin-proposal-optional-chaining-assign\lib\index.js$inherits")

The correct way that works is this:

"plugins": [
  [
    "@babel/plugin-proposal-optional-chaining-assign",
    {
      "version": "2023-07"
    }
  ]
]

I don't know if any other plugin has this mistake in the docs. Checked a few and they look correctly eg. pipeline

Environment

  • babel 7.24.1
  • node 18.18,2
  • webpack 5.90.3
  • babel-loader 9.1.3

Possible solution

Either change version parameter resolution in the plugin or the plugins[] usage example.

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @SharakPL! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@nicolo-ribaudo
Copy link
Member

The docs are missing a set of [] — would you mind opening a PR in the babel/website repo?

@SharakPL
Copy link
Author

Sure. I'm on it 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants