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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-loader parse-helpers.js 6.4.9 regression (vs. 6.4.0) #16984

Closed
mgcrea opened this issue Dec 10, 2021 · 4 comments
Closed

source-loader parse-helpers.js 6.4.9 regression (vs. 6.4.0) #16984

mgcrea opened this issue Dec 10, 2021 · 4 comments
Assignees

Comments

@mgcrea
Copy link
Contributor

mgcrea commented Dec 10, 2021

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch @storybook/source-loader@6.4.9 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@storybook/source-loader/dist/cjs/abstract-syntax-tree/parse-helpers.js b/node_modules/@storybook/source-loader/dist/cjs/abstract-syntax-tree/parse-helpers.js
index 1a9a63b..5040657 100644
--- a/node_modules/@storybook/source-loader/dist/cjs/abstract-syntax-tree/parse-helpers.js
+++ b/node_modules/@storybook/source-loader/dist/cjs/abstract-syntax-tree/parse-helpers.js
@@ -83,7 +83,7 @@ function findTemplate(templateName, program) {
 
     if (node.type === 'VariableDeclaration') {
       declarations = node.declarations;
-    } else if (node.type === 'ExportNamedDeclaration' && node.declaration.type === 'VariableDeclaration') {
+    } else if (node.type === 'ExportNamedDeclaration' && node.declaration?.type === 'VariableDeclaration') {
       declarations = node.declaration.declarations;
     }
 

This issue body was partially generated by patch-package.

Not sure why but bumping from 6.4.0 to 6.4.9 leads to some node element (inside program.body) that have a node.declaration set to null:

{
  node: {
    type: 'ExportNamedDeclaration',
    source: null,
    specifiers: [
      {
        type: 'ExportSpecifier',
        local: {
          type: 'Identifier',
          name: 'Button',
          range: [ 266, 272 ],
          loc: {
            start: { line: 5, column: 8 },
            end: { line: 5, column: 14 }
          },
          start: 266,
          end: 272
        },
        exported: {
          type: 'Identifier',
          name: 'Button',
          range: [ 266, 272 ],
          loc: {
            start: { line: 5, column: 8 },
            end: { line: 5, column: 14 }
          },
          start: 266,
          end: 272
        },
        exportKind: 'value',
        range: [ 266, 272 ],
        loc: { start: { line: 5, column: 8 }, end: { line: 5, column: 14 } },
        start: 266,
        end: 272
      }
    ],
    exportKind: 'value',
    declaration: null,
    assertions: [],
    range: [ 258, 274 ],
    loc: { start: { line: 5, column: 0 }, end: { line: 5, column: 16 } },
    start: 258,
    end: 274
  }
}

And breaks storybook.

@shilman
Copy link
Member

shilman commented Dec 11, 2021

@mgcrea Do you mind creating a PR with the change? I think we can merge this as is. Thanks!

@mgcrea
Copy link
Contributor Author

mgcrea commented Dec 16, 2021

@shilman done :) #17027

@shilman
Copy link
Member

shilman commented Dec 18, 2021

Shiver me timbers!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.4 containing PR #17027 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

@shilman
Copy link
Member

shilman commented Jan 10, 2022

Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.10 containing PR #17027 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants