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

Csf Tools: Fix overriding scalar named export values #21190

Merged
merged 1 commit into from
Feb 21, 2023

Conversation

shilman
Copy link
Member

@shilman shilman commented Feb 21, 2023

Closes #21127

What I did

Update ConfigFile's setFieldNode method to handle setting named exports that are scalars

How to test

  • See attached unit tests
sb automigrate bare-mdx-stories-glob

in a project with:

export const stories = ['./Introduction.stories.mdx', '../src/App.stories.tsx']

Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for a hotfix, we probably need to rethink csf-tools logic if we want to account for many other scenarios. Here's another one, which I don't know if it's really common:

const stories = ['./Introduction.stories.mdx', '../src/App.stories.tsx'];
export { stories };

@shilman
Copy link
Member Author

shilman commented Feb 21, 2023

Note: this PR doesn't handle the following interesting cases raised by @yannbf

This one requires a significant refactor (see my FIXME comment) in the PR:

const stories = ['./Introduction.stories.mdx', '../src/App.stories.tsx'];
export { stories };

This one requires a change in the automigration if we want to support this feature (I vote not):

const autoStories = ['../src/components/atoms/**.stories.*'];
export const stories = ['./Introduction.stories.mdx', '../src/App.stories.tsx', ...autoStories]

Can't wait for the day when everybody is updated to default exports! 🙏

Cc @JReinhold

@shilman shilman merged commit 7e68aa2 into next Feb 21, 2023
@shilman shilman deleted the shilman/csf-tools-fix-configfile-named-export-scalars branch February 21, 2023 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: bare-mdx-stories-glob added duplicate export const stories
2 participants