From 4b6ecafb57e3543f780613f940f03ef4840eed34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 16 Mar 2023 21:28:35 +0100 Subject: [PATCH 1/4] feat!(remix-dev): remove `browserBuildDirectory` config (#5701) --- .changeset/silver-readers-think.md | 5 +++++ packages/remix-dev/config.ts | 20 +------------------- 2 files changed, 6 insertions(+), 19 deletions(-) create mode 100644 .changeset/silver-readers-think.md diff --git a/.changeset/silver-readers-think.md b/.changeset/silver-readers-think.md new file mode 100644 index 00000000000..b529f441942 --- /dev/null +++ b/.changeset/silver-readers-think.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": major +--- + +remove `browserBuildDirectory` config diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 3b52c1c9c42..ebf28f4c87c 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -79,14 +79,6 @@ export interface AppConfig { */ assetsBuildDirectory?: string; - /** - * The path to the browser build, relative to remix.config.js. Defaults to - * "public/build". - * - * @deprecated Use `{@link AppConfig.assetsBuildDirectory}` instead - */ - browserBuildDirectory?: string; - /** * The URL prefix of the browser build with a trailing slash. Defaults to * `"/build/"`. This is the path the browser will use to find assets. @@ -489,14 +481,8 @@ export async function readConfig( ? path.resolve(appDirectory, userEntryServerFile) : path.resolve(defaultsDirectory, entryServerFile); - if (appConfig.browserBuildDirectory) { - warnOnce(browserBuildDirectoryWarning, "browserBuildDirectory"); - } - let assetsBuildDirectory = - appConfig.assetsBuildDirectory || - appConfig.browserBuildDirectory || - path.join("public", "build"); + appConfig.assetsBuildDirectory || path.join("public", "build"); let absoluteAssetsBuildDirectory = path.resolve( rootDirectory, @@ -676,10 +662,6 @@ let listFormat = new Intl.ListFormat("en", { type: "conjunction", }); -export let browserBuildDirectoryWarning = - "⚠️ DEPRECATED: The `browserBuildDirectory` config option is deprecated. " + - "Use `assetsBuildDirectory` instead."; - export let serverBuildDirectoryWarning = "⚠️ DEPRECATED: The `serverBuildDirectory` config option is deprecated. " + "Use `serverBuildPath` instead."; From 011b424294d2f30d0805ec8d9b18bc1f9f9aaf8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 16 Mar 2023 22:03:08 +0100 Subject: [PATCH 2/4] feat!(remix-dev): remove `serverBuildDirectory` config (#5703) Co-authored-by: Jacob Ebey --- .changeset/tame-moons-buy.md | 5 +++++ packages/remix-dev/config.ts | 37 ++++-------------------------------- 2 files changed, 9 insertions(+), 33 deletions(-) create mode 100644 .changeset/tame-moons-buy.md diff --git a/.changeset/tame-moons-buy.md b/.changeset/tame-moons-buy.md new file mode 100644 index 00000000000..ff3d3c69ca0 --- /dev/null +++ b/.changeset/tame-moons-buy.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": major +--- + +remove `serverBuildDirectory` config diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index ebf28f4c87c..ad1b7c37b65 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -109,14 +109,6 @@ export interface AppConfig { */ server?: string; - /** - * The path to the server build, relative to `remix.config.js`. Defaults to - * "build". - * - * @deprecated Use {@link AppConfig.serverBuildPath} instead. - */ - serverBuildDirectory?: string; - /** * The path to the server build file, relative to `remix.config.js`. This file * should end in a `.js` extension and should be deployed to your server. @@ -373,7 +365,10 @@ export async function readConfig( warnOnce(errorBoundaryWarning, "v2_errorBoundary"); } - let serverBuildPath = resolveServerBuildPath(rootDirectory, appConfig); + let serverBuildPath = path.resolve( + rootDirectory, + appConfig.serverBuildPath ?? "build/index.js" + ); let serverBuildTargetEntryModule = `export * from ${JSON.stringify( serverBuildVirtualModule.id )};`; @@ -635,26 +630,6 @@ export function findConfig( return undefined; } -const resolveServerBuildPath = ( - rootDirectory: string, - appConfig: AppConfig -) => { - let serverBuildPath = "build/index.js"; - - // retain deprecated behavior for now - if (appConfig.serverBuildDirectory) { - warnOnce(serverBuildDirectoryWarning, "serverBuildDirectory"); - - serverBuildPath = path.join(appConfig.serverBuildDirectory, "index.js"); - } - - if (appConfig.serverBuildPath) { - serverBuildPath = appConfig.serverBuildPath; - } - - return path.resolve(rootDirectory, serverBuildPath); -}; - // @ts-expect-error available in node 12+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat#browser_compatibility let listFormat = new Intl.ListFormat("en", { @@ -662,10 +637,6 @@ let listFormat = new Intl.ListFormat("en", { type: "conjunction", }); -export let serverBuildDirectoryWarning = - "⚠️ DEPRECATED: The `serverBuildDirectory` config option is deprecated. " + - "Use `serverBuildPath` instead."; - export let serverBuildTargetWarning = "⚠️ DEPRECATED: The `serverBuildTarget` config option is deprecated. Use a " + "combination of `publicPath`, `serverBuildPath`, `serverConditions`, " + From b485b8519ab2ec12782ae51e8c90e977d782fbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 16 Mar 2023 22:23:00 +0100 Subject: [PATCH 3/4] test(integration/templates): remove `meta` from `root` files (#5832) --- integration/helpers/cf-template/app/root.tsx | 9 ++------- integration/helpers/deno-template/app/root.tsx | 9 ++------- integration/helpers/node-template/app/root.tsx | 9 ++------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/integration/helpers/cf-template/app/root.tsx b/integration/helpers/cf-template/app/root.tsx index 43a72817b93..1f082523e7b 100644 --- a/integration/helpers/cf-template/app/root.tsx +++ b/integration/helpers/cf-template/app/root.tsx @@ -1,4 +1,3 @@ -import type { MetaFunction } from "@remix-run/cloudflare"; import { Links, LiveReload, @@ -8,16 +7,12 @@ import { ScrollRestoration, } from "@remix-run/react"; -export const meta: MetaFunction = () => ({ - charset: "utf-8", - title: "New Remix App", - viewport: "width=device-width,initial-scale=1", -}); - export default function App() { return ( + + diff --git a/integration/helpers/deno-template/app/root.tsx b/integration/helpers/deno-template/app/root.tsx index 9171cb50f31..a6a08d93909 100644 --- a/integration/helpers/deno-template/app/root.tsx +++ b/integration/helpers/deno-template/app/root.tsx @@ -1,4 +1,3 @@ -import type { MetaFunction } from "@remix-run/deno"; import { Links, LiveReload, @@ -9,16 +8,12 @@ import { } from "@remix-run/react"; import * as React from "react"; -export const meta: MetaFunction = () => ({ - charset: "utf-8", - title: "New Remix App", - viewport: "width=device-width,initial-scale=1", -}); - export default function App() { return ( + + diff --git a/integration/helpers/node-template/app/root.tsx b/integration/helpers/node-template/app/root.tsx index 927a0f745df..1f082523e7b 100644 --- a/integration/helpers/node-template/app/root.tsx +++ b/integration/helpers/node-template/app/root.tsx @@ -1,4 +1,3 @@ -import type { MetaFunction } from "@remix-run/node"; import { Links, LiveReload, @@ -8,16 +7,12 @@ import { ScrollRestoration, } from "@remix-run/react"; -export const meta: MetaFunction = () => ({ - charset: "utf-8", - title: "New Remix App", - viewport: "width=device-width,initial-scale=1", -}); - export default function App() { return ( + + From 12e5aa6a05e7849db20787dbfe6b2884da66f9a2 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 16 Mar 2023 14:46:55 -0700 Subject: [PATCH 4/4] (react): Fix missing meta and mutation bugs (#5833) --- packages/remix-react/components.tsx | 49 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx index 35d8fdeb713..dffce5c9a9d 100644 --- a/packages/remix-react/components.tsx +++ b/packages/remix-react/components.tsx @@ -667,6 +667,28 @@ function V2Meta() { let routeModule = routeModules[routeId]; let routeMeta: V2_MetaDescriptor[] | V1_HtmlMetaDescriptor | undefined = []; + let match: V2_MetaMatch = { + id: routeId, + data, + meta: [], + params: _match.params, + pathname: _match.pathname, + handle: _match.route.handle, + // TODO: Remove in v2. Only leaving it for now because we used it in + // examples and there's no reason to crash someone's build for one line. + // They'll get a TS error from the type updates anyway. + // @ts-expect-error + get route() { + console.warn( + "The meta function in " + + _match.route.path + + " accesses the `route` property on `matches`. This is deprecated and will be removed in Remix version 2. See" + ); + return _match.route; + }, + }; + matches[i] = match; + if (routeModule?.meta) { routeMeta = typeof routeModule.meta === "function" @@ -676,12 +698,14 @@ function V2Meta() { location, matches, }) + : Array.isArray(routeModule.meta) + ? [...routeModule.meta] : routeModule.meta; } else if (leafMeta) { // We only assign the route's meta to the nearest leaf if there is no meta // export in the route. The meta function may return a falsey value which // is effectively the same as an empty array. - routeMeta = leafMeta; + routeMeta = [...leafMeta]; } routeMeta = routeMeta || []; @@ -697,28 +721,9 @@ function V2Meta() { ); } - let match: V2_MetaMatch = { - id: routeId, - data, - meta: routeMeta, - params: _match.params, - pathname: _match.pathname, - handle: _match.route.handle, - // TODO: Remove in v2. Only leaving it for now because we used it in - // examples and there's no reason to crash someone's build for one line. - // They'll get a TS error from the type updates anyway. - // @ts-expect-error - get route() { - console.warn( - "The meta function in " + - _match.route.path + - " accesses the `route` property on `matches`. This is deprecated and will be removed in Remix version 2. See" - ); - return _match.route; - }, - }; + match.meta = routeMeta; matches[i] = match; - meta = routeMeta; + meta = [...routeMeta]; leafMeta = meta; }