diff --git a/deno.lock b/deno.lock index d0a6c03..2ddc6fc 100644 --- a/deno.lock +++ b/deno.lock @@ -312,6 +312,7 @@ "https://deno.land/x/denoflate@1.2.1/pkg/denoflate_bg.wasm.js": "d581956245407a2115a3d7e8d85a9641c032940a8e810acbd59ca86afd34d44d", "https://deno.land/x/esbuild@v0.14.51/mod.js": "7432566c71fac77637822dc230319c7392a2d2fef51204c9d12c956d7093c279", "https://deno.land/x/esbuild@v0.14.51/wasm.js": "afc1b6927543b664af60ce452c4929e5dc2bb9a0f4ed47b446a6431847c7598e", + "https://deno.land/x/esbuild@v0.19.2/mod.js": "d619154b9c1cc70e8ee4b8db94fb01f00767c9e83089c135cede0cd3edd342a0", "https://deno.land/x/esbuild@v0.19.6/mod.js": "60e627081a3309803115fe336274209164d99876c6e30dbe322f0d74700f4488", "https://deno.land/x/esbuild_deno_loader@0.5.2/deps.ts": "bf83c27b7787b2f245fa0bc0b99f5041aa949c000a81c016cfe828d06b476d37", "https://deno.land/x/esbuild_deno_loader@0.5.2/mod.ts": "bc111a68f323dbdb6edec68dd558ab732b27866d2ef304708872d763387b65d7", diff --git a/src/bundler.ts b/src/bundler.ts index 97b8bd1..f103d24 100644 --- a/src/bundler.ts +++ b/src/bundler.ts @@ -3,7 +3,8 @@ * See https://github.com/denoland/fresh/blob/main/src/server/bundle.ts */ -import * as esbuildNative from "https://deno.land/x/esbuild@v0.19.6/mod.js"; +import * as esbuild from "https://deno.land/x/esbuild@v0.19.2/mod.js"; + import { denoPlugins } from "https://deno.land/x/esbuild_deno_loader@0.8.2/mod.ts"; @@ -13,7 +14,7 @@ async function verifyEsbuildInitialized(): Promise { return; } console.log(new Date(), "start initializing esbuild"); - await esbuildNative.initialize({}); + await esbuild.initialize({}); esbuildInitialized = true; console.log(new Date(), "esbuild initialized"); @@ -27,7 +28,7 @@ export async function createBundle( await verifyEsbuildInitialized(); console.log(new Date(), "Bundling", entryPoint.href); const absWorkingDir = Deno.cwd(); - const res = await esbuildNative.build({ + const res = await esbuild.build({ bundle: true, entryPoints: [entryPoint.href], platform: "neutral", @@ -35,12 +36,12 @@ export async function createBundle( minify: !isDev, sourcemap: isDev ? "inline" : false, outfile: "", - absWorkingDir, + absWorkingDir: Deno.env.get('XDG_CACHE_HOME') , outdir: ".", target: ["chrome99", "firefox99", "safari15"], write: false, format: "esm", - plugins: [...denoPlugins({ importMapURL })], + plugins: [...denoPlugins({ importMapURL: importMapURL.href })], splitting: false, jsx: "automatic", jsxImportSource: "react", diff --git a/src/server.ts b/src/server.ts index af0e430..4c8752b 100644 --- a/src/server.ts +++ b/src/server.ts @@ -10,7 +10,7 @@ type QuestionAnswer = { const router = new Router(); -const clientBundle = createBundle( +const prodClientBundle = createBundle( new URL("./client.ts", import.meta.url), new URL("../import_map.json", import.meta.url), false, @@ -187,11 +187,12 @@ router.get("/api/v1/results", async (context): Promise => { }); router.get("/client.js", async (context): Promise => { - context.response.body = await createBundle( - new URL("./client.ts", import.meta.url), - new URL("../import_map.json", import.meta.url), - false, - ); + context.response.body = await prodClientBundle; + // context.response.body = await createBundle( + // new URL("./client.ts", import.meta.url), + // new URL("../import_map.json", import.meta.url), + // true, + // ); context.response.type = "application/javascript"; });