Skip to content

Commit

Permalink
Add deprecations for v3 future flags
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Oct 16, 2024
1 parent ed3a99a commit fca9594
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-clocks-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": minor
---

Log deprecation warnings for v3 future flags
52 changes: 52 additions & 0 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@ export async function resolveConfig(
}
}

logFutureFlagWarnings(future);

return {
appDirectory,
cacheDirectory,
Expand Down Expand Up @@ -742,3 +744,53 @@ let disjunctionListFormat = new Intl.ListFormat("en", {
style: "long",
type: "disjunction",
});

function logFutureFlagWarning(args: { flag: string; message: string }) {
logger.warn(args.message, {
key: args.flag,
details: [
`You can use the \`${args.flag}\` future flag to opt-in early.`,
`-> https://remix.run/docs/en/2.13.1/start/future-flags#${args.flag}`,
],
});
}

export function logFutureFlagWarnings(future: FutureConfig) {
if (!future.v3_fetcherPersist) {
logFutureFlagWarning({
flag: "v3_fetcherPersist",
message: "Fetcher persistence behavior is changing in React Router v7",
});
}

if (!future.v3_lazyRouteDiscovery) {
logFutureFlagWarning({
flag: "v3_lazyRouteDiscovery",
message:
"Route discovery/manifest behavior is changing in React Router v7",
});
}

if (!future.v3_relativeSplatPath) {
logFutureFlagWarning({
flag: "v3_relativeSplatPath",
message:
"Relative routing behavior for splat routes is changing in React Router v7",
});
}

if (!future.v3_singleFetch) {
logFutureFlagWarning({
flag: "v3_singleFetch",
message: "Data fetching is changing to a single fetch in React Router v7",
});
}

if (!future.v3_throwAbortReason) {
logFutureFlagWarning({
flag: "v3_throwAbortReason",
message:
"The format of errors thrown on aborted requests is changing in React Router v7",
});
}
}

0 comments on commit fca9594

Please sign in to comment.