diff --git a/.github/workflows/tests-e2e.yml b/.github/workflows/tests-e2e.yml index 36b239a..39e7047 100644 --- a/.github/workflows/tests-e2e.yml +++ b/.github/workflows/tests-e2e.yml @@ -27,9 +27,6 @@ jobs: working-directory: packages/reflow run: deno run -A npm:playwright install chromium - - name: Build - run: deno task build - - name: Run e2e tests working-directory: packages/reflow run: deno task e2e diff --git a/deno.jsonc b/deno.jsonc index 8ae4d6f..c2982b4 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -39,5 +39,6 @@ "@std/fs": "jsr:@std/fs@^1.0.19", "@std/path": "jsr:@std/path@^1.1.2" }, - "nodeModulesDir": "auto" + "nodeModulesDir": "auto", + "unstable": ["bundle"] } diff --git a/index.html b/index.html index 8ea4fb1..d361c2f 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ @@ -28,6 +28,33 @@ const template = (path: string) => ` `; +const build: Record = {}; + +const entrypoints = [ + join(rootDir, "packages/functorial/src/reactive.ts"), + join(rootDir, "packages/reflow/src/html.js"), +]; + +for (const entrypoint of entrypoints) { + const filename = basename(entrypoint); + console.log("building", filename); + + // @ts-ignore FUTUR `Deno.bundle` types missing + const result = await Deno.bundle({ + entrypoints: [entrypoint], + format: "esm", + minify: false, + codeSplitting: false, + inlineImports: false, + packages: "external", + platform: "browser", + write: false, + }); + + const [file] = result.outputFiles; + build[filename] = file.text(); +} + /** * Test server */ @@ -44,11 +71,19 @@ export default { }); } - if (extension === ".js") { - const dest = path.startsWith("/packages") - ? join(rootDir, path) - : join(moduleDir, path); + if (extension === ".js" || extension === ".ts") { + if (path.startsWith("/packages")) { + const filename = basename(path); + const file = build[filename]; + + if (!file) throw new Deno.errors.NotFound(`Not found: ${path}`); + + return new Response(file, { + headers: { "content-type": "application/javascript" }, + }); + } + const dest = join(moduleDir, path); const file = Deno.readTextFileSync(dest); return new Response(file, {