-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Core: Support valid globs #10926
Core: Support valid globs #10926
Conversation
…ntation & migration-guide
# Conflicts: # MIGRATION.md
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.
Does "at some point in the future" mean 7.0 or later?
If you want to do that optimization in a 6.x release, we should make the breaking change now. WDYT?
7.0 or later yes |
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'm so happy this is fixed <3
'../src/stories/components/Icon/Icon.mdx', | ||
], | ||
}, | ||
// DUMB GLOB |
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.
should this comment stay here? 😂
So turns out, valid globs break webpack. I've investigating why, but it's not going well. |
Co-authored-by: Yann Braga <[email protected]>
Co-authored-by: Yann Braga <[email protected]>
Co-authored-by: Yann Braga <[email protected]>
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.
Looks good except for the FIXME.
Also can you provide a handful unit tests for this since it's complex and deserves a little documentation
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.
Nice! Didn't realize there were already unit tests in the other file 👍
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.
Couple more things
Co-authored-by: Michael Shilman <[email protected]>
# Conflicts: # lib/core/package.json
So happy to have a found a solution, and a clean break on how to deal with the invalid globs in a backwards but future friendly way. All we need to do to remove the bad behavior support is delete a few lines of code. |
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.
Two more 😅
Co-authored-by: Michael Shilman <[email protected]>
Co-authored-by: Michael Shilman <[email protected]>
@@ -57,13 +57,18 @@ export async function createPreviewEntry(options) { | |||
if (stories && stories.length) { | |||
entries.push(path.resolve(path.join(configDir, `generated-stories-entry.js`))); | |||
|
|||
const files = (await Promise.all(stories.map((g) => glob(g)))).reduce((a, b) => a.concat(b)); | |||
const files = ( | |||
await Promise.all(stories.map((g) => glob(path.join(configDir, g)))) |
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.
@ndelangen Is this correct? I don't think it makes sense to join the glob with the configDir. This means that all globs before this pr won't work anymore
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.
yes this is intentional indeed.
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.
@ndelangen if this is a breaking change do we need to document it in MIGRATION.md
?
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 is def a breaking change that should be documented. But it seems really odd to me that your glob become .storybook/**/*.stories
. IDK when I would ever want that. In reality it always must be something like .storybook/../**/*.stories
.
Issue: #10772
What I did
The value of
stories
inmain.js
is supposed to be a valid glob. We plan to optimize storybook by moving from a regex evaluated in webpack to a glob evaluated by node.But we made a mistake, when we wrote the original globs in our docs & CLI generators. It's actually an invalid glob, but it still works, because the glob-to-regex lib makes it work.
In the future instead of using a glob-to-regex we'll use glob solely.
I added instructions to migration.md & make the warning clearer on what's really happening.
We'll keep the invalid globs working in storybook for now, but they will break at some point in the future.