create-sanifyfe 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/default/README.md +8 -1
- package/templates/default/dev-server.ts +7 -36
- package/templates/default/env.d.ts +14 -0
- package/templates/default/index.html +1 -1
- package/templates/default/package.json +1 -1
- package/templates/default/src/app.ts +2 -0
- package/templates/default/src/components/live-clock.ts +2 -0
- package/templates/default/src/components/nav-bar.ts +2 -0
- package/templates/default/src/components/todo-item.ts +2 -0
- package/templates/default/src/components/users-sidebar.ts +2 -0
- package/templates/default/src/pages/about-page.ts +2 -0
- package/templates/default/src/pages/home-page.ts +2 -0
- package/templates/default/src/pages/settings-page.ts +2 -0
- package/templates/default/src/pages/todos-page.ts +2 -0
- package/templates/default/src/pages/user-detail.ts +2 -0
- package/templates/default/src/pages/user-list.ts +2 -0
- package/templates/default/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ bun install
|
|
|
16
16
|
|
|
17
17
|
| Perintah | Fungsi |
|
|
18
18
|
| --- | --- |
|
|
19
|
-
| `bun dev` |
|
|
19
|
+
| `bun dev` | Dev server di http://localhost:3000 dengan **HMR** |
|
|
20
20
|
| `bun run build` | Bundle produksi ke `dist/` |
|
|
21
21
|
| `bun run typecheck` | Cek tipe TypeScript |
|
|
22
22
|
|
|
@@ -43,3 +43,10 @@ dev-server.ts server dev Bun, transpile TS on-the-fly
|
|
|
43
43
|
| Settings | `createStore` objek nested fine-grained (update by path) |
|
|
44
44
|
| Users | router **nested + outlet** (layout bertahan), `params()` reaktif, `resource` (fetch async) |
|
|
45
45
|
| About | `query()` reaktif |
|
|
46
|
+
|
|
47
|
+
## HMR
|
|
48
|
+
|
|
49
|
+
`bun dev` mendukung Hot Module Replacement. Edit file komponen → tampilan
|
|
50
|
+
ter-update tanpa reload, dan state global (`persisted`/`createStore`) tetap.
|
|
51
|
+
State lokal di dalam `setup` (mis. signal) ter-reset saat hot-remount. Tiap file
|
|
52
|
+
komponen punya `if (import.meta.hot) import.meta.hot.accept();` di bawahnya.
|
|
@@ -1,42 +1,13 @@
|
|
|
1
|
-
// dev-server.ts — dev server
|
|
1
|
+
// dev-server.ts — dev server Bun dengan HMR (import.meta.hot) + bundling otomatis
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import index from "./index.html";
|
|
4
4
|
|
|
5
5
|
const server = Bun.serve({
|
|
6
|
-
port:
|
|
7
|
-
development: true,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let path = url.pathname;
|
|
11
|
-
if (path === "/") path = "/index.html";
|
|
12
|
-
|
|
13
|
-
// bundel entry TS aplikasi on-the-fly
|
|
14
|
-
if (path === "/main.js") {
|
|
15
|
-
const built = await Bun.build({
|
|
16
|
-
entrypoints: ["./src/main.ts"],
|
|
17
|
-
target: "browser",
|
|
18
|
-
});
|
|
19
|
-
if (!built.success) {
|
|
20
|
-
return new Response("Build error:\n" + built.logs.join("\n"), {
|
|
21
|
-
status: 500,
|
|
22
|
-
headers: { "Content-Type": "text/plain" },
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const js = await built.outputs[0]!.text();
|
|
26
|
-
return new Response(js, {
|
|
27
|
-
headers: { "Content-Type": "application/javascript" },
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// file statis dari root project
|
|
32
|
-
const file = Bun.file("." + path);
|
|
33
|
-
if (await file.exists()) return new Response(file);
|
|
34
|
-
|
|
35
|
-
// SPA fallback: route apa pun → index.html
|
|
36
|
-
return new Response(Bun.file("./index.html"), {
|
|
37
|
-
headers: { "Content-Type": "text/html" },
|
|
38
|
-
});
|
|
6
|
+
port: 3000,
|
|
7
|
+
development: { hmr: true, console: true },
|
|
8
|
+
routes: {
|
|
9
|
+
"/*": index, // SPA: semua route → index.html
|
|
39
10
|
},
|
|
40
11
|
});
|
|
41
12
|
|
|
42
|
-
console.log(`Dev server:
|
|
13
|
+
console.log(`Dev server: ${server.url}`);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Tipe fitur dev Bun: import file .html & HMR (import.meta.hot).
|
|
2
|
+
|
|
3
|
+
declare module "*.html" {
|
|
4
|
+
const content: import("bun").HTMLBundle;
|
|
5
|
+
export default content;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface ImportMeta {
|
|
9
|
+
hot?: {
|
|
10
|
+
accept(callback?: (module: unknown) => void): void;
|
|
11
|
+
dispose(callback: (data: unknown) => void): void;
|
|
12
|
+
data: unknown;
|
|
13
|
+
};
|
|
14
|
+
}
|