Skip to content

Commit

Permalink
feat(remix-dev)!: remove serverBuildTarget config option (#6896)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Brophy <matt@brophy.org>
  • Loading branch information
MichaelDeBoey and brophdawg11 committed Jul 20, 2023
1 parent 6e9cbda commit 4614557
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 108 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-wombats-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/dev": major
---

Remove `serverBuildTarget` config option
5 changes: 0 additions & 5 deletions docs/api/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ title: Conventions

[Moved →][moved-12]

### serverBuildTarget

[Moved →][moved-13]

### serverDependenciesToBundle

[Moved →][moved-14]
Expand Down Expand Up @@ -214,7 +210,6 @@ title: Conventions
[moved-10]: ../file-conventions/remix-config#server
[moved-11]: ../file-conventions/remix-config#serverbuilddirectory
[moved-12]: ../file-conventions/remix-config#serverbuildpath
[moved-13]: ../file-conventions/remix-config#serverbuildtarget
[moved-14]: ../file-conventions/remix-config#serverdependenciestobundle
[moved-15]: ../file-conventions/remix-config#watchpaths
[moved-16]: ../file-conventions/routes-files
Expand Down
21 changes: 0 additions & 21 deletions docs/file-conventions/remix-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,6 @@ 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. Defaults
to `"build/index.js"`.

## serverBuildTarget

<docs-warning>This option is deprecated and will be removed in the next major version 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],
[`serverModuleFormat`][server-module-format] and/or
[`serverPlatform`][server-platform] instead.</docs-warning>

The target of the server build. Defaults to `"node-cjs"`.

The `serverBuildTarget` can be one of the following:

- [`"arc"`][arc]
- [`"cloudflare-pages"`][cloudflare-pages]
- [`"cloudflare-workers"`][cloudflare-workers]
- [`"deno"`][deno]
- [`"netlify"`][netlify]
- [`"node-cjs"`][node-cjs]
- [`"vercel"`][vercel]

## serverConditions

The order of conditions to use when resolving server dependencies' `exports`
Expand Down
10 changes: 8 additions & 2 deletions packages/remix-dev/__tests__/fixtures/cloudflare/remix.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
serverBuildTarget: "cloudflare-pages",
server: "./server.ts",
devServerBroadcastDelay: 1000,
ignoredRouteFiles: ["**/.*"],
server: "./server.ts",
serverBuildPath: "functions/[[path]].js",
serverConditions: ["worker"],
serverDependenciesToBundle: "all",
serverMainFields: ["browser", "module", "main"],
serverMinify: true,
serverModuleFormat: "esm",
serverPlatform: "neutral",
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "functions/[[path]].js",
Expand Down
10 changes: 7 additions & 3 deletions packages/remix-dev/__tests__/fixtures/deno/remix.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
serverBuildTarget: "deno",
server: "./server.ts",
/*
If live reload causes page to re-render without changes (live reload is too fast),
increase the dev server broadcast delay.
Expand All @@ -10,8 +8,14 @@ module.exports = {
*/
devServerBroadcastDelay: 300,
ignoredRouteFiles: ["**/.*"],
server: "./server.ts",
serverConditions: ["deno", "worker"],
serverDependenciesToBundle: "all",
serverMainFields: ["module", "main"],
serverModuleFormat: "esm",
serverPlatform: "neutral",
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "build/index.js",
// publicPath: "/build/",
// serverBuildPath: "build/index.js",
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
serverBuildTarget: "node-cjs",
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
Expand Down
1 change: 0 additions & 1 deletion packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ describe("readConfig", () => {
},
},
"serverBuildPath": Any<String>,
"serverBuildTarget": "node-cjs",
"serverBuildTargetEntryModule": "export * from \\"@remix-run/dev/server-build\\";",
"serverConditions": undefined,
"serverDependenciesToBundle": Array [],
Expand Down
76 changes: 1 addition & 75 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ export type RemixMdxConfigFunction = (
filename: string
) => Promise<RemixMdxConfig | undefined> | RemixMdxConfig | undefined;

export type ServerBuildTarget =
| "node-cjs"
| "arc"
| "netlify"
| "vercel"
| "cloudflare-pages"
| "cloudflare-workers"
| "deno";

export type ServerModuleFormat = "esm" | "cjs";
export type ServerPlatform = "node" | "neutral";

Expand Down Expand Up @@ -150,13 +141,6 @@ export interface AppConfig {
*/
serverBuildPath?: string;

/**
* The target of the server build. Defaults to "node-cjs".
*
* @deprecated Use a combination of `{@link AppConfig.publicPath}`, `{@link AppConfig.serverBuildPath}`, `{@link AppConfig.serverConditions}`, `{@link AppConfig.serverDependenciesToBundle}`, `{@link AppConfig.serverMainFields}`, `{@link AppConfig.serverMinify}`, `{@link AppConfig.serverModuleFormat}` and/or `{@link AppConfig.serverPlatform}` instead.
*/
serverBuildTarget?: ServerBuildTarget;

/**
* The order of conditions to use when resolving server dependencies'
* `exports` field in `package.json`.
Expand Down Expand Up @@ -311,12 +295,6 @@ export interface RemixConfig {
*/
serverBuildPath: string;

/**
* The target of the server build. Defaults to "node-cjs".
*
* @deprecated Use a combination of `{@link AppConfig.publicPath}`, `{@link AppConfig.serverBuildPath}`, `{@link AppConfig.serverConditions}`, `{@link AppConfig.serverDependenciesToBundle}`, `{@link AppConfig.serverMainFields}`, `{@link AppConfig.serverMinify}`, `{@link AppConfig.serverModuleFormat}` and/or `{@link AppConfig.serverPlatform}` instead. */
serverBuildTarget?: ServerBuildTarget;

/**
* The default entry module for the server build if a {@see AppConfig.server}
* is not provided.
Expand Down Expand Up @@ -439,10 +417,6 @@ export async function readConfig(
}
}

if (appConfig.serverBuildTarget) {
serverBuildTargetWarning();
}

if (!appConfig.future?.v2_errorBoundary) {
errorBoundaryWarning();
}
Expand All @@ -455,13 +429,7 @@ export async function readConfig(
headersWarning();
}

let isCloudflareRuntime = ["cloudflare-pages", "cloudflare-workers"].includes(
appConfig.serverBuildTarget ?? ""
);
let isDenoRuntime = appConfig.serverBuildTarget === "deno";

let serverBuildPath = resolveServerBuildPath(rootDirectory, appConfig);
let serverBuildTarget = appConfig.serverBuildTarget;
let serverBuildTargetEntryModule = `export * from ${JSON.stringify(
serverBuildVirtualModule.id
)};`;
Expand All @@ -477,21 +445,6 @@ export async function readConfig(

let serverModuleFormat = appConfig.serverModuleFormat || "cjs";
let serverPlatform = appConfig.serverPlatform || "node";
if (isCloudflareRuntime) {
serverConditions ??= ["worker"];
serverDependenciesToBundle = "all";
serverMainFields ??= ["browser", "module", "main"];
serverMinify ??= true;
serverModuleFormat = "esm";
serverPlatform = "neutral";
}
if (isDenoRuntime) {
serverConditions ??= ["deno", "worker"];
serverDependenciesToBundle = "all";
serverMainFields ??= ["module", "main"];
serverModuleFormat = "esm";
serverPlatform = "neutral";
}
serverMainFields ??=
serverModuleFormat === "esm" ? ["module", "main"] : ["main", "module"];
serverMinify ??= false;
Expand Down Expand Up @@ -792,9 +745,7 @@ export async function readConfig(
process.env.REMIX_DEV_SERVER_WS_PORT = String(devServerPort);
let devServerBroadcastDelay = appConfig.devServerBroadcastDelay || 0;

let defaultPublicPath =
appConfig.serverBuildTarget === "arc" ? "/_static/build/" : "/build/";
let publicPath = addTrailingSlash(appConfig.publicPath || defaultPublicPath);
let publicPath = addTrailingSlash(appConfig.publicPath || "/build/");

let rootRouteFile = findEntry(appDirectory, "root");
if (!rootRouteFile) {
Expand Down Expand Up @@ -881,7 +832,6 @@ export async function readConfig(
rootDirectory,
routes,
serverBuildPath,
serverBuildTarget,
serverBuildTargetEntryModule,
serverConditions,
serverDependenciesToBundle,
Expand Down Expand Up @@ -938,21 +888,6 @@ const resolveServerBuildPath = (
) => {
let serverBuildPath = "build/index.js";

switch (appConfig.serverBuildTarget) {
case "arc":
serverBuildPath = "server/index.js";
break;
case "cloudflare-pages":
serverBuildPath = "functions/[[path]].js";
break;
case "netlify":
serverBuildPath = ".netlify/functions-internal/server.js";
break;
case "vercel":
serverBuildPath = "api/index.js";
break;
}

// retain deprecated behavior for now
if (appConfig.serverBuildDirectory) {
serverBuildDirectoryWarning();
Expand Down Expand Up @@ -1016,15 +951,6 @@ let serverBuildDirectoryWarning = () =>
}
);

let serverBuildTargetWarning = () =>
logger.warn("The `serverBuildTarget` config option will be removed in v2", {
details: [
"You can specify multiple server module config options instead to achieve the same result.",
"-> https://remix.run/docs/en/v1.15.0/pages/v2#serverbuildtarget",
],
key: "serverBuildTargetWarning",
});

let serverModuleFormatWarning = () =>
logger.warn("The default server module format is changing in v2", {
details: [
Expand Down

0 comments on commit 4614557

Please sign in to comment.