Skip to content

Commit

Permalink
ci: add typechecking for deno
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Nov 30, 2022
1 parent a79f828 commit 5178317
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-clocks-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/deno": patch
---

Fix types for request handler context
10 changes: 10 additions & 0 deletions .github/workflows/reusable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
node-version-file: ".nvmrc"
cache: "yarn"

- name: 🦕 Setup deno
uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x

- name: 📥 Install deps
run: yarn --frozen-lockfile

Expand Down Expand Up @@ -65,6 +70,11 @@ jobs:
node-version: ${{ matrix.node }}
cache: "yarn"

- name: 🦕 Setup deno
uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x

- name: 📥 Install deps
run: yarn --frozen-lockfile

Expand Down
14 changes: 8 additions & 6 deletions .vscode/deno_resolve_npm_imports.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"// Resolve NPM imports for `packages/remix-deno`.": "",
"// This import map is used solely for the denoland.vscode-deno extension.": "",
"// Remix does not support import maps.": "",
"// Dependency management is done through `npm` and `node_modules/` instead.": "",
"// Deno-only dependencies may be imported via URL imports (without using import maps).": "",
"comment": [
"Resolve NPM imports for `packages/remix-deno`.",
"This import map is used solely for the denoland.vscode-deno extension.",
"Remix does not support import maps.",
"Dependency management is done through `npm` and `node_modules/` instead.",
"Deno-only dependencies may be imported via URL imports (without using import maps)."
],
"imports": {
"@remix-run/server-runtime": "https://esm.sh/@remix-run/server-runtime@1.6.4",
"@remix-run/server-runtime": "https://esm.sh/@remix-run/server-runtime@nightly",
"mime": "https://esm.sh/mime@3.0.0"
}
}
15 changes: 11 additions & 4 deletions packages/remix-deno/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as path from "https://deno.land/std@0.128.0/path/mod.ts";
import mime from "mime";
import { createRequestHandler as createRemixRequestHandler } from "@remix-run/server-runtime";
import {
AppLoadContext,
createRequestHandler as createRemixRequestHandler,
} from "@remix-run/server-runtime";
import type { ServerBuild } from "@remix-run/server-runtime";

function defaultCacheControl(url: URL, assetsPublicPath = "/build/") {
Expand All @@ -11,7 +14,9 @@ function defaultCacheControl(url: URL, assetsPublicPath = "/build/") {
}
}

export function createRequestHandler<Context = unknown>({
export function createRequestHandler<
Context extends AppLoadContext | undefined = undefined
>({
build,
mode,
getLoadContext,
Expand Down Expand Up @@ -51,7 +56,7 @@ export async function serveStaticFiles(
cacheControl?: string | ((url: URL) => string);
publicDir?: string;
assetsPublicPath?: string;
},
}
) {
const url = new URL(request.url);

Expand Down Expand Up @@ -81,7 +86,9 @@ export async function serveStaticFiles(
}
}

export function createRequestHandlerWithStaticFiles<Context = unknown>({
export function createRequestHandlerWithStaticFiles<
Context extends AppLoadContext | undefined = undefined
>({
build,
mode,
getLoadContext,
Expand Down
11 changes: 11 additions & 0 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { spawn } from "cross-spawn";
import glob from "glob";

const args = process.argv.slice(2);
const tsc = process.env.CI || args.includes("--tsc");
const publish = process.env.CI || args.includes("--publish");
const denoCheck = process.env.CI || args.includes("--deno");

exec("yarn", ["rollup", "-c"])
.then(() => tsc && exec("yarn", ["tsc", "-b"]))
.then(
() =>
denoCheck &&
exec("deno", [
"check",
"--import-map=.vscode/deno_resolve_npm_imports.json",
...glob.sync("packages/remix-deno/**/*.ts"),
])
)
.then(() => publish && exec("node", ["scripts/copy-build-to-dist.mjs"]))
.then(() => process.exit(0))
.catch((err) => {
Expand Down

0 comments on commit 5178317

Please sign in to comment.