Skip to content

Commit 7d7761a

Browse files
committed
Make vite deno integration test work
1 parent 1228943 commit 7d7761a

File tree

10 files changed

+81
-29
lines changed

10 files changed

+81
-29
lines changed

.github/workflows/format.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ jobs:
3030
node-version-file: ".nvmrc"
3131
cache: "pnpm"
3232

33+
- name: 🦕 Install Deno
34+
uses: denoland/setup-deno@v1
35+
with:
36+
deno-version: vx.x.x
37+
3338
- name: 📥 Install deps
3439
run: pnpm install --frozen-lockfile
3540

@@ -42,11 +47,6 @@ jobs:
4247
- name: 👔 Format
4348
run: pnpm format
4449

45-
- name: 🦕 Install Deno
46-
uses: denoland/setup-deno@v1
47-
with:
48-
deno-version: vx.x.x
49-
5050
- name: 👔 Format Deno files
5151
run: pnpm format:deno
5252

.github/workflows/lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
node-version-file: ".nvmrc"
2929
cache: "pnpm"
3030

31+
- name: 🦕 Install Deno
32+
uses: denoland/setup-deno@v1
33+
with:
34+
deno-version: vx.x.x
35+
3136
- name: Disable GitHub Actions Annotations
3237
run: |
3338
echo "::remove-matcher owner=tsc::"
@@ -40,10 +45,5 @@ jobs:
4045
- name: 🔬 Lint
4146
run: pnpm lint
4247

43-
- name: 🦕 Install Deno
44-
uses: denoland/setup-deno@v1
45-
with:
46-
deno-version: vx.x.x
47-
4848
- name: 🔬 Lint deno files
4949
run: pnpm lint:deno

.github/workflows/shared-test-unit.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ jobs:
3838
node-version: ${{ matrix.node }}
3939
cache: "pnpm"
4040

41+
- name: 🦕 Install Deno
42+
uses: denoland/setup-deno@v1
43+
with:
44+
deno-version: vx.x.x
45+
4146
- name: Disable GitHub Actions Annotations
4247
run: |
4348
echo "::remove-matcher owner=tsc::"
@@ -47,11 +52,6 @@ jobs:
4752
- name: 📥 Install deps
4853
run: pnpm install --frozen-lockfile
4954

50-
- name: 🦕 Install Deno
51-
uses: denoland/setup-deno@v1
52-
with:
53-
deno-version: vx.x.x
54-
5555
# It's faster to use the built `cli.js` in tests if its available and up-to-date
5656
- name: 🏗 Build
5757
run: pnpm build

integration/helpers/vite-deno-template/deno.jsonc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
{
22
"tasks": {
3-
"build": "deno run -A npm:@remix-run/dev@^2.11.2 vite:build",
4-
"dev": "deno run -A npm:@remix-run/dev@^2.11.2 vite:dev",
3+
"build": "deno run -A npm:@remix-run/dev@* vite:build",
4+
"dev": "deno run -A npm:@remix-run/dev@* vite:dev",
55
"typecheck": "deno check '**/*' && deno run -A npm:typescript@^5.5.4/tsc",
66
"typegen": "deno types > ./app/deno.d.ts"
77
},
88
"exclude": ["app/", "build/"],
99
"nodeModulesDir": true,
10+
"unstable": ["kv"],
1011
"imports": {
11-
"@remix-run/dev": "npm:@remix-run/dev@^2.11.2",
12-
"@remix-run/express": "npm:@remix-run/express@^2.11.2",
13-
"@remix-run/react": "npm:@remix-run/react@^2.11.2",
14-
"@remix-run/server-runtime": "npm:@remix-run/server-runtime@^2.11.2",
15-
"@std/http": "jsr:@std/http@^1.0.4",
16-
"@std/path": "jsr:@std/path@^1.0.3",
17-
"@types/node": "npm:@types/node@^22.5.1",
12+
// These remix packages should be treated like workspace:* dependencies.
13+
"@remix-run/dev": "npm:@remix-run/dev@*",
14+
"@remix-run/react": "npm:@remix-run/react@*",
15+
"@remix-run/server-runtime": "npm:@remix-run/server-runtime@*",
1816
"@types/react": "npm:@types/react@^18.3.5",
1917
"@types/react-dom": "npm:@types/react-dom@^18.3.0",
2018
"isbot": "npm:isbot@^5.1.17",
21-
"postcss": "npm:postcss@^8.4.41",
2219
"react": "npm:react@^18.3.1",
2320
"react-dom": "npm:react-dom@^18.3.1",
2421
"typescript": "npm:typescript@^5.5.4",

integration/helpers/vite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ async function waitForServer(
396396
let devStderr = bufferize(proc.stderr);
397397

398398
await waitOn({
399-
resources: [`http://localhost:${args.port}${args.basename ?? "/"}`],
399+
resources: [`http://127.0.0.1:${args.port}${args.basename ?? "/"}`],
400400
timeout: 10000,
401401
}).catch((err) => {
402402
let stdout = devStdout();

integration/vite-deno-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { test, viteConfig } from "./helpers/vite.js";
66

77
const files: Files = async ({ port }) => ({
88
"vite.config.ts": dedent`
9+
import { vitePlugin as remix } from "@remix-run/dev";
10+
911
export default {
1012
${await viteConfig.server({ port })}
1113
plugins: [

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"playground:new": "node ./scripts/playground/new.js",
1818
"publish": "node ./scripts/publish.js",
1919
"publish:private": "node ./scripts/publish-private.js",
20+
"prepare": "node ./scripts/install-deno-deps.js integration/helpers/vite-deno-template templates/deno",
2021
"release": "node ./scripts/release.js",
2122
"test": "pnpm run \"/^test:.*/\"",
2223
"pretest:integration": "pnpm build",

packages/remix-dev/config/defaults/entry.server.deno.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { AppLoadContext, EntryContext } from "@remix-run/server-runtime";
22
import { RemixServer } from "@remix-run/react";
33
import * as isbotModule from "isbot";
4-
import { renderToReadableStream } from "react-dom/server";
4+
import { renderToReadableStream } from "react-dom/server.browser";
55

66
export default async function handleRequest(
77
request: Request,

scripts/copy-build-to-dist.mjs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import path from "node:path";
2-
import fse from "fs-extra";
31
import chalk from "chalk";
2+
import fse from "fs-extra";
3+
import path from "node:path";
44

55
const args = process.argv.slice(2);
66
const tsc = process.env.CI || args.includes("--tsc");
@@ -9,6 +9,11 @@ const ROOT_DIR = process.cwd();
99
const PACKAGES_PATH = path.join(ROOT_DIR, "packages");
1010
const DEFAULT_BUILD_PATH = path.join(ROOT_DIR, "build");
1111

12+
// pnpm workspaces do not understand Deno projects and vice versa so we need to specify which projects need their node_modules updating
13+
const DENO_NODE_MODULES_PATHS = [
14+
path.join(ROOT_DIR, "integration/helpers/vite-deno-template/node_modules"),
15+
];
16+
1217
let activeOutputDir = DEFAULT_BUILD_PATH;
1318
if (process.env.LOCAL_BUILD_DIRECTORY) {
1419
let appDir = path.resolve(process.env.LOCAL_BUILD_DIRECTORY);
@@ -38,6 +43,8 @@ async function copyBuildToDist() {
3843
PACKAGES_PATH,
3944
parentDir === "@remix-run" ? `remix-${dirName}` : dirName
4045
),
46+
nodeModulesPath:
47+
parentDir === "@remix-run" ? `${parentDir}/${dirName}` : dirName,
4148
};
4249
});
4350

@@ -57,6 +64,28 @@ async function copyBuildToDist() {
5764
let copyQueue = [];
5865
for (let pkg of packages) {
5966
try {
67+
// Copy entire build artifact to node_modules dir for each Deno project that requires it
68+
for (let denoNodeModulesPath of DENO_NODE_MODULES_PATHS) {
69+
let destPath = path.join(denoNodeModulesPath, pkg.nodeModulesPath);
70+
if (await fse.pathExists(destPath)) {
71+
copyQueue.push(
72+
(async () => {
73+
console.log(
74+
chalk.yellow(
75+
` 🛠 🦕 Copying ${path.relative(
76+
ROOT_DIR,
77+
pkg.build
78+
)} to ${path.relative(ROOT_DIR, destPath)}`
79+
)
80+
);
81+
fse.copy(pkg.build, destPath, {
82+
recursive: true,
83+
});
84+
})()
85+
);
86+
}
87+
}
88+
6089
let srcPath = path.join(pkg.build, "dist");
6190
let destPath = path.join(pkg.src, "dist");
6291
if (!(await fse.stat(srcPath)).isDirectory()) {

scripts/install-deno-deps.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { spawnSync } = require("node:child_process");
2+
const path = require("node:path");
3+
4+
const denoProjectPaths = process.argv
5+
.slice(2)
6+
.map((denoProjectDir) => path.join(process.cwd(), denoProjectDir));
7+
8+
for (let denoProjectPath of denoProjectPaths) {
9+
let { error } = spawnSync("deno", ["install", "--no-lock"], {
10+
cwd: denoProjectPath,
11+
env: { ...process.env, DENO_FUTURE: "1" },
12+
stdio: "inherit",
13+
});
14+
15+
if (error) {
16+
console.warn(
17+
new Error(
18+
`Failed to install dependencies for Deno project at ${denoProjectPath}`,
19+
{ cause: error }
20+
)
21+
);
22+
}
23+
}

0 commit comments

Comments
 (0)