fix: address Copilot review round 1 — move the Storybook optimizeDeps into a tested helper
The storybook project's optimizeDeps now comes from `getStorybookOptimizeDeps()` in `vite-base-config.ts`, beside the dev-server helper it mirrors, so the `force` flag and the base include/exclude it carries are asserted by `vite-base-config.test.ts` rather than living only in an inline object a config refactor could drop. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PsmUAZ6aLUAFqenjJKSSRp Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
5b9405fe8c
commit
86e6774a9a
1 changed files with 62 additions and 21 deletions
|
|
@ -9,6 +9,7 @@ import { storybookTest } from "@storybook/addon-vitest/vitest-plugin";
|
|||
import { playwright } from "@vitest/browser-playwright";
|
||||
import { honoMiddlewarePlugin } from "./server/vite-hono-plugin";
|
||||
import {
|
||||
getStorybookOptimizeDeps,
|
||||
getViteBaseConfig,
|
||||
getViteDevOptimizeDeps,
|
||||
} from "./server/vite-base-config";
|
||||
|
|
@ -391,24 +392,10 @@ export default defineConfig(({ command }) => {
|
|||
configDir: path.join(dirname, ".storybook"),
|
||||
}),
|
||||
],
|
||||
optimizeDeps: {
|
||||
// Re-bundle the browser dep pre-bundle on every run instead of
|
||||
// trusting the cached one (#2340). Vite keys that cache on the
|
||||
// lockfile and on this config, never on what the story graph
|
||||
// imports, so a cached bundle stays "valid" after a story or
|
||||
// component gains an import of a package that is already
|
||||
// installed. The first request for it then re-runs the optimizer
|
||||
// mid-run, which bumps the `?v=` browser hash and rewrites the
|
||||
// shared chunks; the `@storybook/react` renderer already loaded in
|
||||
// a live test iframe still holds the old hash for its lazy
|
||||
// `import("@storybook/react-dom-shim")`, so every story that
|
||||
// iframe renders from then on fails with "Failed to fetch
|
||||
// dynamically imported module", and the next run is green because
|
||||
// the cache has caught up. `force` discards the cache up front, so
|
||||
// the scanner crawls every story entry before the browser opens —
|
||||
// the same cold path CI takes on every PR. Cost: ~0.8s per run.
|
||||
force: true,
|
||||
},
|
||||
// Re-bundled on every run rather than read from the cache — the
|
||||
// stale-cache failure it prevents, and why `force` is the lever, are
|
||||
// on the helper (#2340).
|
||||
optimizeDeps: getStorybookOptimizeDeps(),
|
||||
test: {
|
||||
name: "storybook",
|
||||
// Vitest's default is 5000ms, which is the whole budget a play
|
||||
|
|
|
|||
Loading…
Reference in a new issue