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

[Bug]: Babel warning when using a function for base configuration for angular #20940

Closed
Tallyb opened this issue Feb 5, 2023 · 4 comments · Fixed by #20952
Closed

[Bug]: Babel warning when using a function for base configuration for angular #20940

Tallyb opened this issue Feb 5, 2023 · 4 comments · Fixed by #20952
Assignees

Comments

@Tallyb
Copy link

Tallyb commented Feb 5, 2023

Describe the bug

Unexpected {"type":"ExportDefaultDeclaration", ...long warning

This happens when you have a file (ts or mjs) that exports a function that is later used as base configuration.

import { baseConfig } from "./base-main";

const config = baseConfig();
export default config;

To Reproduce

https://github.com/Tallyb/taskbox

run `npx ng run taskbox:storybook`

System

System:
    OS: macOS 13.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Firefox: 104.0.2
    Safari: 16.2
  npmPackages:
    @storybook/addon-actions: 7.0.0-beta.43 => 7.0.0-beta.43
    @storybook/addon-essentials: 7.0.0-beta.43 => 7.0.0-beta.43
    @storybook/addon-interactions: 7.0.0-beta.43 => 7.0.0-beta.43
    @storybook/addon-links: 7.0.0-beta.43 => 7.0.0-beta.43
    @storybook/angular: 7.0.0-beta.43 => 7.0.0-beta.43
    @storybook/jest: ^0.0.11-next.0 => 0.0.11-next.0
    @storybook/testing-library: ^0.0.13 => 0.0.13

Additional context

No response

@yannbf
Copy link
Member

yannbf commented Feb 5, 2023

Hey @Tallyb thank you so much for reporting this issue! Did this happen when you migrated from Storybook 6?

In Storybook 7 we rely a lot on AST parsing of your Storybook-related files, which has some caveats, such as not being able to evaluate the baseConfig function to know which values your main.js contains. We recommend not having helper functions like that, but rather just the object directly. I believe that would fix your issue.

Still, I'm quite curious which was the previous version you were using that this was working, so please let me know if you can. Thanks!

@Tallyb
Copy link
Author

Tallyb commented Feb 5, 2023

hi @yannbf!
Thank you for your quick response. I bisected the error down to beta 39 (we upgraded to SB 7 a while ago).
My wild guess will be that it is related to this PR: #20802

We are running multiple angular storybooks that have a large common configuration, just with a minor change, hence the function. As it is a warning on ts file, I guess we will live with it. Of course, a fix would be awesome...

@yannbf
Copy link
Member

yannbf commented Feb 6, 2023

Thanks for explaining, it definitely is related to that PR! I'm reverting that change and turning that check into an automigration instead!

Having "unconventional" main.js files like yours is fine, however with the caveat that some of our automigrations won't be able to migrate your code on your behalf, FYI. Regardless, the upcoming alpha will be working fine for your scenario!

@shilman
Copy link
Member

shilman commented Feb 7, 2023

Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.44 containing PR #20952 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb@next upgrade --prerelease

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

Successfully merging a pull request may close this issue.

3 participants