From f217a4bfa122d708864b8b5faeb5e7981579773b Mon Sep 17 00:00:00 2001 From: Sebastien Ringrose Date: Sat, 27 Apr 2024 14:46:49 +0100 Subject: [PATCH] fix: npm specifiers in example code --- example/preactSSR/router.ts | 15 +- example/preactSSR/src/components/Layout.ts | 7 +- example/preactSSR/src/pages/Home.ts | 6 +- package.json | 6 +- pnpm-lock.yaml | 246 +-------------------- 5 files changed, 25 insertions(+), 255 deletions(-) diff --git a/example/preactSSR/router.ts b/example/preactSSR/router.ts index f75fb50e..0d433b23 100644 --- a/example/preactSSR/router.ts +++ b/example/preactSSR/router.ts @@ -15,11 +15,18 @@ import About from "./src/pages/About.ts"; import htmlTemplate from "./document.ts"; // esbuild bundling for app TS files -import * as esbuild from "esbuild"; +import * as esbuild from "npm:esbuild-wasm"; +let initialized = false; +if (!initialized) { + await esbuild.initialize({}); + initialized = true; +} const env: Record = (typeof Deno !== "undefined" && Deno.env.toObject()) || + // @ts-ignore - cross-platform env support (typeof process !== "undefined" && process.env) || + // @ts-ignore - cross-platform env support (typeof env !== "undefined" && env) || {}; @@ -75,7 +82,7 @@ router.get("/assets/:filename", cacher(), async (ctx) => ( await file( new URL( - `https://raw.githubusercontent.com/sejori/peko/main/example/preact/assets/${ctx.params.filename}` + `https://raw.githubusercontent.com/sejori/peko/main/example/preactSSR/assets/${ctx.params.filename}` ), { headers: new Headers({ @@ -92,11 +99,11 @@ router.get("/assets/:filename", cacher(), async (ctx) => // BUNDLED TS FILES // dynamic URL param for filename, always cache -router.get("/src/:filename", cacher(), async (ctx) => +router.get("/src/:dirname/:filename", cacher(), async (ctx) => ( await file( new URL( - `https://raw.githubusercontent.com/sejori/peko/main/example/preact/src/${ctx.params.filename}` + `https://raw.githubusercontent.com/sejori/peko/main/example/preactSSR/src/${ctx.params.dirname}/${ctx.params.filename}` ), { transform: async (contents) => { diff --git a/example/preactSSR/src/components/Layout.ts b/example/preactSSR/src/components/Layout.ts index 4f388cbe..75152d26 100644 --- a/example/preactSSR/src/components/Layout.ts +++ b/example/preactSSR/src/components/Layout.ts @@ -13,10 +13,9 @@ const Layout = ({