Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize the optimizeDeps future flag #10092

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading