diff --git a/.changeset/quiet-disks-rest.md b/.changeset/quiet-disks-rest.md new file mode 100644 index 00000000..3f881289 --- /dev/null +++ b/.changeset/quiet-disks-rest.md @@ -0,0 +1,5 @@ +--- +'rsbuild-plugin-react-router': patch +--- + +Stop forcing development output to disk so `dev.writeToDisk: false` and Rsbuild's in-memory default are preserved. diff --git a/examples/default-template/tests/e2e/dev-route-watch.test.ts b/examples/default-template/tests/e2e/dev-route-watch.test.ts index 56dceef2..cc0e3ed2 100644 --- a/examples/default-template/tests/e2e/dev-route-watch.test.ts +++ b/examples/default-template/tests/e2e/dev-route-watch.test.ts @@ -144,7 +144,6 @@ test.describe('dev route watch', () => { }) => { await page.goto('/'); await expect(page.locator('h1')).toContainText('Welcome to React Router'); - const restartMarkerBeforeAdd = readRestartMarkerVersion(); writeFileSync( addedRoutePath, @@ -161,9 +160,6 @@ test.describe('dev route watch', () => { await page.goto(addedRouteUrl); await expect(page.locator('h1')).toHaveText(addedRouteText); - await expect - .poll(readRestartMarkerVersion, { timeout: 10000 }) - .not.toBe(restartMarkerBeforeAdd); const restartMarkerBefore = readRestartMarkerVersion(); writeFileSync( addedRoutePath, diff --git a/src/index.ts b/src/index.ts index 7144c910..f7abb10b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -800,7 +800,6 @@ export const pluginReactRouter = ( assetPrefix: config.output?.assetPrefix || '/', }, dev: { - writeToDisk: true, ...lazyCompilation, watchFiles: mergeWatchFiles(config.dev?.watchFiles, routeWatchFiles), }, diff --git a/tests/features.test.ts b/tests/features.test.ts index 6e1489f2..28b505cf 100644 --- a/tests/features.test.ts +++ b/tests/features.test.ts @@ -33,7 +33,7 @@ describe('pluginReactRouter', () => { // The plugin should not override Rsbuild's HMR defaults. expect(config.dev.hmr).toBe(true); expect(config.dev.liveReload).toBe(true); - expect(config.dev.writeToDisk).toBe(true); + expect(config.dev.writeToDisk).toBe(false); }); it('should register the dev server middleware via server.setup', async () => { diff --git a/tests/index.test.ts b/tests/index.test.ts index 617e1683..8452bebd 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -60,7 +60,7 @@ describe('pluginReactRouter', () => { // The plugin should not override Rsbuild's HMR defaults. expect(config.dev.hmr).toBe(true); expect(config.dev.liveReload).toBe(true); - expect(config.dev.writeToDisk).toBe(true); + expect(config.dev.writeToDisk).toBe(false); expect(config.dev.lazyCompilation).toMatchObject({ entries: true, imports: true, @@ -72,6 +72,19 @@ describe('pluginReactRouter', () => { ).toBe(false); }); + it('preserves an explicit writeToDisk override', async () => { + const rsbuild = await createStubRsbuild({ + rsbuildConfig: { + dev: { writeToDisk: true }, + }, + }); + + rsbuild.addPlugins([pluginReactRouter()]); + const config = await rsbuild.unwrapConfig(); + + expect(config.dev.writeToDisk).toBe(true); + }); + it('adds the committed custom-server build entry only in development', async () => { const devRsbuild = await createStubRsbuild({ rsbuildConfig: {} }); devRsbuild.addPlugins([pluginReactRouter({ customServer: true })]);