Regression in babel transpilation
See original GitHub issueSame as #11045, which was closed as fixed. I re-tested under beta.36
, same issue is present.
Describe the bug
The following transpiled fine in 5.x:
export class ClassWithTranspilationIssues {
constructor(private configuration: any = { foo: 'bar' }) { }
printConfigParameter(): void {
console.log(this.configuration.foo);
}
}
It no longer transpiles correctly with Storybook 6:
new ClassWithTranspilationIssues().printConfigParameter() // => Unexpected error: TypeError: Cannot read property 'foo' of undefined
To reproduce:
- clone the minimal repro https://github.com/bard/storybook-6-babel-regression
- run
yarn && yarn storybook
- storybook opens
- notice the absence of the
Button
story - open the web developer console to see the error message
Expected behavior
Constructor parameters with default values should be transpiled correctly.
System:
System:
OS: Linux 5.7 Arch Linux
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Binaries:
Node: 14.4.0 - /tmp/yarn--1593089574779-0.009958780001808165/node
Yarn: 1.22.4 - /tmp/yarn--1593089574779-0.009958780001808165/yarn
npm: 6.14.5 - /usr/sbin/npm
Browsers:
Firefox: 77.0.1
npmPackages:
@storybook/addon-actions: ^6.0.0-beta.36 => 6.0.0-beta.36
@storybook/addon-links: ^6.0.0-beta.36 => 6.0.0-beta.36
@storybook/addons: ^6.0.0-beta.36 => 6.0.0-beta.36
@storybook/cli: ^6.0.0-beta.36 => 6.0.0-beta.36
@storybook/preset-create-react-app: ^3.0.0 => 3.0.0
@storybook/react: ^6.0.0-beta.36 => 6.0.0-beta.36
Additional context
The issue is related to the order in which babel plugins run. I fixed this locally in storybook/lib/core/src/server/common/babel.js
:
The clue was in https://github.com/babel/babel/pull/8682#issuecomment-420408858
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
Babel Roadmap
This will give us a few things: Better confidence in Babel's output. More tests/coverage is better for catching regressions and finding spec bugs...
Read more >Should a thrown error in babel-transpiled code show the ...
Yes, this is expected behavior. Stacktrace behavior isn't part of the ES6 spec, it's more of a defacto standard that has been settled...
Read more >CoffeeScript
-t, --transpile, Pipe the CoffeeScript compiler's output through Babel ... Bugfix for regression in 2.2.0 involving an error thrown by the compiler in ......
Read more >babel-preset-edge - npm Package Health Analysis | Snyk
The preset does not offer the translation of generators nor transpilation of async/await to these. This has always been a half-baked solution with...
Read more >babel-loader | Yarn - Package Manager
v6.2.7. Regression ... Fixes an issue with v6.2.6 when using babel-loader as a global package. v6.2.6. Bug Fix ... Use the common cache...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hacked around this in the code base I’m working. Here’s the summary in case someone finds this through a search.
@storybook/preset-create-react-app
, you shouldn’t need to worry about anything, because project and Storybook will be using compatible webpack configurations.--isolatedModules
..storybook/main.js
fixed things in my case. It discards Storybook’s default rules, except for MDX ones, and replaces them with local rules.Hey there, it’s me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!