-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
CLI: Add prompt-only automigrate asking for react-removal #25215
Conversation
if (hasMDX) { | ||
const mdxSuggestion = dedent` | ||
As you are using '.mdx'-files, it might be reasonable to keep the dependency. | ||
`; | ||
return [start, mdxSuggestion].join('\n\n'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The detectMDXEntries
is pretty heavy and requires some heavy-lifting file system lookups. I don't think it's worth it just to log this one-liner to the user. What is the worst that can happen? Things might break and the user has to re-add react
and react-dom
. I think that's acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the user uses .mdx
files, they will very likely want to keep the react dependency.
I pulled this code from the override preset, it costs like <80ms. Is that heavy lifting file system lookups to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know in which particular project you did the measurement, but I guess that the automigration might be blocking in bigger projects.
Also, I don't quite understand what you want to achieve:
- You only scan for mdx files, if they are part of the
stories
glob. If they are not defined in the stories glob, you are not checking for them. So why not directly just search formdx
in the stories glob pattern? I don't think file system lookups are necessary in this case. - What about MDX usage outside of Storybook. This case isn't covered here, since if the
stories
glob pattern doesn't mentionmdx
files, they also subsequently will not be found by glob. So if you want to cover this scenario, you don't have to consider thestories
glob at all but create a simple glob, which considers mdx files and pass it directly to theglob
function. Also, isn't this case the only relevant one? We want to keepreact
andreact-dom
if e.g. MDX is used outside of Storybook. Isn't this the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't think this check is necessary at all. Early results in #24881 shows that it's perfectly valid to have MDX files - even ones importing React components - in a project without react
and react-dom
. It just works. TypeScript in the IDE might complain - I haven't tested that out yet - but I don't think that warrants this additional message.
}, | ||
prompt({ hasMDX, hasDocs, hasEssentials }) { | ||
const addons = [hasEssentials ? 'essentials' : '', hasDocs ? 'docs' : ''].filter(Boolean); | ||
const addonReasonText = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like an unnecessary detail to me, I don't think it's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the special messages for MDX and the addons are unnecessary and we should be able to remove them to simplify the prompt without loosing value.
Co-authored-by: Jeppe Reinhold <jeppe@chromatic.com>
Co-authored-by: Jeppe Reinhold <jeppe@chromatic.com>
…-react-automigration
…-react-automigration
Telescoped: #25196
Works on #25179
What I did
Added an automigration prompt, asking users to remove "react" as a dependency, when it's likely they have it because we asked for it.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>