Skip to content

Commit

Permalink
Stabilize the optimizeDeps future flag (#10092)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 authored Oct 11, 2024
1 parent a3230ee commit 3626151
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/hot-dingos-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": minor
---

Stabilize the `future.unstable_optimizeDeps` flag into `future.v3_optimizeDeps`
2 changes: 1 addition & 1 deletion docs/guides/dependency-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Dependency optimization

# Dependency optimization

Remix introduced automatic dependency optimization in development behind the `future.unstable_optimizeDeps` [Future Flag][future-flags].
Remix introduced automatic dependency optimization in development behind the `future.v3_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.
Expand Down
20 changes: 18 additions & 2 deletions docs/start/future-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,25 @@ You shouldn't need to make any changes to your application code for this feature

You may find some usage for the new [`<Link discover>`][discover-prop] API if you wish to disable eager route discovery on certain links.

## unstable_optimizeDeps
## v3_optimizeDeps

Opt into automatic [dependency optimization][dependency-optimization] during development.
**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.

[development-strategy]: ../guides/api-development-strategy
[fetcherpersist-rfc]: https://github.com/remix-run/remix/discussions/7698
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ describe("readConfig", () => {
"entryServerFile": "entry.server.tsx",
"entryServerFilePath": Any<String>,
"future": {
"unstable_optimizeDeps": false,
"v3_fetcherPersist": false,
"v3_lazyRouteDiscovery": false,
"v3_optimizeDeps": false,
"v3_relativeSplatPath": false,
"v3_singleFetch": false,
"v3_throwAbortReason": false,
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface FutureConfig {
v3_throwAbortReason: boolean;
v3_singleFetch: boolean;
v3_lazyRouteDiscovery: boolean;
unstable_optimizeDeps: boolean;
v3_optimizeDeps: boolean;
}

type NodeBuiltinsPolyfillOptions = Pick<
Expand Down Expand Up @@ -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,
unstable_optimizeDeps: appConfig.future?.unstable_optimizeDeps === true,
v3_optimizeDeps: appConfig.future?.v3_optimizeDeps === true,
};

if (appConfig.future) {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ export const remixVitePlugin: RemixVitePlugin = (remixUserConfig = {}) => {
: undefined,
},
optimizeDeps: {
entries: ctx.remixConfig.future.unstable_optimizeDeps
entries: ctx.remixConfig.future.v3_optimizeDeps
? [
ctx.entryClientFilePath,
...Object.values(ctx.remixConfig.routes).map((route) =>
Expand Down

0 comments on commit 3626151

Please sign in to comment.