From 3360ee326267725c64ea140db0c15c9c2d2cf558 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Wed, 9 Nov 2022 17:09:49 -0800 Subject: [PATCH 01/10] feat(compiler): add support for remix config feature flags --- .changeset/calm-eels-invite.md | 5 ++++ packages/remix-dev/compiler/compileBrowser.ts | 3 +++ packages/remix-dev/compiler/compilerServer.ts | 3 +++ packages/remix-dev/config.ts | 23 +++++++++++++++++++ packages/remix-dev/index.ts | 2 +- 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .changeset/calm-eels-invite.md diff --git a/.changeset/calm-eels-invite.md b/.changeset/calm-eels-invite.md new file mode 100644 index 00000000000..8d1ea67cb2e --- /dev/null +++ b/.changeset/calm-eels-invite.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +Added support for feature flags in `remix.config.js` diff --git a/packages/remix-dev/compiler/compileBrowser.ts b/packages/remix-dev/compiler/compileBrowser.ts index 338dd8a7dd8..2ffdcad6545 100644 --- a/packages/remix-dev/compiler/compileBrowser.ts +++ b/packages/remix-dev/compiler/compileBrowser.ts @@ -107,6 +107,9 @@ const createEsbuildConfig = ( "process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify( config.devServerPort ), + "process.env.REMIX_CONFIG_FEATURES_V2_META": JSON.stringify( + config.features.v2_meta + ), }, jsx: "automatic", jsxDev: options.mode !== "production", diff --git a/packages/remix-dev/compiler/compilerServer.ts b/packages/remix-dev/compiler/compilerServer.ts index fa5289b61e9..9bbbf40a790 100644 --- a/packages/remix-dev/compiler/compilerServer.ts +++ b/packages/remix-dev/compiler/compilerServer.ts @@ -108,6 +108,9 @@ const createEsbuildConfig = ( "process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify( config.devServerPort ), + "process.env.REMIX_CONFIG_FEATURES_V2_META": JSON.stringify( + config.features.v2_meta + ), }, jsx: "automatic", jsxDev: options.mode !== "production", diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 0a6d3943eb7..0410cd2ab03 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -157,6 +157,15 @@ export interface AppConfig { | string | string[] | (() => Promise | string | string[]); + + features?: { + /** + * A flag to opt-in to the updated route `meta` API for v2. + * + * @see https://github.com/remix-run/remix/discussions/4462 + */ + v2_meta?: boolean; + }; } /** @@ -275,6 +284,15 @@ export interface RemixConfig { * The path for the tsconfig file, if present on the root directory. */ tsconfigPath: string | undefined; + + features: { + /** + * A flag to opt-in to the updated route `meta` API for v2. + * + * @see https://github.com/remix-run/remix/discussions/4462 + */ + v2_meta: boolean; + }; } /** @@ -472,6 +490,10 @@ export async function readConfig( writeConfigDefaults(tsconfigPath); } + let features = { + v2_meta: appConfig.features?.v2_meta === true, + }; + return { appDirectory, cacheDirectory, @@ -495,6 +517,7 @@ export async function readConfig( mdx, watchPaths, tsconfigPath, + features, }; } diff --git a/packages/remix-dev/index.ts b/packages/remix-dev/index.ts index 7876a895d8b..ba236fd8bc6 100644 --- a/packages/remix-dev/index.ts +++ b/packages/remix-dev/index.ts @@ -1,6 +1,6 @@ import "./modules"; -export type { AppConfig } from "./config"; +export type { AppConfig, RemixConfig as ResolvedRemixConfig } from "./config"; export * as cli from "./cli/index"; export { createApp } from "./cli/create"; From ae16e9296ec92232888d8736b9edd9675642535d Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 08:11:52 -0800 Subject: [PATCH 02/10] make types more generic initially --- packages/remix-dev/config.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 0410cd2ab03..c7cd1f90f4b 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -158,14 +158,7 @@ export interface AppConfig { | string[] | (() => Promise | string | string[]); - features?: { - /** - * A flag to opt-in to the updated route `meta` API for v2. - * - * @see https://github.com/remix-run/remix/discussions/4462 - */ - v2_meta?: boolean; - }; + features?: { [key: string]: unknown }; // TODO: This type will change when we start adding features } /** @@ -285,14 +278,7 @@ export interface RemixConfig { */ tsconfigPath: string | undefined; - features: { - /** - * A flag to opt-in to the updated route `meta` API for v2. - * - * @see https://github.com/remix-run/remix/discussions/4462 - */ - v2_meta: boolean; - }; + features: { [key: string]: unknown }; // TODO: This type will change when we start adding features } /** From c04606564804db62de287375ef28245b37ca843e Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 08:14:48 -0800 Subject: [PATCH 03/10] create test fixture --- .../__tests__/fixtures/v2-meta/.gitignore | 6 ++ .../__tests__/fixtures/v2-meta/README.md | 53 ++++++++++++++++++ .../fixtures/v2-meta/app/entry.client.tsx | 4 ++ .../fixtures/v2-meta/app/entry.server.tsx | 22 ++++++++ .../__tests__/fixtures/v2-meta/app/root.tsx | 34 +++++++++++ .../__tests__/fixtures/v2-meta/app/utils.ts | 1 + .../__tests__/fixtures/v2-meta/package.json | 15 +++++ .../fixtures/v2-meta/public/favicon.ico | Bin 0 -> 16958 bytes .../fixtures/v2-meta/remix.config.js | 11 ++++ .../__tests__/fixtures/v2-meta/remix.env.d.ts | 2 + .../fixtures/v2-meta/remix.init/index.js | 1 + .../__tests__/fixtures/v2-meta/tsconfig.json | 22 ++++++++ 12 files changed, 171 insertions(+) create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/README.md create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/package.json create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/public/favicon.ico create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js create mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore b/packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore new file mode 100644 index 00000000000..3f7bf98da3e --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore @@ -0,0 +1,6 @@ +node_modules + +/.cache +/build +/public/build +.env diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/README.md b/packages/remix-dev/__tests__/fixtures/v2-meta/README.md new file mode 100644 index 00000000000..9659e785e03 --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/README.md @@ -0,0 +1,53 @@ +# Welcome to Remix! + +- [Remix Docs](https://remix.run/docs) + +## Development + +From your terminal: + +```sh +npm run dev +``` + +This starts your app in development mode, rebuilding assets on file changes. + +## Deployment + +First, build your app for production: + +```sh +npm run build +``` + +Then run the app in production mode: + +```sh +npm start +``` + +Now you'll need to pick a host to deploy it to. + +### DIY + +If you're familiar with deploying node applications, the built-in Remix app server is production-ready. + +Make sure to deploy the output of `remix build` + +- `build/` +- `public/build/` + +### Using a Template + +When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server. + +```sh +cd .. +# create a new project, and pick a pre-configured host +npx create-remix@latest +cd my-new-remix-app +# remove the new project's app (not the old one!) +rm -rf app +# copy your app over +cp -R ../my-old-remix-app/app app +``` diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx b/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx new file mode 100644 index 00000000000..3eec1fd0a02 --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx @@ -0,0 +1,4 @@ +import { RemixBrowser } from "@remix-run/react"; +import { hydrate } from "react-dom"; + +hydrate(, document); diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx b/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx new file mode 100644 index 00000000000..068773556ca --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx @@ -0,0 +1,22 @@ +import type { EntryContext } from "@remix-run/node"; +import { RemixServer } from "@remix-run/react"; +import { renderToString } from "react-dom/server"; + +export default function handleRequest( + request: Request, + responseStatusCode: number, + responseHeaders: Headers, + remixContext: EntryContext +) { + // eslint-disable-next-line testing-library/render-result-naming-convention + let markup = renderToString( + + ); + + responseHeaders.set("Content-Type", "text/html"); + + return new Response("" + markup, { + status: responseStatusCode, + headers: responseHeaders, + }); +} diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx b/packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx new file mode 100644 index 00000000000..f4d9d855a7b --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx @@ -0,0 +1,34 @@ +import { + Links, + LiveReload, + Meta, + Outlet, + Scripts, + ScrollRestoration, +} from "@remix-run/react"; + +export function meta() { + return [ + { title: "Remix" }, + { charSet: "utf-8" }, + { name: "description", content: "Center-stack goodness" }, + { property: "og:description", content: "Center-stack goodness" }, + ]; +} + +export default function App() { + return ( + + + + + + + + + + + + + ); +} diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts b/packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts new file mode 100644 index 00000000000..304bb4e19c1 --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts @@ -0,0 +1 @@ +// this is a utility file diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/package.json b/packages/remix-dev/__tests__/fixtures/v2-meta/package.json new file mode 100644 index 00000000000..3ab75a6c52e --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/package.json @@ -0,0 +1,15 @@ +{ + "name": "remix-template-remix", + "private": true, + "sideEffects": false, + "scripts": { + "build": "remix build", + "dev": "remix dev", + "start": "remix-serve build" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=14" + } +} diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/public/favicon.ico b/packages/remix-dev/__tests__/fixtures/v2-meta/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8830cf6821b354114848e6354889b8ecf6d2bc61 GIT binary patch literal 16958 zcmeI3+jCXb9mnJN2h^uNlXH@jlam{_a8F3W{T}Wih>9YJpaf7TUbu)A5fv|h7OMfR zR;q$lr&D!wv|c)`wcw1?>4QT1(&|jdsrI2h`Rn)dTW5t$8pz=s3_5L?#oBxAowe8R z_WfPfN?F+@`q$D@rvC?(W!uWieppskmQ~YG*>*L?{img@tWpnYXZslxeh#TSUS3{q z1Ju6JcfQSbQuORq69@YK(X-3c9vC2c2a2z~zw=F=50@pm0PUiCAm!bAT?2jpM`(^b zC|2&Ngngt^<>oCv#?P(AZ`5_84x#QBPulix)TpkIAUp=(KgGo4CVS~Sxt zVoR4>r5g9%bDh7hi0|v$={zr>CHd`?-l4^Ld(Z9PNz9piFY+llUw_x4ou7Vf-q%$g z)&)J4>6Ft~RZ(uV>dJD|`nxI1^x{X@Z5S<=vf;V3w_(*O-7}W<=e$=}CB9_R;)m9)d7`d_xx+nl^Bg|%ew=?uoKO8w zeQU7h;~8s!@9-k>7Cx}1SDQ7m(&miH zs8!l*wOJ!GHbdh)pD--&W3+w`9YJ=;m^FtMY=`mTq8pyV!-@L6smwp3(q?G>=_4v^ zn(ikLue7!y70#2uhqUVpb7fp!=xu2{aM^1P^pts#+feZv8d~)2sf`sjXLQCEj;pdI z%~f`JOO;*KnziMv^i_6+?mL?^wrE_&=IT9o1i!}Sd4Sx4O@w~1bi1)8(sXvYR-1?7~Zr<=SJ1Cw!i~yfi=4h6o3O~(-Sb2Ilwq%g$+V` z>(C&N1!FV5rWF&iwt8~b)=jIn4b!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`(6LA>F$~{{xE8-3Wzyfe`+Lsce(?uj{k@lb97YTJt#>l*Z&LyKX@zjmu?UJC9w~;|NsB{%7G}y*uNDBxirfC EKbET!0{{R3 literal 0 HcmV?d00001 diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js new file mode 100644 index 00000000000..472bdbd8447 --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js @@ -0,0 +1,11 @@ +/** @type {import('@remix-run/dev').AppConfig} */ +module.exports = { + ignoredRouteFiles: ["**/.*"], + features: { + v2_meta: true, + }, + // appDirectory: "app", + // assetsBuildDirectory: "public/build", + // serverBuildPath: "build/index.js", + // publicPath: "/build/", +}; diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts new file mode 100644 index 00000000000..72e2affe311 --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js new file mode 100644 index 00000000000..d3dd71ce24c --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js @@ -0,0 +1 @@ +// this is the init file diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json b/packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json new file mode 100644 index 00000000000..7d43861a8fa --- /dev/null +++ b/packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json @@ -0,0 +1,22 @@ +{ + "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], + "compilerOptions": { + "allowJs": true, + "forceConsistentCasingInFileNames": true, + "lib": ["DOM", "DOM.Iterable", "ES2019"], + "isolatedModules": true, + "esModuleInterop": true, + "jsx": "react-jsx", + "moduleResolution": "node", + "resolveJsonModule": true, + "target": "ES2019", + "strict": true, + "baseUrl": ".", + "paths": { + "~/*": ["./app/*"] + }, + + // Remix takes care of building everything in `remix build`. + "noEmit": true + } +} From 43f5e5d498d13c177c541c8d2c893ab3e4cc6e11 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 08:23:13 -0800 Subject: [PATCH 04/10] add test for config features --- packages/remix-dev/__tests__/readConfig-test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/remix-dev/__tests__/readConfig-test.ts b/packages/remix-dev/__tests__/readConfig-test.ts index 5f14c9f4f44..b28ef2b7cd0 100644 --- a/packages/remix-dev/__tests__/readConfig-test.ts +++ b/packages/remix-dev/__tests__/readConfig-test.ts @@ -22,6 +22,9 @@ describe("readConfig", () => { assetsBuildDirectory: expect.any(String), relativeAssetsBuildDirectory: expect.any(String), tsconfigPath: expect.any(String), + features: { + v2_meta: expect.any(Boolean), + }, }, ` Object { @@ -32,6 +35,9 @@ describe("readConfig", () => { "devServerPort": Any, "entryClientFile": "entry.client.tsx", "entryServerFile": "entry.server.tsx", + "features": Object { + "v2_meta": Any, + }, "mdx": undefined, "publicPath": "/build/", "relativeAssetsBuildDirectory": Any, @@ -62,4 +68,13 @@ describe("readConfig", () => { let newConfig = await readConfig(remixRoot); expect(newConfig.devServerPort).toBe(config.devServerPort); }); + + it("includes feature flags", async () => { + let newConfig = await readConfig(remixRoot); + expect(newConfig.features).toEqual( + expect.objectContaining({ + v2_meta: expect.any(Boolean), + }) + ); + }); }); From 61ed9e0ff10b2baaefebd80ce1d1f09ee81f28d5 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 08:25:16 -0800 Subject: [PATCH 05/10] rm meta test fixture --- .../__tests__/fixtures/v2-meta/.gitignore | 6 -- .../__tests__/fixtures/v2-meta/README.md | 53 ------------------ .../fixtures/v2-meta/app/entry.client.tsx | 4 -- .../fixtures/v2-meta/app/entry.server.tsx | 22 -------- .../__tests__/fixtures/v2-meta/app/root.tsx | 34 ----------- .../__tests__/fixtures/v2-meta/app/utils.ts | 1 - .../__tests__/fixtures/v2-meta/package.json | 15 ----- .../fixtures/v2-meta/public/favicon.ico | Bin 16958 -> 0 bytes .../fixtures/v2-meta/remix.config.js | 11 ---- .../__tests__/fixtures/v2-meta/remix.env.d.ts | 2 - .../fixtures/v2-meta/remix.init/index.js | 1 - .../__tests__/fixtures/v2-meta/tsconfig.json | 22 -------- 12 files changed, 171 deletions(-) delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/README.md delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/package.json delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/public/favicon.ico delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js delete mode 100644 packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore b/packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore deleted file mode 100644 index 3f7bf98da3e..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules - -/.cache -/build -/public/build -.env diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/README.md b/packages/remix-dev/__tests__/fixtures/v2-meta/README.md deleted file mode 100644 index 9659e785e03..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# Welcome to Remix! - -- [Remix Docs](https://remix.run/docs) - -## Development - -From your terminal: - -```sh -npm run dev -``` - -This starts your app in development mode, rebuilding assets on file changes. - -## Deployment - -First, build your app for production: - -```sh -npm run build -``` - -Then run the app in production mode: - -```sh -npm start -``` - -Now you'll need to pick a host to deploy it to. - -### DIY - -If you're familiar with deploying node applications, the built-in Remix app server is production-ready. - -Make sure to deploy the output of `remix build` - -- `build/` -- `public/build/` - -### Using a Template - -When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server. - -```sh -cd .. -# create a new project, and pick a pre-configured host -npx create-remix@latest -cd my-new-remix-app -# remove the new project's app (not the old one!) -rm -rf app -# copy your app over -cp -R ../my-old-remix-app/app app -``` diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx b/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx deleted file mode 100644 index 3eec1fd0a02..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.client.tsx +++ /dev/null @@ -1,4 +0,0 @@ -import { RemixBrowser } from "@remix-run/react"; -import { hydrate } from "react-dom"; - -hydrate(, document); diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx b/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx deleted file mode 100644 index 068773556ca..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/app/entry.server.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import type { EntryContext } from "@remix-run/node"; -import { RemixServer } from "@remix-run/react"; -import { renderToString } from "react-dom/server"; - -export default function handleRequest( - request: Request, - responseStatusCode: number, - responseHeaders: Headers, - remixContext: EntryContext -) { - // eslint-disable-next-line testing-library/render-result-naming-convention - let markup = renderToString( - - ); - - responseHeaders.set("Content-Type", "text/html"); - - return new Response("" + markup, { - status: responseStatusCode, - headers: responseHeaders, - }); -} diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx b/packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx deleted file mode 100644 index f4d9d855a7b..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/app/root.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { - Links, - LiveReload, - Meta, - Outlet, - Scripts, - ScrollRestoration, -} from "@remix-run/react"; - -export function meta() { - return [ - { title: "Remix" }, - { charSet: "utf-8" }, - { name: "description", content: "Center-stack goodness" }, - { property: "og:description", content: "Center-stack goodness" }, - ]; -} - -export default function App() { - return ( - - - - - - - - - - - - - ); -} diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts b/packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts deleted file mode 100644 index 304bb4e19c1..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/app/utils.ts +++ /dev/null @@ -1 +0,0 @@ -// this is a utility file diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/package.json b/packages/remix-dev/__tests__/fixtures/v2-meta/package.json deleted file mode 100644 index 3ab75a6c52e..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "remix-template-remix", - "private": true, - "sideEffects": false, - "scripts": { - "build": "remix build", - "dev": "remix dev", - "start": "remix-serve build" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=14" - } -} diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/public/favicon.ico b/packages/remix-dev/__tests__/fixtures/v2-meta/public/favicon.ico deleted file mode 100644 index 8830cf6821b354114848e6354889b8ecf6d2bc61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16958 zcmeI3+jCXb9mnJN2h^uNlXH@jlam{_a8F3W{T}Wih>9YJpaf7TUbu)A5fv|h7OMfR zR;q$lr&D!wv|c)`wcw1?>4QT1(&|jdsrI2h`R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%5Js)tQ)|>pTT@1ojd+F9Gey zg`B)zm`|Mo%tH31s4=<+`Pu|B3orXwNyIcNN>;fBkIj^X8P}RXhF= zXQK1u5RLN7k#_Q(KznJrALtMM13!vhfr025ar?@-%{l|uWt@NEd<$~n>RQL{ z+o;->n)+~0tt(u|o_9h!T`%M8%)w2awpV9b*xz9Pl-daUJm3y-HT%xg`^mFd6LBeL z!0~s;zEr)Bn9x)I(wx`;JVwvRcc^io2XX(Nn3vr3dgbrr@YJ?K3w18P*52^ieBCQP z=Up1V$N2~5ppJHRTeY8QfM(7Yv&RG7oWJAyv?c3g(29)P)u;_o&w|&)HGDIinXT~p z3;S|e$=&Tek9Wn!`cdY+d-w@o`37}x{(hl>ykB|%9yB$CGdIcl7Z?d&lJ%}QHck77 zJPR%C+s2w1_Dl_pxu6$Zi!`HmoD-%7OD@7%lKLL^Ixd9VlRSW*o&$^iQ2z+}hTgH) z#91TO#+jH<`w4L}XWOt(`gqM*uTUcky`O(mEyU|4dJoy6*UZJ7%*}ajuos%~>&P2j zk23f5<@GeV?(?`l=ih+D8t`d72xrUjv0wsg;%s1@*2p?TQ;n2$pV7h?_T%sL>iL@w zZ{lmc<|B7!e&o!zs6RW+u8+aDyUdG>ZS(v&rT$QVymB7sEC@VsK1dg^3F@K90-wYB zX!we79qx`(6LA>F$~{{xE8-3Wzyfe`+Lsce(?uj{k@lb97YTJt#>l*Z&LyKX@zjmu?UJC9w~;|NsB{%7G}y*uNDBxirfC EKbET!0{{R3 diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js deleted file mode 100644 index 472bdbd8447..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.config.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @type {import('@remix-run/dev').AppConfig} */ -module.exports = { - ignoredRouteFiles: ["**/.*"], - features: { - v2_meta: true, - }, - // appDirectory: "app", - // assetsBuildDirectory: "public/build", - // serverBuildPath: "build/index.js", - // publicPath: "/build/", -}; diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts deleted file mode 100644 index 72e2affe311..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.env.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -/// -/// diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js b/packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js deleted file mode 100644 index d3dd71ce24c..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/remix.init/index.js +++ /dev/null @@ -1 +0,0 @@ -// this is the init file diff --git a/packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json b/packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json deleted file mode 100644 index 7d43861a8fa..00000000000 --- a/packages/remix-dev/__tests__/fixtures/v2-meta/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"], - "compilerOptions": { - "allowJs": true, - "forceConsistentCasingInFileNames": true, - "lib": ["DOM", "DOM.Iterable", "ES2019"], - "isolatedModules": true, - "esModuleInterop": true, - "jsx": "react-jsx", - "moduleResolution": "node", - "resolveJsonModule": true, - "target": "ES2019", - "strict": true, - "baseUrl": ".", - "paths": { - "~/*": ["./app/*"] - }, - - // Remix takes care of building everything in `remix build`. - "noEmit": true - } -} From b58589c08b5f4cb0c67c89a5eb9a33955bfdc4eb Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 09:09:40 -0800 Subject: [PATCH 06/10] rm extra unit test --- packages/remix-dev/__tests__/readConfig-test.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/remix-dev/__tests__/readConfig-test.ts b/packages/remix-dev/__tests__/readConfig-test.ts index b28ef2b7cd0..120505cd204 100644 --- a/packages/remix-dev/__tests__/readConfig-test.ts +++ b/packages/remix-dev/__tests__/readConfig-test.ts @@ -68,13 +68,4 @@ describe("readConfig", () => { let newConfig = await readConfig(remixRoot); expect(newConfig.devServerPort).toBe(config.devServerPort); }); - - it("includes feature flags", async () => { - let newConfig = await readConfig(remixRoot); - expect(newConfig.features).toEqual( - expect.objectContaining({ - v2_meta: expect.any(Boolean), - }) - ); - }); }); From eb19995fef34a429dc5f4780ca6a2634b807191f Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 15:11:02 -0800 Subject: [PATCH 07/10] put features on context --- packages/remix-dev/compiler/compileBrowser.ts | 3 --- packages/remix-dev/compiler/compilerServer.ts | 3 --- .../remix-dev/compiler/plugins/serverEntryModulePlugin.ts | 1 + packages/remix-react/components.tsx | 4 ++++ packages/remix-react/entry.ts | 3 +++ packages/remix-server-runtime/build.ts | 3 +++ packages/remix-server-runtime/entry.ts | 3 +++ packages/remix-server-runtime/server.ts | 1 + 8 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/remix-dev/compiler/compileBrowser.ts b/packages/remix-dev/compiler/compileBrowser.ts index 2ffdcad6545..338dd8a7dd8 100644 --- a/packages/remix-dev/compiler/compileBrowser.ts +++ b/packages/remix-dev/compiler/compileBrowser.ts @@ -107,9 +107,6 @@ const createEsbuildConfig = ( "process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify( config.devServerPort ), - "process.env.REMIX_CONFIG_FEATURES_V2_META": JSON.stringify( - config.features.v2_meta - ), }, jsx: "automatic", jsxDev: options.mode !== "production", diff --git a/packages/remix-dev/compiler/compilerServer.ts b/packages/remix-dev/compiler/compilerServer.ts index 9bbbf40a790..fa5289b61e9 100644 --- a/packages/remix-dev/compiler/compilerServer.ts +++ b/packages/remix-dev/compiler/compilerServer.ts @@ -108,9 +108,6 @@ const createEsbuildConfig = ( "process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify( config.devServerPort ), - "process.env.REMIX_CONFIG_FEATURES_V2_META": JSON.stringify( - config.features.v2_meta - ), }, jsx: "automatic", jsxDev: options.mode !== "production", diff --git a/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts b/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts index 941c1a90b81..23db3dacf43 100644 --- a/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts +++ b/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts @@ -45,6 +45,7 @@ ${Object.keys(config.routes) export const assetsBuildDirectory = ${JSON.stringify( config.relativeAssetsBuildDirectory )}; + export const features = ${JSON.stringify(config.features)}; export const publicPath = ${JSON.stringify(config.publicPath)}; export const entry = { module: entryServer }; export const routes = { diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx index f499bcf8717..c2a95fbd1f1 100644 --- a/packages/remix-react/components.tsx +++ b/packages/remix-react/components.tsx @@ -71,6 +71,9 @@ interface RemixEntryContextType { serverHandoffString?: string; clientRoutes: ClientRoute[]; transitionManager: ReturnType; + features: { + v2_meta: boolean; + }; } export const RemixEntryContext = React.createContext< @@ -195,6 +198,7 @@ export function RemixEntry({ routeData: loaderData, actionData, transitionManager, + features: entryContext.features, }} > ; serverHandoffString?: string; + features: { + v2_meta: boolean; + }; } export interface AssetsManifest { diff --git a/packages/remix-server-runtime/server.ts b/packages/remix-server-runtime/server.ts index edc3311f696..8cf16399bfd 100644 --- a/packages/remix-server-runtime/server.ts +++ b/packages/remix-server-runtime/server.ts @@ -577,6 +577,7 @@ async function handleDocumentRequest({ appState: appState, matches: entryMatches, routeData, + features: build.features, }; let entryContext: EntryContext = { From 1f2034fce12e22476fd8b3c30ba09b1281acdb42 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 15:21:23 -0800 Subject: [PATCH 08/10] reorganize types --- packages/remix-dev/config.ts | 8 ++++++-- packages/remix-react/components.tsx | 6 ++---- packages/remix-react/entry.ts | 8 +++++--- packages/remix-server-runtime/build.ts | 6 ++---- packages/remix-server-runtime/entry.ts | 8 +++++--- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index c7cd1f90f4b..f2224670349 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -31,6 +31,10 @@ export type ServerBuildTarget = export type ServerModuleFormat = "esm" | "cjs"; export type ServerPlatform = "node" | "neutral"; +interface ConfigFeatures { + v2_meta: boolean; +} + /** * The user-provided config in `remix.config.js`. */ @@ -158,7 +162,7 @@ export interface AppConfig { | string[] | (() => Promise | string | string[]); - features?: { [key: string]: unknown }; // TODO: This type will change when we start adding features + features?: Partial; } /** @@ -278,7 +282,7 @@ export interface RemixConfig { */ tsconfigPath: string | undefined; - features: { [key: string]: unknown }; // TODO: This type will change when we start adding features + features: ConfigFeatures; } /** diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx index c2a95fbd1f1..f7ec991b6e4 100644 --- a/packages/remix-react/components.tsx +++ b/packages/remix-react/components.tsx @@ -24,7 +24,7 @@ import { createPath } from "history"; import type { SerializeFrom } from "@remix-run/server-runtime"; import type { AppData, FormEncType, FormMethod } from "./data"; -import type { EntryContext, AssetsManifest } from "./entry"; +import type { AssetsManifest, ConfigFeatures, EntryContext } from "./entry"; import type { AppState, SerializedError } from "./errors"; import { RemixRootDefaultErrorBoundary, @@ -71,9 +71,7 @@ interface RemixEntryContextType { serverHandoffString?: string; clientRoutes: ClientRoute[]; transitionManager: ReturnType; - features: { - v2_meta: boolean; - }; + features: ConfigFeatures; } export const RemixEntryContext = React.createContext< diff --git a/packages/remix-react/entry.ts b/packages/remix-react/entry.ts index 118fc258286..b6565d9a1f8 100644 --- a/packages/remix-react/entry.ts +++ b/packages/remix-react/entry.ts @@ -12,9 +12,11 @@ export interface EntryContext { actionData?: RouteData; routeModules: RouteModules; serverHandoffString?: string; - features: { - v2_meta: boolean; - }; + features: ConfigFeatures; +} + +export interface ConfigFeatures { + v2_meta: boolean; } export interface AssetsManifest { diff --git a/packages/remix-server-runtime/build.ts b/packages/remix-server-runtime/build.ts index 563a53a2ebd..b861dcf0875 100644 --- a/packages/remix-server-runtime/build.ts +++ b/packages/remix-server-runtime/build.ts @@ -1,5 +1,5 @@ import type { DataFunctionArgs } from "./routeModules"; -import type { EntryContext, AssetsManifest } from "./entry"; +import type { AssetsManifest, ConfigFeatures, EntryContext } from "./entry"; import type { ServerRouteManifest } from "./routes"; /** @@ -13,9 +13,7 @@ export interface ServerBuild { assets: AssetsManifest; publicPath: string; assetsBuildDirectory: string; - features: { - v2_meta: boolean; - }; + features: ConfigFeatures; } export interface HandleDocumentRequestFunction { diff --git a/packages/remix-server-runtime/entry.ts b/packages/remix-server-runtime/entry.ts index eb8316c51f4..93757781824 100644 --- a/packages/remix-server-runtime/entry.ts +++ b/packages/remix-server-runtime/entry.ts @@ -17,9 +17,11 @@ export interface EntryContext { actionData?: RouteData; routeModules: RouteModules; serverHandoffString?: string; - features: { - v2_meta: boolean; - }; + features: ConfigFeatures; +} + +export interface ConfigFeatures { + v2_meta: boolean; } export interface AssetsManifest { From 26b7c6687c0c9298686580fe12f4bde1fa53ddef Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Thu, 10 Nov 2022 18:52:22 -0800 Subject: [PATCH 09/10] features > future --- packages/remix-dev/__tests__/readConfig-test.ts | 4 ++-- .../compiler/plugins/serverEntryModulePlugin.ts | 2 +- packages/remix-dev/config.ts | 12 ++++++------ packages/remix-react/components.tsx | 6 +++--- packages/remix-react/entry.ts | 4 ++-- packages/remix-server-runtime/build.ts | 4 ++-- packages/remix-server-runtime/entry.ts | 4 ++-- packages/remix-server-runtime/server.ts | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/remix-dev/__tests__/readConfig-test.ts b/packages/remix-dev/__tests__/readConfig-test.ts index 120505cd204..a6cdea1f44e 100644 --- a/packages/remix-dev/__tests__/readConfig-test.ts +++ b/packages/remix-dev/__tests__/readConfig-test.ts @@ -22,7 +22,7 @@ describe("readConfig", () => { assetsBuildDirectory: expect.any(String), relativeAssetsBuildDirectory: expect.any(String), tsconfigPath: expect.any(String), - features: { + future: { v2_meta: expect.any(Boolean), }, }, @@ -35,7 +35,7 @@ describe("readConfig", () => { "devServerPort": Any, "entryClientFile": "entry.client.tsx", "entryServerFile": "entry.server.tsx", - "features": Object { + "future": Object { "v2_meta": Any, }, "mdx": undefined, diff --git a/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts b/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts index 23db3dacf43..56955b4ce4f 100644 --- a/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts +++ b/packages/remix-dev/compiler/plugins/serverEntryModulePlugin.ts @@ -45,7 +45,7 @@ ${Object.keys(config.routes) export const assetsBuildDirectory = ${JSON.stringify( config.relativeAssetsBuildDirectory )}; - export const features = ${JSON.stringify(config.features)}; + export const future = ${JSON.stringify(config.future)}; export const publicPath = ${JSON.stringify(config.publicPath)}; export const entry = { module: entryServer }; export const routes = { diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index f2224670349..1b126731d46 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -31,7 +31,7 @@ export type ServerBuildTarget = export type ServerModuleFormat = "esm" | "cjs"; export type ServerPlatform = "node" | "neutral"; -interface ConfigFeatures { +interface ConfigFuture { v2_meta: boolean; } @@ -162,7 +162,7 @@ export interface AppConfig { | string[] | (() => Promise | string | string[]); - features?: Partial; + future?: Partial; } /** @@ -282,7 +282,7 @@ export interface RemixConfig { */ tsconfigPath: string | undefined; - features: ConfigFeatures; + future: ConfigFuture; } /** @@ -480,8 +480,8 @@ export async function readConfig( writeConfigDefaults(tsconfigPath); } - let features = { - v2_meta: appConfig.features?.v2_meta === true, + let future = { + v2_meta: appConfig.future?.v2_meta === true, }; return { @@ -507,7 +507,7 @@ export async function readConfig( mdx, watchPaths, tsconfigPath, - features, + future, }; } diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx index f7ec991b6e4..63c959b2873 100644 --- a/packages/remix-react/components.tsx +++ b/packages/remix-react/components.tsx @@ -24,7 +24,7 @@ import { createPath } from "history"; import type { SerializeFrom } from "@remix-run/server-runtime"; import type { AppData, FormEncType, FormMethod } from "./data"; -import type { AssetsManifest, ConfigFeatures, EntryContext } from "./entry"; +import type { AssetsManifest, ConfigFuture, EntryContext } from "./entry"; import type { AppState, SerializedError } from "./errors"; import { RemixRootDefaultErrorBoundary, @@ -71,7 +71,7 @@ interface RemixEntryContextType { serverHandoffString?: string; clientRoutes: ClientRoute[]; transitionManager: ReturnType; - features: ConfigFeatures; + future: ConfigFuture; } export const RemixEntryContext = React.createContext< @@ -196,7 +196,7 @@ export function RemixEntry({ routeData: loaderData, actionData, transitionManager, - features: entryContext.features, + future: entryContext.future, }} > ; serverHandoffString?: string; - features: ConfigFeatures; + future: ConfigFuture; } -export interface ConfigFeatures { +export interface ConfigFuture { v2_meta: boolean; } diff --git a/packages/remix-server-runtime/server.ts b/packages/remix-server-runtime/server.ts index 8cf16399bfd..21eca52ad8a 100644 --- a/packages/remix-server-runtime/server.ts +++ b/packages/remix-server-runtime/server.ts @@ -577,7 +577,7 @@ async function handleDocumentRequest({ appState: appState, matches: entryMatches, routeData, - features: build.features, + future: build.future, }; let entryContext: EntryContext = { From 832e8526816e3820181406ee6fbb03556bbab043 Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Fri, 11 Nov 2022 07:25:46 -0800 Subject: [PATCH 10/10] rename interface --- packages/remix-dev/config.ts | 6 +++--- packages/remix-react/components.tsx | 4 ++-- packages/remix-react/entry.ts | 4 ++-- packages/remix-server-runtime/build.ts | 4 ++-- packages/remix-server-runtime/entry.ts | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 1b126731d46..5c8a67ec29f 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -31,7 +31,7 @@ export type ServerBuildTarget = export type ServerModuleFormat = "esm" | "cjs"; export type ServerPlatform = "node" | "neutral"; -interface ConfigFuture { +interface FutureConfig { v2_meta: boolean; } @@ -162,7 +162,7 @@ export interface AppConfig { | string[] | (() => Promise | string | string[]); - future?: Partial; + future?: Partial; } /** @@ -282,7 +282,7 @@ export interface RemixConfig { */ tsconfigPath: string | undefined; - future: ConfigFuture; + future: FutureConfig; } /** diff --git a/packages/remix-react/components.tsx b/packages/remix-react/components.tsx index 63c959b2873..12a1f5d3a45 100644 --- a/packages/remix-react/components.tsx +++ b/packages/remix-react/components.tsx @@ -24,7 +24,7 @@ import { createPath } from "history"; import type { SerializeFrom } from "@remix-run/server-runtime"; import type { AppData, FormEncType, FormMethod } from "./data"; -import type { AssetsManifest, ConfigFuture, EntryContext } from "./entry"; +import type { AssetsManifest, EntryContext, FutureConfig } from "./entry"; import type { AppState, SerializedError } from "./errors"; import { RemixRootDefaultErrorBoundary, @@ -71,7 +71,7 @@ interface RemixEntryContextType { serverHandoffString?: string; clientRoutes: ClientRoute[]; transitionManager: ReturnType; - future: ConfigFuture; + future: FutureConfig; } export const RemixEntryContext = React.createContext< diff --git a/packages/remix-react/entry.ts b/packages/remix-react/entry.ts index af80a7b3696..e4cbb36b2fb 100644 --- a/packages/remix-react/entry.ts +++ b/packages/remix-react/entry.ts @@ -12,10 +12,10 @@ export interface EntryContext { actionData?: RouteData; routeModules: RouteModules; serverHandoffString?: string; - future: ConfigFuture; + future: FutureConfig; } -export interface ConfigFuture { +export interface FutureConfig { v2_meta: boolean; } diff --git a/packages/remix-server-runtime/build.ts b/packages/remix-server-runtime/build.ts index 60a35ce0878..9c01f8258cb 100644 --- a/packages/remix-server-runtime/build.ts +++ b/packages/remix-server-runtime/build.ts @@ -1,5 +1,5 @@ import type { DataFunctionArgs } from "./routeModules"; -import type { AssetsManifest, ConfigFuture, EntryContext } from "./entry"; +import type { AssetsManifest, EntryContext, FutureConfig } from "./entry"; import type { ServerRouteManifest } from "./routes"; /** @@ -13,7 +13,7 @@ export interface ServerBuild { assets: AssetsManifest; publicPath: string; assetsBuildDirectory: string; - future: ConfigFuture; + future: FutureConfig; } export interface HandleDocumentRequestFunction { diff --git a/packages/remix-server-runtime/entry.ts b/packages/remix-server-runtime/entry.ts index b69a10a536a..3986e6a0436 100644 --- a/packages/remix-server-runtime/entry.ts +++ b/packages/remix-server-runtime/entry.ts @@ -17,10 +17,10 @@ export interface EntryContext { actionData?: RouteData; routeModules: RouteModules; serverHandoffString?: string; - future: ConfigFuture; + future: FutureConfig; } -export interface ConfigFuture { +export interface FutureConfig { v2_meta: boolean; }