Initial bundle server prototype
This commit is contained in:
commit
175ee5018f
9
.editorconfig
Normal file
9
.editorconfig
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*.{ts,json}]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
deno.d.ts
|
||||||
|
.vscode
|
||||||
|
.local
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# typescript/bundler
|
||||||
|
|
||||||
|
[![Build Status](https://thunderk.visualstudio.com/typescript/_apis/build/status/bundler?branchName=master)](https://dev.azure.com/thunderk/typescript/_build?pipelineNameFilter=bundler)
|
24
server.ts
Normal file
24
server.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// Automated bundle server
|
||||||
|
|
||||||
|
import { serve } from "https://deno.land/std/http/server.ts";
|
||||||
|
import { bool } from "https://code.thunderk.net/typescript/functional/raw/1.0.0/all.ts";
|
||||||
|
|
||||||
|
const server = serve({ port: 8000 });
|
||||||
|
for await (const req of server) {
|
||||||
|
const params = req.url.split("/").filter(bool);
|
||||||
|
const lib = params[0] || "all";
|
||||||
|
const version = params[1] || "master";
|
||||||
|
const file = params.length > 2 ? params.slice(2).join("/") : "all";
|
||||||
|
const path =
|
||||||
|
`https://code.thunderk.net/typescript/${lib}/raw/${version}/${file}.ts`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const process = Deno.run({
|
||||||
|
cmd: ["deno", "bundle", path],
|
||||||
|
stdout: "piped",
|
||||||
|
});
|
||||||
|
req.respond({ body: await process.output() });
|
||||||
|
} catch {
|
||||||
|
req.respond({ body: `console.error("Failed to bundle ${path}");` });
|
||||||
|
}
|
||||||
|
}
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "esnext",
|
||||||
|
"target": "ESNext",
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"preserveConstEnums": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue