Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/redabacha/remix into moderni…
Browse files Browse the repository at this point in the history
…ze-deno-template
  • Loading branch information
redabacha committed Oct 19, 2024
2 parents 0b65afb + 984875d commit 3907b73
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/rude-clocks-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@remix-run/dev": minor
---

- Log deprecation warnings for v3 future flags
- Add `@deprecated` annotations to `json`/`defer` utilities
10 changes: 9 additions & 1 deletion integration/vite-build-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ test.beforeAll(async () => {
},
plugins: [
mdx(),
remix(),
remix({
future: {
v3_fetcherPersist: true,
v3_lazyRouteDiscovery: true,
v3_relativeSplatPath: true,
v3_singleFetch: true,
v3_throwAbortReason: true,
}
}),
],
});
`,
Expand Down
15 changes: 13 additions & 2 deletions integration/vite-css-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const files = {
`,
"app/entry.client.tsx": js`
import "./entry.client.css";
import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
Expand Down Expand Up @@ -156,7 +156,18 @@ const VITE_CONFIG = async (port: number) => dedent`
export default {
${await viteConfig.server({ port })}
plugins: [remix(), vanillaExtractPlugin()],
plugins: [
remix({
future: {
v3_fetcherPersist: true,
v3_lazyRouteDiscovery: true,
v3_relativeSplatPath: true,
v3_singleFetch: true,
v3_throwAbortReason: true,
}
}),
vanillaExtractPlugin()
],
}
`;

Expand Down
20 changes: 18 additions & 2 deletions integration/vite-presets-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ const files = {
assetsDir: "custom-assets-dir",
},
plugins: [remix({
future: {
v3_fetcherPersist: true,
v3_lazyRouteDiscovery: true,
v3_relativeSplatPath: true,
v3_singleFetch: true,
v3_throwAbortReason: true,
},
presets: [
// Ensure user config is passed to remixConfig hook
{
Expand All @@ -35,7 +42,16 @@ const files = {
throw new Error("Remix user config doesn't have presets array.");
}
let expected = JSON.stringify({ appDirectory: "app"});
let expected = JSON.stringify({
future: {
v3_fetcherPersist: true,
v3_lazyRouteDiscovery: true,
v3_relativeSplatPath: true,
v3_singleFetch: true,
v3_throwAbortReason: true,
},
appDirectory: "app",
});
let actual = JSON.stringify(restUserConfig);
if (actual !== expected) {
Expand All @@ -49,7 +65,7 @@ const files = {
return {};
},
},
// Ensure preset config takes lower precedence than user config
{
name: "test-preset",
Expand Down
68 changes: 60 additions & 8 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { NodePolyfillsOptions as EsbuildPluginsNodeModulesPolyfillOptions } from "esbuild-plugins-node-modules-polyfill";
import fse from "fs-extra";
import { execSync } from "node:child_process";
import path from "node:path";
import { pathToFileURL } from "node:url";
import fse from "fs-extra";
import type { NodePolyfillsOptions as EsbuildPluginsNodeModulesPolyfillOptions } from "esbuild-plugins-node-modules-polyfill";

import type { RouteManifest, DefineRoutesFunction } from "./config/routes";
import { defineRoutes } from "./config/routes";
import { ServerMode, isValidServerMode } from "./config/serverModes";
import { serverBuildVirtualModule } from "./compiler/server/virtualModules";
import { flatRoutes } from "./config/flat-routes";
import { detectPackageManager } from "./cli/detectPackageManager";
import { tryLoadPackageJson } from "./cli/tryLoadPackageJson";
import { detectServerRuntime } from "./cli/detectServerRuntime";
import { tryLoadPackageJson } from "./cli/tryLoadPackageJson";
import { serverBuildVirtualModule } from "./compiler/server/virtualModules";
import { flatRoutes } from "./config/flat-routes";
import type { DefineRoutesFunction, RouteManifest } from "./config/routes";
import { defineRoutes } from "./config/routes";
import { ServerMode, isValidServerMode } from "./config/serverModes";
import { logger } from "./tux";

export interface RemixMdxConfig {
Expand Down Expand Up @@ -628,6 +628,8 @@ export async function resolveConfig(
}
}

logFutureFlagWarnings(future);

return {
appDirectory,
cacheDirectory,
Expand Down Expand Up @@ -692,3 +694,53 @@ export function findConfig(

return undefined;
}

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",
});
}
}
9 changes: 9 additions & 0 deletions packages/remix-server-runtime/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export type TypedResponse<T = unknown> = Omit<Response, "json"> & {
* This is a shortcut for creating `application/json` responses. Converts `data`
* to JSON and sets the `Content-Type` header.
*
* @deprecated This utility is deprecated in favor of opting into Single Fetch
* via `future.v3_singleFetch` and returning raw objects. This method will be
* removed in React Router v7. If you need to return a JSON Response, you can
* use `Response.json()`.
*
* @see https://remix.run/utils/json
*/
export const json: JsonFunction = (data, init = {}) => {
Expand All @@ -50,6 +55,10 @@ export const json: JsonFunction = (data, init = {}) => {
/**
* This is a shortcut for creating Remix deferred responses
*
* @deprecated This utility is deprecated in favor of opting into Single Fetch
* via `future.v3_singleFetch` and returning raw objects. This method will be
* removed in React Router v7.
*
* @see https://remix.run/utils/defer
*/
export const defer: DeferFunction = (data, init = {}) => {
Expand Down

0 comments on commit 3907b73

Please sign in to comment.