Skip to content

Commit

Permalink
fix: npm specifiers in example code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Ringrose committed Apr 27, 2024
1 parent d389ec3 commit f217a4b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 255 deletions.
15 changes: 11 additions & 4 deletions example/preactSSR/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> =
(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) ||
{};

Expand Down Expand Up @@ -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({
Expand All @@ -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) => {
Expand Down
7 changes: 3 additions & 4 deletions example/preactSSR/src/components/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ const Layout = ({
<nav style=${navStyle(navColor)}>
<div class="container align-center">
<img
height="200px"
width="1000px"
style="max-width:100%; margin: 1rem;"
src="https://raw.githubusercontent.com/sejori/peko/examples/preact/assets/logo_dark_alpha.webp"
height="270px"
style="margin: 1rem;"
src="https://raw.githubusercontent.com/sejori/peko/main/example/preactSSR/assets/logo_dark_alpha.webp"
alt="peko-logo"
/>
<h1 style="text-align: center;">
Expand Down
6 changes: 1 addition & 5 deletions example/preactSSR/src/pages/Home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ const Home = () => {
<li>100% TypeScript complete with tests.</li>
</ul>
<h2>Guides</h2>
<ol>
<li><a href="https://github.com/sebringrose/peko/blob/main/react.md">How to build a full-stack React application with Peko and Deno</a></li>
<li>Want to build a lightweight HTML or Preact app? Check out the <a href="https://github.com/sebringrose/peko/blob/main/examples">examples</a>!</li>
</ol>
<p>Want to build a full-stack app with Peko? Check out the <a href="https://github.com/sebringrose/peko/blob/main/examples">examples</a>!</p>
<div style="display: flex; justify-content: space-between; flex-wrap: wrap;">
<div>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
},
"type": "module",
"scripts": {
"start": "deno run --allow-net --allow-read --allow-env scripts/deno/main.ts",
"start": "deno run --allow-net --allow-read --allow-env --allow-run scripts/deno/main.ts",
"test": "deno test --allow-read --allow-net",
"profile:deno": "deno run --allow-read --allow-net scripts/deno/profile.ts",
"profile:bun": "bun run scripts/bun/profile.ts",
"profile:start:wrangler": "wrangler dev scripts/wrangler/testApp.ts",
"profile:wrangler": "node --loader ts-node/esm scripts/wrangler/profile.ts",
"start:dev:deno": "deno run --allow-net --allow-read --allow-env --watch scripts/deno/main.ts",
"start:dev:deno": "deno run -A --watch scripts/deno/main.ts",
"start:dev:bun": "bun run --watch scripts/bun/main.ts",
"start:dev:wrangler": "wrangler dev scripts/wrangler/main.ts"
},
Expand All @@ -36,7 +36,7 @@
"wrangler": "^3.30.1"
},
"dependencies": {
"esbuild": "^0.20.1",
"esbuild-wasm": "^0.20.1",
"htm": "^3.1.1",
"preact": "^10.19.6",
"preact-render-to-string": "^6.4.0"
Expand Down
Loading

1 comment on commit f217a4b

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on f217a4b Apr 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

Relative import path "preact-render-to-string" not prefixed with / or ./ or ../

Please sign in to comment.