question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook 6.2.0-beta.13 not transforming class properties

See original GitHub issue

I have tried to upgrade to 6.2.0-beta.13 to test the fix for #13608 and I am having babel issues. On start up I’m getting a bunch of Syntax Error: Missing class properties transform errors. However, it looks like @babel/plugin-proposal-class-properties is still included in the default storybook babel plugins so I don’t know why this is appearing all of a sudden. Even if I explicitly add it myself in main.js I get the same error. I saw a couple babel changes in the changelog for 6.2, but nothing specifically related to this. It worked fine in 6.1.3.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade to @storybook/react@6.2.0-beta.13 with npx sb upgrade -p
  2. Use class properties in a component that is referenced in a story:
class MyComponent extends React.Component<MyComponentProps> {
  static Foo = Bar;
  // ...
}
  1. Start storybook

Expected behavior The class properties should be transformed and Storybook should start normally.

Code snippets Adding the following to main.js does not help.

  babel: async options => ({
    ...options,
    plugins: [...options.plugins, '@babel/plugin-proposal-class-properties'],
  }),

If you log options, you can see that the plugin is already provided so this shouldn’t be needed anyway.

┆Issue is synchronized with this Asana task by Unito

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:34 (12 by maintainers)

github_iconTop GitHub Comments

16reactions
imbhargav5commented, Jun 23, 2021

@shilman Issue still persists in 6.3. 😞

10reactions
shilmancommented, Oct 22, 2021

For anybody stumbling on this issue, we still don’t have a root cause. Given all the comments above, it appears that multiple versions of babel and its various packages are not working well together. Given that, clearing those out of the lockfile and reinstalling forces all the babel libs to the same version, which solves the problem.

Things to try (in order of least to most disruptive):

  • try upgrading to the latest storybook npx sb upgrade
  • npx yarn-deduplicate --scopes @babel
  • try updating your .storybook/main.js with the snippet below
  • try removing your lockfile and reinstalling
// main.js
module.exports = {
  babel: async (options) => ({
    ...options,
    plugins: [['@babel/plugin-proposal-class-properties', { loose: true }]],
  }),
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

storybook missing class properties transform. - You.com
I have tried to upgrade to 6.2.0-beta.13 to test the fix for #13608 and I am having babel issues. On start up I'm...
Read more >
Error: Missing class properties transform - Stack Overflow
The fix in my case was defining 'transform-class-properties' plugin in the options attribute of my webpack.config.js, i'm using babel V6
Read more >
Compare Versions | @elliemae/pui-cli | npm
GHSA-hj9c-8jmm-8c52Packing does not respect root-level ignore files in ... @babel/plugin-syntax-class-properties 7.12.13 ... @storybook/client-api 6.2.9.
Read more >
@storybook/react | Yarn - Package Manager
6.2.0-rc.3 (March 18, 2021). NOTE: For Angular users using inline story rendering in addon-docs, this is a breaking prerelease change. See below. ......
Read more >
comicrelief/storybook@1.24.0 vulnerabilities - Snyk
Affected versions of this package are vulnerable to Arbitrary Code Execution. When an object with an executable toString() property used as a map...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found