-
-
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: Fix builder stats typings to be optional #18377
Core: Fix builder stats typings to be optional #18377
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit b49b835. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
Fixes #397. Storybook expects `stats` to match `Stats` interface of `webpack`: https://github.com/webpack/webpack/blob/main/types.d.ts#L11243-L11253. This type-mismatch is caused by `@storybook/core-common`'s `Builder` and will be fixed by storybookjs/storybook#18377. - Pass null as optional Stats instead of incorrect structure
It also seems that this causes 2 issues:
|
Good catch. I was unable to run storybook locally when creating the PR but got it running now - I'm also seeing this error now. Looks like it's caused by Webpack v4 vs v5 storybook/lib/core-common/package.json Line 92 in 008b542
Another option is to create a custom interface where we explicitly list the types we expect from a builder stats. This would mean that whole codebase should be scanned for the usage of stats - as there are /** Webpack 4/5 compatible `Stats` interface */
interface Stats {
/** Returns compilation information as a JSON object. */
toJson(options?: SomeType, forToString?: boolean): SomeOutputType;
} |
@AriPerkkio I've been working on Perhaps you'll be keen to take a look at my work here: Do you think it'd be best to focus your efforts on FYI: The default branch |
Yes, I think we should only target the However it seems that in #18504 the storybook/lib/core-common/src/types.ts Line 193 in 9b92429
The idea of separating Webpack typings from @storybook/core-common is great but those stats are still a Webpack thing. I don't think we want to make @storybook/core-common dependent of @storybook/webpack-common , right? Where should the typings of stats be defined?
|
They should be super generic in core-common then be extended and made webpack specific in core-webpack, and then possibly be extended again in builder-webpack5. |
@AriPerkkio let's rebase this unto |
7743f01
to
0502e0d
Compare
Rebased storybook/lib/core-common/src/types.ts Lines 102 to 104 in 379d8b8
Now, with changes of this PR, builders which do not provide such |
Awesome, I'll take a look on Monday! |
Sorry for the delay, I merged in the base branch, to see if the CI approves... If it does, I'm going to merge it! 👏👏👏 |
Issue: storybookjs/builder-vite#397
What I did
Fixed typings of
Builder
(@storybook/core-common
package). Currently typings and implementation do not match. The implementation is using@ts-ignore
😭storybook/lib/core-server/src/build-dev.ts
Lines 109 to 111 in 61d6451
Usage of
Builder<SomeValidConfigType, {}>
causes TypeErrors mentioned in the linked issue. If typings were correct these kind of issues would be prevented.How to test
If your answer is yes to any of these, please make sure to include it in your PR.