Initial bundle server prototype

This commit is contained in:
Michaël Lemaire 2020-05-13 16:39:34 +02:00
commit 175ee5018f
5 changed files with 49 additions and 0 deletions

9
.editorconfig Normal file
View 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
View file

@ -0,0 +1,3 @@
deno.d.ts
.vscode
.local

3
README.md Normal file
View 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
View 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
View file

@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "esnext",
"target": "ESNext",
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"preserveConstEnums": true
}
}