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 cccb30e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
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 cccb30e

Please sign in to comment.