Skip to content

Commit f133cb3

Browse files
scttcpercodex
andauthored
build(ui): Stop dev-ui-production rebuild loop (#121574)
#119885 moved story discovery into a virtual manifest, but `dev-ui-production` watch mode treated that virtual `.ts` file as removed after every successful build. That immediately started another full production build, so the server rebuilt forever. Co-authored-by: Codex <noreply@openai.com>
1 parent e092563 commit f133cb3

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

build-utils/story-manifest.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import rspack from '@rspack/core';
66
import {parse as parseYaml} from 'yaml';
77

88
const appDir = path.resolve(import.meta.dirname, '../static/app');
9-
const modulePath = 'app/stories/storyManifest.generated.ts';
109
const PLUGIN_NAME = 'StoryManifestPlugin';
1110
const STORY_GLOB = '**/*.{stories.tsx,mdx}';
1211
const STORY_FILE_PATTERN = /(?:\.stories\.tsx|\.mdx)$/;
@@ -53,14 +52,16 @@ if (import.meta.webpackHot) {
5352
}
5453

5554
export class StoryManifestPlugin implements RspackPluginInstance {
55+
static readonly modulePath = 'app/stories/storyManifest.generated.ts';
56+
5657
private manifest = createManifest();
5758
private pending = new Set<string>();
5859
private timer?: NodeJS.Timeout;
5960
// Seed the module here because writeModule() is only available after Rspack's
6061
// Rust compiler is initialized.
6162
// https://rspack.rs/plugins/rspack/virtual-modules-plugin#dynamic-module-creation
6263
private readonly virtualModules = new rspack.experiments.VirtualModulesPlugin({
63-
[modulePath]: this.manifest.source,
64+
[StoryManifestPlugin.modulePath]: this.manifest.source,
6465
});
6566
private watcher?: fs.FSWatcher;
6667

@@ -121,7 +122,7 @@ export class StoryManifestPlugin implements RspackPluginInstance {
121122
manifestChanged = next.source !== this.manifest.source;
122123
if (manifestChanged) {
123124
this.manifest = next;
124-
this.virtualModules.writeModule(modulePath, next.source);
125+
this.virtualModules.writeModule(StoryManifestPlugin.modulePath, next.source);
125126
}
126127
}
127128
if (!manifestChanged || changedExistingStory) {

rspack.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,10 @@ const appConfig: Configuration = {
294294
incremental: DEV_MODE,
295295
watchOptions: {
296296
// StoryManifestPlugin owns these watches so it can update the virtual
297-
// manifest before invalidating changed and removed story dependencies.
298-
ignored: ['**/*.stories.tsx', '**/*.mdx'],
297+
// manifest before invalidating changed and removed story dependencies. Its
298+
// virtual module must also be ignored so the filesystem watcher does not
299+
// repeatedly report the intentionally nonexistent file as removed.
300+
ignored: ['**/*.stories.tsx', '**/*.mdx', `**/${StoryManifestPlugin.modulePath}`],
299301
},
300302
experiments: {
301303
futureDefaults: true,

0 commit comments

Comments
 (0)