From a36e04566aa81d47df42bbf0a3382bad7276d251 Mon Sep 17 00:00:00 2001
From: James Edmonds
Date: Sat, 1 Jul 2023 02:34:47 +0000
Subject: [PATCH 1/8] feat: support @/ special prefix
---
examples/basic/deno.json | 2 +-
examples/basic/importMap.json | 3 ++-
examples/basic/server.tsx | 4 +---
examples/basic/src/app.tsx | 2 ++
examples/basic/src/components/Button.tsx | 10 ++++++++++
lib/stream.ts | 6 +++++-
6 files changed, 21 insertions(+), 6 deletions(-)
create mode 100644 examples/basic/src/components/Button.tsx
diff --git a/examples/basic/deno.json b/examples/basic/deno.json
index 8080d9f1..7e153f62 100644
--- a/examples/basic/deno.json
+++ b/examples/basic/deno.json
@@ -1,6 +1,6 @@
{
"tasks": {
- "dev": "deno run -A --no-check --watch ./server.tsx",
+ "dev": "ULTRA_MODE=development deno run -A --no-check --watch ./server.tsx",
"test": "deno test --allow-all",
"build": "deno run -A ./build.ts",
"start": "ULTRA_MODE=production deno run -A --no-remote ./server.js"
diff --git a/examples/basic/importMap.json b/examples/basic/importMap.json
index 8e37d5da..11f56a23 100644
--- a/examples/basic/importMap.json
+++ b/examples/basic/importMap.json
@@ -6,6 +6,7 @@
"react-dom/server": "https://esm.sh/v122/react-dom@18.2.0/server?dev",
"react-dom/client": "https://esm.sh/v122/react-dom@18.2.0/client?dev",
"ultra/": "https://deno.land/x/ultra@v2.2.4/",
- "@ultra/qrcode/": "https://deno.land/x/qrcode@v2.0.0/"
+ "@ultra/qrcode/": "https://deno.land/x/qrcode@v2.0.0/",
+ "@/": "./src/"
}
}
diff --git a/examples/basic/server.tsx b/examples/basic/server.tsx
index ee138397..9404e94f 100644
--- a/examples/basic/server.tsx
+++ b/examples/basic/server.tsx
@@ -3,9 +3,7 @@ import { createServer } from "ultra/server.ts";
import App from "./src/app.tsx";
const server = await createServer({
- importMapPath: Deno.env.get("ULTRA_MODE") === "development"
- ? import.meta.resolve("./importMap.dev.json")
- : import.meta.resolve("./importMap.json"),
+ importMapPath: import.meta.resolve("./importMap.json"),
browserEntrypoint: import.meta.resolve("./client.tsx"),
});
diff --git a/examples/basic/src/app.tsx b/examples/basic/src/app.tsx
index 39333fdb..9b7ade63 100644
--- a/examples/basic/src/app.tsx
+++ b/examples/basic/src/app.tsx
@@ -1,5 +1,6 @@
import useAsset from "ultra/hooks/use-asset.js";
import useEnv from "ultra/hooks/use-env.js";
+import Button from "@/components/Button.tsx";
export default function App() {
// Read our environment variable from '.env' or the host environment
@@ -37,6 +38,7 @@ export default function App() {
customise your routing, data fetching, and styling with popular
libraries.
+