From 323af6d2e148a824dd1b4643bb28c01b2e08e49d Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 11 Oct 2024 16:34:01 -0400 Subject: [PATCH 1/3] Revert "Stabilize the optimizeDeps future flag (#10092)" This reverts commit 3626151a7574fb92808ee321fec3aad65368390e. --- docs/guides/dependency-optimization.md | 2 +- docs/start/future-flags.md | 20 ++----------------- .../remix-dev/__tests__/readConfig-test.ts | 2 +- packages/remix-dev/config.ts | 4 ++-- packages/remix-dev/vite/plugin.ts | 2 +- 5 files changed, 7 insertions(+), 23 deletions(-) diff --git a/docs/guides/dependency-optimization.md b/docs/guides/dependency-optimization.md index a92f9b3733c..48877769a3e 100644 --- a/docs/guides/dependency-optimization.md +++ b/docs/guides/dependency-optimization.md @@ -6,7 +6,7 @@ title: Dependency optimization # Dependency optimization -Remix introduced automatic dependency optimization in development behind the `future.v3_optimizeDeps` [Future Flag][future-flags]. +Remix introduced automatic dependency optimization in development behind the `future.unstable_optimizeDeps` [Future Flag][future-flags]. This allows you to opt-into this behavior which will become the default in the next major version of Remix - a.k.a. React Router v7 ([1][rr-v7], [2][rr-v7-2]). In development, Vite aims to [prebundle dependencies][prebundle-dependencies] so that it can efficiently serve up those dependencies on-demand. diff --git a/docs/start/future-flags.md b/docs/start/future-flags.md index 1356d4937d1..728da129fb0 100644 --- a/docs/start/future-flags.md +++ b/docs/start/future-flags.md @@ -472,25 +472,9 @@ You shouldn't need to make any changes to your application code for this feature You may find some usage for the new [``][discover-prop] API if you wish to disable eager route discovery on certain links. -## v3_optimizeDeps +## unstable_optimizeDeps -**Background** - -This flag allows you to opt-into automatic [dependency optimization][dependency-optimization] during development when using Vite. - -👉 **Enable the Flag** - -```ts filename=vite.config.ts -remix({ - future: { - v3_optimizeDeps: true, - }, -}); -``` - -**Update your Code** - -You shouldn't need to make any changes to your application code for this feature to work. +Opt into automatic [dependency optimization][dependency-optimization] during development. [development-strategy]: ../guides/api-development-strategy [fetcherpersist-rfc]: https://github.com/remix-run/remix/discussions/7698 diff --git a/packages/remix-dev/__tests__/readConfig-test.ts b/packages/remix-dev/__tests__/readConfig-test.ts index bd06d50309f..f528c16f15e 100644 --- a/packages/remix-dev/__tests__/readConfig-test.ts +++ b/packages/remix-dev/__tests__/readConfig-test.ts @@ -36,9 +36,9 @@ describe("readConfig", () => { "entryServerFile": "entry.server.tsx", "entryServerFilePath": Any, "future": { + "unstable_optimizeDeps": false, "v3_fetcherPersist": false, "v3_lazyRouteDiscovery": false, - "v3_optimizeDeps": false, "v3_relativeSplatPath": false, "v3_singleFetch": false, "v3_throwAbortReason": false, diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index b6cb6dd8f01..16065ff01af 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -39,7 +39,7 @@ interface FutureConfig { v3_throwAbortReason: boolean; v3_singleFetch: boolean; v3_lazyRouteDiscovery: boolean; - v3_optimizeDeps: boolean; + unstable_optimizeDeps: boolean; } type NodeBuiltinsPolyfillOptions = Pick< @@ -605,7 +605,7 @@ export async function resolveConfig( v3_throwAbortReason: appConfig.future?.v3_throwAbortReason === true, v3_singleFetch: appConfig.future?.v3_singleFetch === true, v3_lazyRouteDiscovery: appConfig.future?.v3_lazyRouteDiscovery === true, - v3_optimizeDeps: appConfig.future?.v3_optimizeDeps === true, + unstable_optimizeDeps: appConfig.future?.unstable_optimizeDeps === true, }; if (appConfig.future) { diff --git a/packages/remix-dev/vite/plugin.ts b/packages/remix-dev/vite/plugin.ts index c886f7fcbcf..53ce6400b57 100644 --- a/packages/remix-dev/vite/plugin.ts +++ b/packages/remix-dev/vite/plugin.ts @@ -1075,7 +1075,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => { : undefined, }, optimizeDeps: { - entries: ctx.remixConfig.future.v3_optimizeDeps + entries: ctx.remixConfig.future.unstable_optimizeDeps ? [ ctx.entryClientFilePath, ...Object.values(ctx.remixConfig.routes).map((route) => From c6f84f5e13dfed7d69d6fc2da546bf71897ce44d Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 11 Oct 2024 16:37:03 -0400 Subject: [PATCH 2/3] changeset and update docs --- .changeset/slow-guests-wait.md | 5 +++++ docs/start/future-flags.md | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/slow-guests-wait.md diff --git a/.changeset/slow-guests-wait.md b/.changeset/slow-guests-wait.md new file mode 100644 index 00000000000..daa1eb032cb --- /dev/null +++ b/.changeset/slow-guests-wait.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +Revert `future.v3_optimizeDeps` back to `future.unstable_optimizeDeps` as it was not intended to stabilize in Remix v2 diff --git a/docs/start/future-flags.md b/docs/start/future-flags.md index 728da129fb0..664388b602b 100644 --- a/docs/start/future-flags.md +++ b/docs/start/future-flags.md @@ -474,7 +474,7 @@ You may find some usage for the new [``][discover-prop] API if yo ## unstable_optimizeDeps -Opt into automatic [dependency optimization][dependency-optimization] during development. +Opt into automatic [dependency optimization][dependency-optimization] during development. This flag will remain in an "unstable" state until React Router v7 so you do not need to adopt this in your Remix v2 app prior to upgrading to React Router v7. [development-strategy]: ../guides/api-development-strategy [fetcherpersist-rfc]: https://github.com/remix-run/remix/discussions/7698 From 470258346b604f0c5bda319c624bacbd10c047d1 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 11 Oct 2024 16:52:24 -0400 Subject: [PATCH 3/3] Update docs --- docs/guides/dependency-optimization.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/guides/dependency-optimization.md b/docs/guides/dependency-optimization.md index 48877769a3e..7d06dbb0f56 100644 --- a/docs/guides/dependency-optimization.md +++ b/docs/guides/dependency-optimization.md @@ -6,8 +6,7 @@ title: Dependency optimization # Dependency optimization -Remix introduced automatic dependency optimization in development behind the `future.unstable_optimizeDeps` [Future Flag][future-flags]. -This allows you to opt-into this behavior which will become the default in the next major version of Remix - a.k.a. React Router v7 ([1][rr-v7], [2][rr-v7-2]). +Remix introduced automatic dependency optimization in development behind the `future.unstable_optimizeDeps` [Future Flag][future-flags]. This allows you to opt-into this behavior which will eventually become the default in some future version of Remix - a.k.a. React Router ([1][rr-v7], [2][rr-v7-2]). This flag is intended to remain "unstable" into React Router v7 as there is some additional bundling-related work coming that will ease adoption of the flag. We plan to stabilize the flag once that work is completed in v7. In development, Vite aims to [prebundle dependencies][prebundle-dependencies] so that it can efficiently serve up those dependencies on-demand. To do this, Vite needs to know where to start crawling your app's module graph to look for dependencies.