Skip to content

Commit

Permalink
Revert "feat(remix-dev): add warning when future.v2_routeConvention
Browse files Browse the repository at this point in the history
… is not enabled (#5606)"

This reverts commit 712732f.
  • Loading branch information
mcansh committed Mar 14, 2023
1 parent d906d5e commit 2abe0d0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 63 deletions.
47 changes: 0 additions & 47 deletions integration/flat-routes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <p>routes/index</p>;
}
`,
},
});

let chunks: Buffer[] = [];
buildOutput = await new Promise<string>((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;
Expand Down
1 change: 0 additions & 1 deletion integration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"rootDir": "."
},
"references": [
{ "path": "../packages/remix-dev" },
{ "path": "../packages/remix-express" },
{ "path": "../packages/remix-react" },
{ "path": "../packages/remix-server-runtime" }
Expand Down
5 changes: 1 addition & 4 deletions packages/remix-dev/__tests__/create-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -348,9 +347,7 @@ describe("the create command", () => {
"--no-typescript",
]);
expect(output.trim()).toBe(
flatRoutesWarning +
"\n\n" +
getOptOutOfInstallMessage() +
getOptOutOfInstallMessage() +
"\n\n" +
getSuccessMessage(path.join("<TEMP_DIR>", "template-to-js"))
);
Expand Down
15 changes: 4 additions & 11 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.`;

0 comments on commit 2abe0d0

Please sign in to comment.