Skip to content

Commit

Permalink
refactor!(dev,react): remove deprecated REMIX_DEV_SERVER_WS_PORT env …
Browse files Browse the repository at this point in the history
…var (#6965)
  • Loading branch information
pcattori authored Jul 26, 2023
1 parent 7917c81 commit f964197
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 22 deletions.
8 changes: 8 additions & 0 deletions .changeset/moody-pants-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@remix-run/dev": major
"@remix-run/react": major
---

remove deprecated REMIX_DEV_SERVER_WS_PORT env var

use `remix dev`'s '`--port`/`port` option instead
4 changes: 0 additions & 4 deletions packages/remix-dev/compiler/js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ const createEsbuildConfig = (
"process.env.REMIX_DEV_ORIGIN": JSON.stringify(
ctx.options.REMIX_DEV_ORIGIN ?? ""
),
// TODO: remove in v2
"process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify(
ctx.config.devServerPort
),
...(ctx.options.mode === "production"
? {
"import.meta.hot": "undefined",
Expand Down
4 changes: 0 additions & 4 deletions packages/remix-dev/compiler/server/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ const createEsbuildConfig = (
publicPath: ctx.config.publicPath,
define: {
"process.env.NODE_ENV": JSON.stringify(ctx.options.mode),
// TODO: remove in v2
"process.env.REMIX_DEV_SERVER_WS_PORT": JSON.stringify(
ctx.config.devServerPort
),
"process.env.REMIX_DEV_ORIGIN": JSON.stringify(
ctx.options.REMIX_DEV_ORIGIN ?? ""
),
Expand Down
12 changes: 2 additions & 10 deletions packages/remix-react/__tests__/components-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,14 @@ describe("<LiveReload />", () => {
LiveReload = require("../components").LiveReload;
let { container } = render(<LiveReload />);
expect(container.querySelector("script")).toHaveTextContent(
"url.port = undefined || REMIX_DEV_ORIGIN ? new URL(REMIX_DEV_ORIGIN).port : Number(undefined) || 8002;"
"url.port = undefined || REMIX_DEV_ORIGIN ? new URL(REMIX_DEV_ORIGIN).port : 8002;"
);
});

it("can set the port explicitly", () => {
let { container } = render(<LiveReload port={4321} />);
expect(container.querySelector("script")).toHaveTextContent(
"url.port = 4321 || REMIX_DEV_ORIGIN ? new URL(REMIX_DEV_ORIGIN).port : Number(undefined) || 8002;"
);
});

it("determines the right port based on REMIX_DEV_SERVER_WS_PORT env variable", () => {
process.env.REMIX_DEV_SERVER_WS_PORT = "1234";
let { container } = render(<LiveReload />);
expect(container.querySelector("script")).toHaveTextContent(
"url.port = undefined || REMIX_DEV_ORIGIN ? new URL(REMIX_DEV_ORIGIN).port : Number(1234) || 8002;"
"url.port = 4321 || REMIX_DEV_ORIGIN ? new URL(REMIX_DEV_ORIGIN).port : 8002;"
);
});

Expand Down
4 changes: 0 additions & 4 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1308,10 +1308,6 @@ export const LiveReload =
url.port =
${port} ||
REMIX_DEV_ORIGIN ? new URL(REMIX_DEV_ORIGIN).port :
Number(${
// TODO: remove in v2
process.env.REMIX_DEV_SERVER_WS_PORT
}) ||
8002;
let ws = new WebSocket(url.href);
Expand Down

0 comments on commit f964197

Please sign in to comment.