Skip to content
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

chore: rename devReady to broadcastDevReady #6194

Merged
merged 1 commit into from
Apr 26, 2023
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
20 changes: 10 additions & 10 deletions .changeset/dev-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
// <other imports>
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");
Expand All @@ -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);
}
});
```
Expand All @@ -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
Expand All @@ -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) 😆)

Expand Down
12 changes: 12 additions & 0 deletions .changeset/modern-ways-eat.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions integration/hmr-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }));
Expand All @@ -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);
}
});
`,
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-cloudflare/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export {
createRequestHandler,
createSession,
defer,
devReady,
broadcastDevReady,
isCookie,
isSession,
json,
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-deno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export {
export {
createSession,
defer,
devReady,
broadcastDevReady,
isCookie,
isSession,
json,
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/devServer_unstable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export {
createRequestHandler,
createSession,
defer,
devReady,
broadcastDevReady,
isCookie,
isSession,
json,
Expand Down
4 changes: 2 additions & 2 deletions packages/remix-serve/cli.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -37,7 +37,7 @@ let onListen = () => {
build.future?.unstable_dev !== false &&
process.env.NODE_ENV === "development"
) {
devReady(build);
broadcastDevReady(build);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/dev.ts
Original file line number Diff line number Diff line change
@@ -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");

Expand Down
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions templates/express/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});