From 65b7f84d2304fb09494bf736051cd8b42d5c2128 Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Wed, 26 Apr 2023 11:31:25 -0700 Subject: [PATCH] chore: rename devReady to broadcastDevReady --- .changeset/dev-server.md | 20 +++++++++---------- .changeset/modern-ways-eat.md | 12 +++++++++++ integration/hmr-test.ts | 4 ++-- packages/remix-cloudflare/index.ts | 2 +- packages/remix-deno/index.ts | 2 +- .../remix-dev/devServer_unstable/index.ts | 2 +- packages/remix-node/index.ts | 2 +- packages/remix-serve/cli.ts | 4 ++-- packages/remix-server-runtime/dev.ts | 2 +- packages/remix-server-runtime/index.ts | 2 +- templates/express/server.ts | 4 ++-- 11 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 .changeset/modern-ways-eat.md diff --git a/.changeset/dev-server.md b/.changeset/dev-server.md index eba6d7aa674..6830fc06d8c 100644 --- a/.changeset/dev-server.md +++ b/.changeset/dev-server.md @@ -52,13 +52,13 @@ Update `package.json` scripts, specifying the command to run you app server with } ``` -Then, call `devReady` in your server when its up and running. +Then, call `broadcastDevReady` in your server when its up and running. -For example, an Express server would call `devReady` at the end of `listen`: +For example, an Express server would call `broadcastDevReady` at the end of `listen`: ```js // -import { devReady } from "@remix-run/node"; +import { broadcastDevReady } from "@remix-run/node"; // Path to Remix's server build directory ('build/' by default) let BUILD_DIR = path.join(process.cwd(), "build"); @@ -69,9 +69,9 @@ app.listen(3000, () => { let build = require(BUILD_DIR); console.log("Ready: http://localhost:" + port); - // in development, call `devReady` _after_ your server is up and running + // in development, call `broadcastDevReady` _after_ your server is up and running if (process.env.NODE_ENV === "development") { - devReady(build); + broadcastDevReady(build); } }); ``` @@ -95,11 +95,11 @@ Most users won't need to configure the dev server, but you might need to if: unstable_dev: { // Command to run your app server command: "wrangler", // default: `remix-serve ./build` - // HTTP(S) scheme used when sending `devReady` messages to the dev server + // HTTP(S) scheme used when sending `broadcastDevReady` messages to the dev server httpScheme: "https", // default: `"http"` - // HTTP(S) host used when sending `devReady` messages to the dev server + // HTTP(S) host used when sending `broadcastDevReady` messages to the dev server httpHost: "mycustomhost", // default: `"localhost"` - // HTTP(S) port internally used by the dev server to statically serve built assets and to receive app server `devReady` messages + // HTTP(S) port internally used by the dev server to statically serve built assets and to receive app server `broadcastDevReady` messages httpPort: 8001, // default: Remix chooses an open port in the range 3001-3099 // Websocket port internally used by the dev server for sending updates to the browser (Live reload, HMR, HDR) websocketPort: 8002, // default: Remix chooses an open port in the range 3001-3099 @@ -125,13 +125,13 @@ If you want to manage app server updates yourself, you can use the `--no-restart For example, if you rely on require cache purging to keep your app server running while server changes are pulled in, then you'll want to use `--no-restart`. -🚨 It is then your responsibility to call `devReady` whenever server changes are incorporated in your app server. 🚨 +🚨 It is then your responsibility to call `broadcastDevReady` whenever server changes are incorporated in your app server. 🚨 So for require cache purging, you'd want to: 1. Purge the require cache 2. `require` your server build -3. Call `devReady` within a `if (process.env.NODE_ENV === 'development')` +3. Call `broadcastDevReady` within a `if (process.env.NODE_ENV === 'development')` ([Looking at you, Kent](https://github.com/kentcdodds/kentcdodds.com/blob/main/server/index.ts#L298) 😆) diff --git a/.changeset/modern-ways-eat.md b/.changeset/modern-ways-eat.md new file mode 100644 index 00000000000..3618458d809 --- /dev/null +++ b/.changeset/modern-ways-eat.md @@ -0,0 +1,12 @@ +--- +"@remix-run/cloudflare": patch +"@remix-run/deno": patch +"@remix-run/dev": patch +"@remix-run/eslint-config": patch +"@remix-run/node": patch +"@remix-run/react": patch +"@remix-run/serve": patch +"@remix-run/server-runtime": patch +--- + +rename devReady to broadcastDevReady diff --git a/integration/hmr-test.ts b/integration/hmr-test.ts index bb632820868..635e7f716e4 100644 --- a/integration/hmr-test.ts +++ b/integration/hmr-test.ts @@ -63,7 +63,7 @@ let fixture = (options: { let path = require("path"); let express = require("express"); let { createRequestHandler } = require("@remix-run/express"); - let { devReady } = require("@remix-run/node"); + let { broadcastDevReady } = require("@remix-run/node"); const app = express(); app.use(express.static("public", { immutable: true, maxAge: "1y" })); @@ -84,7 +84,7 @@ let fixture = (options: { let build = require(BUILD_DIR); console.log('✅ app ready: http://localhost:' + port); if (process.env.NODE_ENV === 'development') { - devReady(build); + broadcastDevReady(build); } }); `, diff --git a/packages/remix-cloudflare/index.ts b/packages/remix-cloudflare/index.ts index 1f6f1ffa052..4ebd2ff4147 100644 --- a/packages/remix-cloudflare/index.ts +++ b/packages/remix-cloudflare/index.ts @@ -28,7 +28,7 @@ export { createRequestHandler, createSession, defer, - devReady, + broadcastDevReady, isCookie, isSession, json, diff --git a/packages/remix-deno/index.ts b/packages/remix-deno/index.ts index 946342f8cc2..023c766c942 100644 --- a/packages/remix-deno/index.ts +++ b/packages/remix-deno/index.ts @@ -16,7 +16,7 @@ export { export { createSession, defer, - devReady, + broadcastDevReady, isCookie, isSession, json, diff --git a/packages/remix-dev/devServer_unstable/index.ts b/packages/remix-dev/devServer_unstable/index.ts index df19f1da0e7..44d57abb23e 100644 --- a/packages/remix-dev/devServer_unstable/index.ts +++ b/packages/remix-dev/devServer_unstable/index.ts @@ -166,7 +166,7 @@ export let serve = async ( }) ) - // handle `devReady` messages + // handle `broadcastDevReady` messages .use(express.json()) .post("/ping", (req, res) => { let { buildHash } = req.body; diff --git a/packages/remix-node/index.ts b/packages/remix-node/index.ts index ec5466e6138..5931fd7ddee 100644 --- a/packages/remix-node/index.ts +++ b/packages/remix-node/index.ts @@ -39,7 +39,7 @@ export { createRequestHandler, createSession, defer, - devReady, + broadcastDevReady, isCookie, isSession, json, diff --git a/packages/remix-serve/cli.ts b/packages/remix-serve/cli.ts index a1c286189aa..06246b42052 100644 --- a/packages/remix-serve/cli.ts +++ b/packages/remix-serve/cli.ts @@ -1,7 +1,7 @@ import "./env"; import path from "path"; import os from "os"; -import { devReady } from "@remix-run/node"; +import { broadcastDevReady } from "@remix-run/node"; import { createApp } from "./index"; @@ -37,7 +37,7 @@ let onListen = () => { build.future?.unstable_dev !== false && process.env.NODE_ENV === "development" ) { - devReady(build); + broadcastDevReady(build); } }; diff --git a/packages/remix-server-runtime/dev.ts b/packages/remix-server-runtime/dev.ts index 8ce5210cf5e..970bfd73c56 100644 --- a/packages/remix-server-runtime/dev.ts +++ b/packages/remix-server-runtime/dev.ts @@ -1,6 +1,6 @@ import type { ServerBuild } from "./build"; -export let devReady = (build: ServerBuild, origin?: string) => { +export let broadcastDevReady = (build: ServerBuild, origin?: string) => { origin ??= process.env.REMIX_DEV_HTTP_ORIGIN; if (!origin) throw Error("Dev server origin not set"); diff --git a/packages/remix-server-runtime/index.ts b/packages/remix-server-runtime/index.ts index 14112112827..55746c0025f 100644 --- a/packages/remix-server-runtime/index.ts +++ b/packages/remix-server-runtime/index.ts @@ -15,7 +15,7 @@ export { createCookieSessionStorageFactory } from "./sessions/cookieStorage"; export { createMemorySessionStorageFactory } from "./sessions/memoryStorage"; export { createMemoryUploadHandler as unstable_createMemoryUploadHandler } from "./upload/memoryUploadHandler"; export { MaxPartSizeExceededError } from "./upload/errors"; -export { devReady } from "./dev"; +export { broadcastDevReady } from "./dev"; // Types for the Remix server runtime interface export type { diff --git a/templates/express/server.ts b/templates/express/server.ts index 0ab35561ea7..b0536d7cd3f 100644 --- a/templates/express/server.ts +++ b/templates/express/server.ts @@ -35,7 +35,7 @@ app.listen(port, async () => { console.log(`✅ Express server listening on port ${port}`); if (process.env.NODE_ENV === "development") { - const { devReady } = await import("@remix-run/node"); - devReady(build); + const { broadcastDevReady } = await import("@remix-run/node"); + broadcastDevReady(build); } });