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

@babel/core v7.13.0 bugs causing builds to fail on new installs #977

Closed
marklawlor opened this issue Feb 23, 2021 · 10 comments
Closed

@babel/core v7.13.0 bugs causing builds to fail on new installs #977

marklawlor opened this issue Feb 23, 2021 · 10 comments
Labels
scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue

Comments

@marklawlor
Copy link

Current Behavior

npx tsdx create my-project

Choose react with storybook

Errors during the build phase with

(babel plugin) TypeError: Cannot read property 'resolved' of undefined
TypeError: Cannot read property 'resolved' of undefined
    at /home/user/my-project/node_modules/tsdx/dist/babelPluginTsdx.js:19:94
    at Array.findIndex (<anonymous>)
    at /home/user/my-project/node_modules/tsdx/dist/babelPluginTsdx.js:19:54
    at Array.forEach (<anonymous>)
    at /home/user/my-project/node_modules/tsdx/dist/babelPluginTsdx.js:18:27
    at Array.forEach (<anonymous>)
    at Object.exports.mergeConfigItems (/home/user/my-project/node_modules/tsdx/dist/babelPluginTsdx.js:17:24)
    at Object.config (/home/user/my-project/node_modules/tsdx/dist/babelPluginTsdx.js:109:40)
    at transformCode (/home/user/my-project/node_modules/@rollup/plugin-babel/dist/index.js:239:86)
    at async Promise.all (index 0)

It appears the latest version of @babel/core broke the config merging.

Expected behavior

TSDX can create new projects

Suggested solution(s)

Current workaround is to lock package.json to "@babel/core": "7.12.17" via resolutions

"resolutions": {
  "**/@babel/core": "7.12.17"
}

Additional context

Your environment

System:
    OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 5.76 GB / 15.37 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 12.19.0 - ~/.nvm/versions/node/v12.19.0/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.19.0/bin/npm
  Browsers:
    Chrome: 88.0.4324.182
    Firefox: 85.0.1

@marklawlor
Copy link
Author

marklawlor commented Feb 23, 2021

This seems to fix the build, but the Storybook is failing with

Uncaught TypeError: _interopRequireDefault is not a function
    at Object../node_modules/react-syntax-highlighter/dist/cjs/languages/prism/jsx.js (vendors~main.96bbda1226654fa44563.bundle.js:141158)
    at __webpack_require__ (runtime~main.96bbda1226654fa44563.bundle.js:849)
    at fn (runtime~main.96bbda1226654fa44563.bundle.js:151)
    at Object../node_modules/@storybook/components/dist/syntaxhighlighter/syntaxhighlighter.js (vendors~main.96bbda1226654fa44563.bundle.js:29490)
    at __webpack_require__ (runtime~main.96bbda1226654fa44563.bundle.js:849)
    at fn (runtime~main.96bbda1226654fa44563.bundle.js:151)
    at Object../node_modules/@storybook/components/dist/index.js (vendors~main.96bbda1226654fa44563.bundle.js:29046)
    at __webpack_require__ (runtime~main.96bbda1226654fa44563.bundle.js:849)
    at fn (runtime~main.96bbda1226654fa44563.bundle.js:151)
    at Object../node_modules/@storybook/addon-essentials/node_modules/@storybook/addon-docs/dist/blocks/index.js (vendors~main.96bbda1226654fa44563.bundle.js:10641)
    ```

@agilgur5 agilgur5 changed the title Failing on clean install @babel/core v7.13.0 bugs causing builds to fail on new installs Feb 23, 2021
@agilgur5 agilgur5 added scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue labels Feb 23, 2021
@marklawlor
Copy link
Author

marklawlor commented Feb 23, 2021

Related babel issues

Config merging (looks like tsdx uses the logic as Gatsby): babel/babel#12851
_interopRequireDefault is not a function: babel/babel#12854

@hzoo
Copy link

hzoo commented Feb 23, 2021

@marklawlor yep looks like the same issue with createConfigItem, so should be fixed soon https://github.com/formium/tsdx/blob/462af2d002987f985695b98400e0344b8f2754b7/src/babelPluginTsdx.ts#L1

@agilgur5
Copy link
Collaborator

agilgur5 commented Feb 23, 2021

It appears the latest version of @babel/core broke the config merging.

Yes, @babel/core v7.13.0 was released just two hours ago and seems to have several bugs. babel/babel#12851 is this error and babel/babel#12852 recently fixed it an hour ago.

It is an upstream bug in Babel that many packages are hitting; it's not something TSDX can control. It's also incredibly recent and likely to be fixed by tomorrow if not within the next few hours.

Current workaround is to lock package.json to "@babel/core": "7.12.17" via resolutions

You can also set your yarn.lock or package-lock.json. TSDX does not pin a newer version.

but the Storybook is failing with

That is also a bug in Babel, babel/babel#12854, filed an hour ago, that was closed 5 minutes ago in babel/babel#12855.

TSDX does not even depend on Storybook, it's just included in one of the templates, so a bug in Storybook is also not something TSDX can control. But neither can Storybook as that's a bug in Babel.

Would recommend focusing time upstream, but thanks for providing a workaround @marklawlor that should suffice for anyone installing within the next day or so until this is fixed upstream.
(Yes, TSDX could hard pin to resolve this, but as I've previously stated, having all downstream packages churn multiple releases is not a good solution to an upstream issue -- contributing upstream is)

@hzoo
Copy link

hzoo commented Feb 23, 2021

It's also incredibly recent and likely to be fixed by tomorrow if not within the next few hours.

@agilgur5, yep publishing a new version now! https://github.com/babel/babel/runs/1957418439

@hzoo
Copy link

hzoo commented Feb 23, 2021

Ah it published when I posted, it should be fixed if you try again https://github.com/babel/babel/releases/tag/v7.13.1

@agilgur5
Copy link
Collaborator

Thanks @hzoo, y'all rock!

@agilgur5
Copy link
Collaborator

@marklawlor if you could confirm the fix and close out, that'd be great. I think the added tests in the Babel PRs cover our use-cases, but might find something else -- please report upstream to help the Babel team if so.

@derrickmehaffy
Copy link

Hi from another node project Strapi o/

We tested v7.13.1 and it did not fix it for us, we issued a workaround for our community here: strapi/strapi#9482 (comment)

@marklawlor
Copy link
Author

@agilgur5 v7.13.1 works for a clean install.

@derrickmehaffy cheers that fixed the last issue with my project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: upstream Issue in upstream dependency solution: workaround available There is a workaround available for this issue
Projects
None yet
Development

No branches or pull requests

4 participants