commit 175ee5018f4e5f8ca90cd1b1eff365a3a100c652 Author: Michaƫl Lemaire Date: Wed May 13 16:39:34 2020 +0200 Initial bundle server prototype diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..83c1115 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d69a4c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +deno.d.ts +.vscode +.local diff --git a/README.md b/README.md new file mode 100644 index 0000000..5152fc0 --- /dev/null +++ b/README.md @@ -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) diff --git a/server.ts b/server.ts new file mode 100644 index 0000000..2b691f7 --- /dev/null +++ b/server.ts @@ -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}");` }); + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e28737f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "module": "esnext", + "target": "ESNext", + "strict": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "preserveConstEnums": true + } +}