From 2abe0d085ff44f42c84c7e2ca210dff8466ab2b0 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 14 Mar 2023 11:01:57 -0400 Subject: [PATCH 1/4] Revert "feat(remix-dev): add warning when `future.v2_routeConvention` is not enabled (#5606)" This reverts commit 712732f4fce0fdc39c42892c7b622008d6a3ec02. --- integration/flat-routes-test.ts | 47 --------------------- integration/tsconfig.json | 1 - packages/remix-dev/__tests__/create-test.ts | 5 +-- packages/remix-dev/config.ts | 15 ++----- 4 files changed, 5 insertions(+), 63 deletions(-) diff --git a/integration/flat-routes-test.ts b/integration/flat-routes-test.ts index 0b4b6b6aab6..9254ca16ee5 100644 --- a/integration/flat-routes-test.ts +++ b/integration/flat-routes-test.ts @@ -5,7 +5,6 @@ import { PlaywrightFixture } from "./helpers/playwright-fixture"; import type { Fixture, AppFixture } from "./helpers/create-fixture"; import { createFixtureProject } from "./helpers/create-fixture"; import { createAppFixture, createFixture, js } from "./helpers/create-fixture"; -import { flatRoutesWarning } from "../packages/remix-dev/config"; let fixture: Fixture; let appFixture: AppFixture; @@ -148,52 +147,6 @@ test.describe("flat routes", () => { } }); -test.describe("warns when v1 routesConvention is used", () => { - let buildStdio = new PassThrough(); - let buildOutput: string; - - let originalConsoleLog = console.log; - let originalConsoleWarn = console.warn; - let originalConsoleError = console.error; - - test.beforeAll(async () => { - console.log = () => {}; - console.warn = () => {}; - console.error = () => {}; - await createFixtureProject({ - buildStdio, - future: { v2_routeConvention: false }, - files: { - "routes/index.tsx": js` - export default function () { - return

routes/index

; - } - `, - }, - }); - - let chunks: Buffer[] = []; - buildOutput = await new Promise((resolve, reject) => { - buildStdio.on("data", (chunk) => chunks.push(Buffer.from(chunk))); - buildStdio.on("error", (err) => reject(err)); - buildStdio.on("end", () => - resolve(Buffer.concat(chunks).toString("utf8")) - ); - }); - }); - - test.afterAll(() => { - console.log = originalConsoleLog; - console.warn = originalConsoleWarn; - console.error = originalConsoleError; - }); - - test("warns about conflicting routes", () => { - console.log(buildOutput); - expect(buildOutput).toContain(flatRoutesWarning); - }); -}); - test.describe("emits warnings for route conflicts", async () => { let buildStdio = new PassThrough(); let buildOutput: string; diff --git a/integration/tsconfig.json b/integration/tsconfig.json index d2215944147..b8fd6c97ac7 100644 --- a/integration/tsconfig.json +++ b/integration/tsconfig.json @@ -17,7 +17,6 @@ "rootDir": "." }, "references": [ - { "path": "../packages/remix-dev" }, { "path": "../packages/remix-express" }, { "path": "../packages/remix-react" }, { "path": "../packages/remix-server-runtime" } diff --git a/packages/remix-dev/__tests__/create-test.ts b/packages/remix-dev/__tests__/create-test.ts index 4508ac91907..4a0fbed9768 100644 --- a/packages/remix-dev/__tests__/create-test.ts +++ b/packages/remix-dev/__tests__/create-test.ts @@ -8,7 +8,6 @@ import stripAnsi from "strip-ansi"; import { run } from "../cli/run"; import { server } from "./msw"; -import { flatRoutesWarning } from "../config"; beforeAll(() => server.listen({ onUnhandledRequest: "error" })); afterAll(() => server.close()); @@ -348,9 +347,7 @@ describe("the create command", () => { "--no-typescript", ]); expect(output.trim()).toBe( - flatRoutesWarning + - "\n\n" + - getOptOutOfInstallMessage() + + getOptOutOfInstallMessage() + "\n\n" + getSuccessMessage(path.join("", "template-to-js")) ); diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 8686777438a..4c6f161eb86 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -560,14 +560,9 @@ export async function readConfig( root: { path: "", id: "root", file: rootRouteFile }, }; - let routesConvention: typeof flatRoutes; - - if (appConfig.future?.v2_routeConvention) { - routesConvention = flatRoutes; - } else { - warnOnce(flatRoutesWarning, "v2_routeConvention"); - routesConvention = defineConventionalRoutes; - } + let routesConvention = appConfig.future?.v2_routeConvention + ? flatRoutes + : defineConventionalRoutes; if (fse.existsSync(path.resolve(appDirectory, "routes"))) { let conventionalRoutes = routesConvention( @@ -731,6 +726,4 @@ let listFormat = new Intl.ListFormat("en", { type: "conjunction", }); -export let serverBuildTargetWarning = `⚠️ DEPRECATED: The "serverBuildTarget" config option is deprecated. Use a combination of "publicPath", "serverBuildPath", "serverConditions", "serverDependenciesToBundle", "serverMainFields", "serverMinify", "serverModuleFormat" and/or "serverPlatform" instead.`; - -export let flatRoutesWarning = `⚠️ DEPRECATED: The old nested folders route convention has been deprecated in favor of "flat routes". Please enable the new routing convention via the \`future.v2_routeConvention\` flag in your \`remix.config.js\` file. For more information, please see https://remix.run/docs/en/main/file-conventions/route-files-v2.`; +export let serverBuildTargetWarning = `The "serverBuildTarget" config option is deprecated. Use a combination of "publicPath", "serverBuildPath", "serverConditions", "serverDependenciesToBundle", "serverMainFields", "serverMinify", "serverModuleFormat" and/or "serverPlatform" instead.`; From bc88441cecaa00f331baefe36e44f19e852f227e Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 14 Mar 2023 11:02:21 -0400 Subject: [PATCH 2/4] Revert "feat(remix-dev): serverBuildTarget deprecation warning (#5624)" This reverts commit 342dc6058fd5ab45f1e2611f632d13174c18f841. --- docs/file-conventions/remix-config.md | 15 ++------------- .../__tests__/fixtures/stack/remix.config.js | 1 - packages/remix-dev/__tests__/readConfig-test.ts | 10 ++-------- packages/remix-dev/config.ts | 7 ------- 4 files changed, 4 insertions(+), 29 deletions(-) diff --git a/docs/file-conventions/remix-config.md b/docs/file-conventions/remix-config.md index f2b4e5e54c1..3a975ed16f6 100644 --- a/docs/file-conventions/remix-config.md +++ b/docs/file-conventions/remix-config.md @@ -116,7 +116,8 @@ to `"build/index.js"`. ## serverBuildTarget -This option is deprecated and will be removed in the next major version release. Use a combination of [`publicPath`][public-path], +This option is deprecated and will likely be removed in a future +stable release. Use a combination of [`publicPath`][public-path], [`serverBuildPath`][server-build-path], [`serverConditions`][server-conditions], [`serverDependenciesToBundle`][server-dependencies-to-bundle] [`serverMainFields`][server-main-fields], [`serverMinify`][server-minify], @@ -135,18 +136,6 @@ The `serverBuildTarget` can be one of the following: - [`"node-cjs"`][node-cjs] - [`"vercel"`][vercel] -**Migration Table:** - -| serverBuildTarget | publicPath | serverBuildPath | serverConditions | serverMainFields | serverModuleFormat | serverPlatform | serverDependenciesToBundle | serverMinify | -| -------------------- | ------------------ | --------------------------------------- | ---------------- | ----------------------- | ------------------ | -------------- | -------------------------- | ------------ | -| `arc` | `/\_static/build/` | `server/index.js` | | `main, module` | `cjs` | `node` | | `false` | -| `cloudflare-pages` | `/build/` | `functions/[[path]].js` | `worker` | `browser, module, main` | `esm` | `neutral` | `all` | `true` | -| `cloudflare-workers` | `/build/` | `build/index.js` | `worker` | `browser, module, main` | `esm` | `neutral` | `all` | `true` | -| `deno` | `/build/` | `build/index.js` | `deno, worker` | `module, main` | `esm` | `neutral` | `all` | `false` | -| `netlify` | `/build/` | `.netlify/functions-internal/server.js` | | `main, module` | `cjs` | `node` | | `false` | -| `node-cjs` | `/build/` | `build/index.js` | | `main, module` | `cjs` | `node` | | `false` | -| `vercel` | `/build/` | `api/index.js` | | `main, module` | `cjs` | `node` | | `false` | - ## serverConditions The order of conditions to use when resolving server dependencies' `exports` diff --git a/packages/remix-dev/__tests__/fixtures/stack/remix.config.js b/packages/remix-dev/__tests__/fixtures/stack/remix.config.js index 5bb0822e720..adf2a0b5d3e 100644 --- a/packages/remix-dev/__tests__/fixtures/stack/remix.config.js +++ b/packages/remix-dev/__tests__/fixtures/stack/remix.config.js @@ -1,6 +1,5 @@ /** @type {import('@remix-run/dev').AppConfig} */ module.exports = { - serverBuildTarget: "node-cjs", ignoredRouteFiles: ["**/.*"], // appDirectory: "app", // assetsBuildDirectory: "public/build", diff --git a/packages/remix-dev/__tests__/readConfig-test.ts b/packages/remix-dev/__tests__/readConfig-test.ts index b953178b363..1dced697bf7 100644 --- a/packages/remix-dev/__tests__/readConfig-test.ts +++ b/packages/remix-dev/__tests__/readConfig-test.ts @@ -1,23 +1,17 @@ import path from "path"; import type { RemixConfig } from "../config"; -import { serverBuildTargetWarning, readConfig } from "../config"; +import { readConfig } from "../config"; const remixRoot = path.resolve(__dirname, "./fixtures/stack"); describe("readConfig", () => { let config: RemixConfig; - let warnStub; beforeEach(async () => { - let consoleWarn = console.warn; - warnStub = jest.fn(); - console.warn = warnStub; config = await readConfig(remixRoot); - console.warn = consoleWarn; }); it("generates a config", async () => { - expect(warnStub).toHaveBeenCalledWith(serverBuildTargetWarning); expect(config).toMatchInlineSnapshot( { rootDirectory: expect.any(String), @@ -75,7 +69,7 @@ describe("readConfig", () => { }, }, "serverBuildPath": Any, - "serverBuildTarget": "node-cjs", + "serverBuildTarget": undefined, "serverBuildTargetEntryModule": "export * from \\"@remix-run/dev/server-build\\";", "serverConditions": undefined, "serverDependenciesToBundle": Array [], diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 4c6f161eb86..77589404d72 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -13,7 +13,6 @@ import { serverBuildVirtualModule } from "./compiler/virtualModules"; import { writeConfigDefaults } from "./compiler/utils/tsconfig/write-config-defaults"; import { flatRoutes } from "./config/flat-routes"; import { getPreferredPackageManager } from "./cli/getPreferredPackageManager"; -import { warnOnce } from "./compiler/warnings"; export interface RemixMdxConfig { rehypePlugins?: any[]; @@ -397,10 +396,6 @@ export async function readConfig( } } - if (appConfig.serverBuildTarget) { - warnOnce(serverBuildTargetWarning, "v2_serverBuildTarget"); - } - let isCloudflareRuntime = ["cloudflare-pages", "cloudflare-workers"].includes( appConfig.serverBuildTarget ?? "" ); @@ -725,5 +720,3 @@ let listFormat = new Intl.ListFormat("en", { style: "long", type: "conjunction", }); - -export let serverBuildTargetWarning = `The "serverBuildTarget" config option is deprecated. Use a combination of "publicPath", "serverBuildPath", "serverConditions", "serverDependenciesToBundle", "serverMainFields", "serverMinify", "serverModuleFormat" and/or "serverPlatform" instead.`; From ff0ddfbc4fdf043e4152bb3d396b0a32f2288048 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 14 Mar 2023 11:09:48 -0400 Subject: [PATCH 3/4] Create .changeset/metal-masks-develop.md --- .changeset/metal-masks-develop.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/metal-masks-develop.md diff --git a/.changeset/metal-masks-develop.md b/.changeset/metal-masks-develop.md new file mode 100644 index 00000000000..2561b37e6bd --- /dev/null +++ b/.changeset/metal-masks-develop.md @@ -0,0 +1,6 @@ +--- +"remix": patch +"@remix-run/dev": patch +--- + +remove premature deprecation warnings From 117f121763c7cb00dbfc52c63fed9622e88f32ca Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 14 Mar 2023 11:10:24 -0400 Subject: [PATCH 4/4] rename --- .changeset/{metal-masks-develop.md => premature-deprecations.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changeset/{metal-masks-develop.md => premature-deprecations.md} (100%) diff --git a/.changeset/metal-masks-develop.md b/.changeset/premature-deprecations.md similarity index 100% rename from .changeset/metal-masks-develop.md rename to .changeset/premature-deprecations.md