babel: [Bug]: Release 7.17.0 breaks downstream plugins

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

import { SomeComponent } from '~/some/aliased/path`;

Configuration file name

No response

Configuration

No response

Current and expected behavior

Not to break downstream plugins

Environment

Possible solution

No response

Additional context

This is the error that started occurring after updating from @babel/core: 7.16.12 to 7.17.0

[eslint-import-resolver-babel-module] TypeError: [BABEL] C:\Redacted\src\components\ui\Nav\AccountMenu\AccountMenu.js: Cannot add property 1, object is not extensible
    at Array.push (<anonymous>)
    at C:\Redacted\node_modules\@babel\core\lib\config\full.js:314:26
    at Generator.next (<anonymous>)
    at Function.<anonymous> (C:\Redacted\node_modules\@babel\core\lib\gensync-utils\async.js:25:3)
    at Generator.next (<anonymous>)
    at evaluateSync (C:\Redacted\node_modules\gensync\index.js:251:28)
    at Function.sync (C:\Redacted\node_modules\gensync\index.js:89:14)
    at sync (C:\Redacted\node_modules\@babel\core\lib\gensync-utils\async.js:68:25)
    at sync (C:\Redacted\node_modules\gensync\index.js:182:19)
    at onFirstPause (C:\Redacted\node_modules\gensync\index.js:210:24)
    at Generator.next (<anonymous>)
    at cachedFunction (C:\Redacted\node_modules\@babel\core\lib\config\caching.js:66:46)
    at cachedFunction.next (<anonymous>)
    at loadPluginDescriptor (C:\Redacted\node_modules\@babel\core\lib\config\full.js:282:17)
    at loadPluginDescriptor.next (<anonymous>)
    at loadPluginDescriptors (C:\Redacted\node_modules\@babel\core\lib\config\full.js:170:33)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

@nicolo-ribaudo thank you for promptly addressing this. I will pin to 7.16 until #14241 gets merged! Have a good weekend!

Thanks @l0gicgate; I was able to trim your repository down even more (first removing webpack, and then some ESLint stuff), and I managed to create a reproduction that only uses Babel (https://github.com/babel/babel/pull/14241).

However, I will not be available much this weekend and next week, so it might take a while before I fix it. In the meantime, please pin @babel/core to the last working version (e.g. ~7.16.0).

@nicolo-ribaudo I stripped everything down as best as I could with minimal dependencies to reproduce the issue. Here’s the repository: https://github.com/l0gicgate/babel-core-issue-14233

Let me know if you need anything else

@nicolo-ribaudo here’s my babel config:

{
  "env": {
    "development": {
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        [
          "@babel/plugin-transform-runtime",
          {
            "absoluteRuntime": false,
            "corejs": false,
            "version": "^7.7.4"
          }
        ],
        [
          "module-resolver",
          {
            "root": ["./src"],
            "alias": {
              "~": "./src"
            }
          }
        ]
      ],
      "presets": [
        "airbnb",
        "@babel/preset-env",
        "@babel/preset-react"
      ]
    },
    "production": {
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        [
          "@babel/plugin-transform-runtime",
          {
            "absoluteRuntime": false,
            "corejs": false,
            "version": "^7.7.4"
          }
        ],
        [
          "module-resolver",
          {
            "root": ["./src"],
            "alias": {
              "~": "./src"
            }
          }
        ],
        ["transform-react-remove-prop-types", {
          "mode": "remove",
          "ignoreFilenames": ["node_modules"],
          "removeImport": true
        }]
      ],
      "presets": [
        "airbnb",
        "@babel/preset-env",
        "@babel/preset-react"
      ]
    },
    "staging": {
      "plugins": [
        "@babel/plugin-proposal-class-properties",
        [
          "@babel/plugin-transform-runtime",
          {
            "absoluteRuntime": false,
            "corejs": false,
            "version": "^7.7.4"
          }
        ],
        [
          "module-resolver",
          {
            "root": ["./src"],
            "alias": {
              "~": "./src"
            }
          }
        ],
        ["transform-react-remove-prop-types", {
          "mode": "remove",
          "ignoreFilenames": ["node_modules"],
          "removeImport": true
        }]
      ],
      "presets": [
        "airbnb",
        "@babel/preset-env",
        "@babel/preset-react"
      ]
    }
  }
}

This is related to the extendedDependencies tracking. When loading a plugin, we usually:

  1. create an externalDependencies array for the plugin
  2. if the plugin inherits from another plugin:
    1. load the inherited plugin
    2. push the externalDependencies of the inherited plugin into the externalDependencies of the plugin we are loading
  3. freeze externalDependencies of the plugin we are loading

However, for some reason externalDependencies of the plugin we are loading is already frozen at step 2.2: I don’t understand why it’s possible, so we need to know which plugin is causing this.