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]: Must import specific lodash methods individually #23191

Open
markwoon opened this issue Jun 23, 2023 · 1 comment
Open

[Bug]: Must import specific lodash methods individually #23191

markwoon opened this issue Jun 23, 2023 · 1 comment

Comments

@markwoon
Copy link

markwoon commented Jun 23, 2023

Describe the bug

I tried upgrading from Storybook 6 to 7.0.23. I'm using webpack + babel (react-webpack5 framework).

When I try running storybook, I get the following error:

TypeError: Property source of ImportDeclaration expected node to be of a type ["StringLiteral"] but instead got "StringLiteral"

For a while I thought it may be related to #17398 due to this comment referencing the error above, but after a lot of debugging I've discovered that it's because I'm importing lodash using curly braces.

Instead of:

import {forEach, isUndefined} from 'lodash';

I have to do:

import forEach from 'lodash/forEach';
import isUndefined from 'lodash/isUndefined';

This only applies to Storybook-specific code (i.e. *.stories.js) and not my existing code.

Is there a reason for this behavior? Or is there some config I should be using to get this to work the way I expect?

To Reproduce

No response

System

Running npx storybook@latest info produces:

Error: Command failed: wmic os get Caption
'wmic' is not recognized as an internal or external command,
operable program or batch file.

I'm using node 18.16.1, yarn 3.5.0, npm 9.7.2. Running on Windows 11.

From package.json:

    "@storybook/addon-a11y": "7.0.23",
    "@storybook/addon-actions": "7.0.23",
    "@storybook/addon-essentials": "7.0.23",
    "@storybook/addon-interactions": "7.0.23",
    "@storybook/addon-storysource": "7.0.23",
    "@storybook/jest": "0.1.0",
    "@storybook/react": "7.0.23",
    "@storybook/react-webpack5": "7.0.23",
    "@storybook/testing-library": "0.2.0",

Additional context

No response

@markwoon
Copy link
Author

Correction: I need to import individual lodash methos from any code that Storybook has to compile.

I'm not sure why it starts just fine, but if I make any changes that triggers a recompile in Storybook, it'll throw the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

1 participant