Skip to content

Remove unused default server entries #11615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ let conjunctionListFormat = new Intl.ListFormat("en", {
type: "conjunction",
});

let disjunctionListFormat = new Intl.ListFormat("en", {
style: "long",
type: "disjunction",
});

export async function generateEntry(
entry: string,
reactRouterRoot: string,
Expand Down Expand Up @@ -116,26 +111,8 @@ export async function generateEntry(
let pkgJson = await PackageJson.load(rootDirectory);
let deps = pkgJson.content.dependencies ?? {};

let serverRuntime = deps["@react-router/deno"]
? "deno"
: deps["@react-router/cloudflare"]
? "cloudflare"
: deps["@react-router/node"]
? "node"
: undefined;

if (!serverRuntime) {
let serverRuntimes = [
"@react-router/deno",
"@react-router/cloudflare",
"@react-router/node",
];
let formattedList = disjunctionListFormat.format(serverRuntimes);
console.error(
colors.error(
`Could not determine server runtime. Please install one of the following: ${formattedList}`
)
);
if (!deps["@react-router/node"]) {
console.error(colors.error(`No default server entry detected.`));
return;
}

Expand All @@ -146,7 +123,7 @@ export async function generateEntry(
defaultsDirectory,
ctx?.reactRouterConfig.ssr === false
? `entry.server.spa.tsx`
: `entry.server.${serverRuntime}.tsx`
: `entry.server.node.tsx`
);

let isServerEntry = entry === "entry.server";
Expand Down
54 changes: 4 additions & 50 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export async function resolveEntryFiles({
rootDirectory: string;
reactRouterConfig: ResolvedVitePluginConfig;
}) {
let { appDirectory, future } = reactRouterConfig;
let { appDirectory } = reactRouterConfig;

let defaultsDirectory = path.resolve(__dirname, "config", "defaults");

Expand All @@ -500,23 +500,9 @@ export async function resolveEntryFiles({
} else if (userEntryServerFile) {
entryServerFile = userEntryServerFile;
} else {
let serverRuntime = deps["@react-router/deno"]
? "deno"
: deps["@react-router/cloudflare"]
? "cloudflare"
: deps["@react-router/node"]
? "node"
: undefined;

if (!serverRuntime) {
let serverRuntimes = [
"@react-router/deno",
"@react-router/cloudflare",
"@react-router/node",
];
let formattedList = disjunctionListFormat.format(serverRuntimes);
if (!deps["@react-router/node"]) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now the only built-in runtime package so we can simplify the code a lot.

throw new Error(
`Could not determine server runtime. Please install one of the following: ${formattedList}`
`Could not determine server runtime. Please install @react-router/node, or provide a custom entry.server.tsx/jsx file in your app directory.`
);
}

Expand All @@ -542,7 +528,7 @@ export async function resolveEntryFiles({
});
}

entryServerFile = `entry.server.${serverRuntime}.tsx`;
entryServerFile = `entry.server.node.tsx`;
}

let entryClientFilePath = userEntryClientFile
Expand All @@ -566,35 +552,3 @@ function findEntry(dir: string, basename: string): string | undefined {

return undefined;
}

// adds types for `Intl.ListFormat` to the global namespace
// we could also update our `tsconfig.json` to include `lib: ["es2021"]`
declare namespace Intl {
type ListType = "conjunction" | "disjunction";

interface ListFormatOptions {
localeMatcher?: "lookup" | "best fit";
type?: ListType;
style?: "long" | "short" | "narrow";
}

interface ListFormatPart {
type: "element" | "literal";
value: string;
}

class ListFormat {
constructor(locales?: string | string[], options?: ListFormatOptions);
format(values: any[]): string;
formatToParts(values: any[]): ListFormatPart[];
supportedLocalesOf(
locales: string | string[],
options?: ListFormatOptions
): string[];
}
}

let disjunctionListFormat = new Intl.ListFormat("en", {
style: "long",
type: "disjunction",
});
55 changes: 0 additions & 55 deletions packages/remix-dev/config/defaults/entry.server.cloudflare.tsx

This file was deleted.

55 changes: 0 additions & 55 deletions packages/remix-dev/config/defaults/entry.server.deno.tsx

This file was deleted.

Loading