-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Core: Decouple Mocking Logic from Core into Builders #32921
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
Merged
valentinpalkovic
merged 18 commits into
valentin/cli-init-rework
from
valentin/cli-init-docs-performance
Nov 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
04f6bcd
Core: Move builder-specific mocking logic into builders
valentinpalkovic 6aae3d9
Fix tests
valentinpalkovic 1f13f05
Fix tests
valentinpalkovic 14becd3
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 12ed766
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 970ec6d
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 16b7aab
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 6ed2906
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic e379604
Improve error logging in extractMockCalls function to include error m…
valentinpalkovic ca75222
Merge remote-tracking branch 'origin/valentin/cli-init-rework' into v…
valentinpalkovic 423a1a9
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 926fd23
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 31bda49
Merge remote-tracking branch 'origin/valentin/cli-init-rework' into v…
valentinpalkovic a9da81c
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic d1f6bed
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic cabdff3
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic 5f21e96
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic e8977ce
Merge branch 'valentin/cli-init-rework' into valentin/cli-init-docs-p…
valentinpalkovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './dist/preset.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...er/presets/vitePlugins/vite-mock/utils.ts → ...ilder-vite/src/plugins/vite-mock/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import { realpathSync } from 'fs'; | ||
| import type { ViteDevServer } from 'vite'; | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { findConfigFile } from 'storybook/internal/common'; | ||
| import type { Options } from 'storybook/internal/types'; | ||
|
|
||
| import type { UserConfig } from 'vite'; | ||
|
|
||
| import { viteInjectMockerRuntime } from './plugins/vite-inject-mocker/plugin'; | ||
| import { viteMockPlugin } from './plugins/vite-mock/plugin'; | ||
|
|
||
| // This preset defines currently mocking plugins for Vite | ||
| // It is defined as a viteFinal preset so that @storybook/addon-vitest can use it as well and that it doesn't have to be duplicated in addon-vitest. | ||
| // The main vite configuration is defined in `./vite-config.ts`. | ||
| export async function viteFinal(existing: UserConfig, options: Options) { | ||
| const previewConfigPath = findConfigFile('preview', options.configDir); | ||
|
|
||
| // If there's no preview file, there's nothing to mock. | ||
| if (!previewConfigPath) { | ||
| return existing; | ||
| } | ||
|
|
||
| const coreOptions = await options.presets.apply('core'); | ||
|
|
||
| return { | ||
| ...existing, | ||
| plugins: [ | ||
| ...(existing.plugins ?? []), | ||
| ...(previewConfigPath | ||
| ? [ | ||
| viteInjectMockerRuntime({ previewConfigPath }), | ||
| viteMockPlugin({ previewConfigPath, coreOptions, configDir: options.configDir }), | ||
| ] | ||
| : []), | ||
| ], | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...oaders/storybook-mock-transform-loader.ts → ...oaders/storybook-mock-transform-loader.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...ebpack/loaders/webpack-automock-loader.ts → ...k5/src/loaders/webpack-automock-loader.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Normalize existing plugins before spreading
existing.pluginscan legally be a singlePluginOption(e.g.plugins: react()), so using the spread operator tries to iterate a non-iterable and throws at runtime. That regresses valid user configs. Normalize to an array before spreading so we don't crash.📝 Committable suggestion
🤖 Prompt for AI Agents