Browse Source

Initial bundle server prototype

master
Michaël Lemaire 1 year ago
commit
175ee5018f
  1. 9
      .editorconfig
  2. 3
      .gitignore
  3. 3
      README.md
  4. 24
      server.ts
  5. 10
      tsconfig.json

9
.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

3
.gitignore

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

3
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)

24
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}");` });
}
}

10
tsconfig.json

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