Skip to content

Commit

Permalink
refactor!(dev): remove deprecated devServerPort option
Browse files Browse the repository at this point in the history
use `--port`/`config.dev.port` option instead
  • Loading branch information
pcattori committed Aug 1, 2023
1 parent 49157df commit 000457e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 118 deletions.
7 changes: 7 additions & 0 deletions .changeset/loud-pandas-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@remix-run/dev": major
---

remove deprecated `devServerPort` option

use `--port` / `config.dev.port` option instead
7 changes: 0 additions & 7 deletions packages/remix-dev/__tests__/readConfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe("readConfig", () => {
rootDirectory: expect.any(String),
appDirectory: expect.any(String),
cacheDirectory: expect.any(String),
devServerPort: expect.any(Number),
serverBuildPath: expect.any(String),
assetsBuildDirectory: expect.any(String),
relativeAssetsBuildDirectory: expect.any(String),
Expand All @@ -32,7 +31,6 @@ describe("readConfig", () => {
"cacheDirectory": Any<String>,
"dev": Object {},
"devServerBroadcastDelay": 0,
"devServerPort": Any<Number>,
"entryClientFile": "entry.client.tsx",
"entryClientFilePath": Any<String>,
"entryServerFile": "entry.server.tsx",
Expand Down Expand Up @@ -71,9 +69,4 @@ describe("readConfig", () => {
`
);
});

it("returns the same devServerPort value across reloads", async () => {
let newConfig = await readConfig(remixRoot);
expect(newConfig.devServerPort).toBe(config.devServerPort);
});
});
3 changes: 2 additions & 1 deletion packages/remix-dev/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ export async function watch(
? remixRootOrConfig
: await readConfig(remixRootOrConfig);

devServer.liveReload(config);
let resolved = await resolveDev(config);
devServer.liveReload(config, resolved);
return await new Promise(() => {});
}

Expand Down
17 changes: 0 additions & 17 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { execSync } from "node:child_process";
import path from "node:path";
import { pathToFileURL } from "node:url";
import fse from "fs-extra";
import getPort from "get-port";
import NPMCliPackageJson from "@npmcli/package-json";
import { coerce } from "semver";
import type { NodePolyfillsOptions as EsbuildPluginsNodeModulesPolyfillOptions } from "esbuild-plugins-node-modules-polyfill";
Expand Down Expand Up @@ -84,13 +83,6 @@ export interface AppConfig {
*/
dev?: Dev;

/**
* @deprecated
*
* The port number to use for the dev server. Defaults to 8002.
*/
devServerPort?: number;

/**
* @deprecated
*
Expand Down Expand Up @@ -257,11 +249,6 @@ export interface RemixConfig {
*/
dev: Dev;

/**
* The port number to use for the dev (asset) server.
*/
devServerPort: number;

/**
* The delay before the dev (asset) server broadcasts a reload event.
*/
Expand Down Expand Up @@ -568,9 +555,6 @@ export async function readConfig(
assetsBuildDirectory
);

let devServerPort = await getPort({
port: Number(appConfig.devServerPort) || 8002,
});
// set env variable so un-bundled servers can use it
let devServerBroadcastDelay = appConfig.devServerBroadcastDelay || 0;

Expand Down Expand Up @@ -634,7 +618,6 @@ export async function readConfig(
entryServerFile,
entryServerFilePath,
dev: appConfig.dev ?? {},
devServerPort,
devServerBroadcastDelay,
assetsBuildDirectory: absoluteAssetsBuildDirectory,
relativeAssetsBuildDirectory: assetsBuildDirectory,
Expand Down
1 change: 0 additions & 1 deletion packages/remix-dev/devServer/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { liveReload } from "./liveReload";
export { serve } from "./serve";
7 changes: 5 additions & 2 deletions packages/remix-dev/devServer/liveReload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ let clean = (config: RemixConfig) => {
}
};

export async function liveReload(config: RemixConfig) {
export async function liveReload(
config: RemixConfig,
options: { port: number }
) {
clean(config);
let wss = new WebSocket.Server({ port: config.devServerPort });
let wss = new WebSocket.Server({ port: options.port });
function broadcast(event: { type: string } & Record<string, unknown>) {
setTimeout(() => {
wss.clients.forEach((client) => {
Expand Down
90 changes: 0 additions & 90 deletions packages/remix-dev/devServer/serve.ts

This file was deleted.

0 comments on commit 000457e

Please sign in to comment.