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.4 through 6.2.0-rc.1 fails to display any stories due to prettier ES5 transpilation

See original GitHub issue

Describe the bug When upgrading to any version past beta.3, my storybook fails all stories due to an error in the console:

vendors~main.d7688b207a41d38e761d.bundle.js:110185 TypeError: Cannot convert undefined or null to object
    at getPrototypeOf (<anonymous>)
    at r.parse (vendors~main.d7688b207a41d38e761d.bundle.js:206929)
    at Object.t.parse (vendors~main.d7688b207a41d38e761d.bundle.js:206953)
    at Mn (vendors~main.d7688b207a41d38e761d.bundle.js:206995)
    at Un (vendors~main.d7688b207a41d38e761d.bundle.js:207184)
    at Object.parse (vendors~main.d7688b207a41d38e761d.bundle.js:207230)
    at Object.parse (vendors~main.d7688b207a41d38e761d.bundle.js:207300)
    at ts (vendors~main.d7688b207a41d38e761d.bundle.js:207300)
    at us (vendors~main.d7688b207a41d38e761d.bundle.js:207300)
    at vendors~main.d7688b207a41d38e761d.bundle.js:207330

After alot of digging, it seems this PR https://github.com/storybookjs/storybook/pull/14047 made the change in es6Transpiler, adding prettier to the regex list of packages to transpile to ES5. For some reason the transpiled version is wrong in my repository, but not in the storybook Angular-cli example.

What is generated for the failing function in my repo is:

      _createClass(r, [{
        key: "parse",
        value: function parse(e, t, n) {
          var r = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
          var s = arguments.length > 4 ? arguments[4] : undefined;
          return _get(_getPrototypeOf(r.prototype), "parse", this).call(this, e, t, n, r, s);
        }
      }]);

Whereas in the working storybook-repo:

 _createClass(r, [{
        key: "parse",
        value: function parse(e, t, n) {
          var _r33 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;

          var s = arguments.length > 4 ? arguments[4] : undefined;
          return _get(_getPrototypeOf(r.prototype), "parse", this).call(this, e, t, n, _r33, s);
        }
 }]);

It’s not easy to spot at first, but in the failing example, the var r is causing the problem, rescoping r from being the actual object passed in to _createClass to now simply a boolean.

To Reproduce

I’ve attempted imitate configuration and settings as closely as I can in my project, but to no avail. I did manage to create a repository that reproduces the error: https://github.com/yngvebn/storybook-babel The repository is a stripped down version of the one I work in daily, so it’s as real as it gets.

Steps to reproduce the behavior:

Clone https://github.com/yngvebn/storybook-babel Run npm install Run npm start-storybook

  1. Go to any story in the compiled storybook
  2. Open the console
  3. See the error mentioned earlier

Expected behavior Expect stories to work.

Screenshots All stories ends up looking like this:

image

Code snippets If applicable, add code samples to help explain your problem.

System

Environment Info:

  System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 14.0.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 89.0.4389.90
    Edge: Spartan (44.19041.423.0), Chromium (89.0.774.54)
  npmPackages:
    @storybook/addon-a11y: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-actions: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-docs: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-essentials: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-knobs: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-links: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-storysource: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addon-viewport: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/addons: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/angular: ^6.2.0-rc.1 => 6.2.0-rc.1
    @storybook/cli: ^6.2.0-rc.1 => 6.2.0-rc.1

Additional context If I manually find es6Transpiler.js in node_modules, and remove prettier from the regex, everything works as it should.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
thorn0commented, Apr 1, 2021
1reaction
ndelangencommented, Mar 17, 2021

yes, I know this is a pain, but unfortunately something we can’t make it any easier on you, because we’re constrained by webpack’s api…

I suggest finding the module.rule that has a include that’s a regex that matches prettier then generating a new regex that doesn’t include it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@storybook/addon-links | Yarn - Package Manager
Link stories together to build demos and prototypes with your UI components ... Install this addon by adding the @storybook/addon-links dependency:
Read more >
How to Prevent Webpack Error after npm Install?
Seems like Webpack 3.4.1 is causing you troubles, because you are relying on some old dependencies. Do the following: npm uninstall webpack --save-dev....
Read more >
storybookjs/storybook (Raised $170.00) - Issuehunt
Storybook 6.2.0-beta.4 through 6.2.0-rc.1 fails to display any stories due to prettier ES5 transpilation. Unfunded#14262created byyngvebn.
Read more >
https://raw.githubusercontent.com/storybooks/story...
6.2.0-rc.13 (March 30, 2021) ### Bug Fixes - Controls: QA fixes for Object and ... Maintenance - Build: Exclude all test and story...
Read more >
@storybook/core-common: Versions | Openbase
Svelte: Fix regression causing all stories to error #19653 ... Vite: Export storybook utilities from frameworks for better pnpm support #19216. Bug Fixes....
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