babel: [Bug]: TypeError: Cannot set properties of undefined (setting 'kind')

💻

  • Would you like to work on a fix?

How are you using Babel?

Other (Next.js, Gatsby, vue-cli, …)

Input code

image

Seeing the error:

Cannot set properties of undefined (setting 'kind')

Seems related to https://github.com/babel/babel/issues/15300 and

Configuration file name

No response

Configuration

No response

Current and expected behavior

After release @babel/plugin-transform-block-scoping v7.20.8 seeing the error above.

Environment

System: OS: macOS 12.6.1 Binaries: Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm

Possible solution

Does https://github.com/babel/babel/pull/15200 need to be reverted until the issues are all fixed?

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 7
  • Comments: 20 (6 by maintainers)

Most upvoted comments

I went back a version for @babel/plugin-transform-block-scoping and my react application is now building successfully again. npm i @babel/plugin-transform-block-scoping@7.20.5

We are also experiencing a similar issue for a react-app with the following versions:

  • node: 8.12.0
  • npm: 6.4.1

The earlier error was TypeError: 'constantViolations' of undefined however now it’s TypeError: Cannot set property 'kind' of undefined. Since our project is working on an old package version so we wanted to be sure whether it’s a deprecation of babel dependency that we are using or something else. Kindly provide an update on this.

I’m also a bit hesitant to ask… but would a roll-back to 7.20.5 be an option? Meaning releasing a new patch with the contents of 7.20.5?

I could provide a environment, in which you can replace some node_modules content and a command to run to reproduce the problem in “isolation”…

Maybe in the second one we could run a crawl if the binding is not present.

A fix would be checking that every call to scope.getOwnBinding in https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-block-scoping/src can return null. I can probably work on a PR in a few hours, tomorrow morning (EU) at latest, but if someone else wants to open the PR it would be much appreciated.