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

ci: add typechecking for deno #4715

Merged
merged 2 commits into from
Nov 30, 2022
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
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
25 changes: 25 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
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
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 Expand Up @@ -97,6 +107,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 Expand Up @@ -128,6 +143,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 Expand Up @@ -159,6 +179,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)."
],
Comment on lines +2 to +8
Copy link
Contributor Author

@ascorbic ascorbic Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved it here because otherwise the typechecker gives lots of scary-looking warnings. Now it just gives one, less scary warning.

"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",
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
"mime": "https://esm.sh/mime@3.0.0"
}
}
12 changes: 8 additions & 4 deletions packages/remix-deno/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 type { ServerBuild } from "@remix-run/server-runtime";
import type { AppLoadContext, ServerBuild } from "@remix-run/server-runtime";

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

export function createRequestHandler<Context = unknown>({
export function createRequestHandler<
Context extends AppLoadContext | undefined = undefined
>({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a type error that the typecheck uncovered

build,
mode,
getLoadContext,
Expand Down Expand Up @@ -51,7 +53,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 +83,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