create-jant 0.3.26 → 0.3.28

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.
@@ -1,212 +0,0 @@
1
- import { defineConfig, type Plugin } from "vite";
2
- import { cloudflare } from "@cloudflare/vite-plugin";
3
- import swc from "unplugin-swc";
4
- import tailwindcss from "@tailwindcss/vite";
5
- import { resolve } from "path";
6
- import { readFileSync, writeFileSync, readdirSync } from "fs";
7
-
8
- /**
9
- * Trigger full page reload when server/worker code changes.
10
- * @cloudflare/vite-plugin only hot-updates the worker module,
11
- * but for SSR apps the browser needs a full reload to see new HTML.
12
- */
13
- function ssrReload(): Plugin {
14
- return {
15
- name: "ssr-reload",
16
- hotUpdate({ modules, server }) {
17
- if (this.environment.name !== "client" && modules.length > 0) {
18
- server.hot.send({ type: "full-reload" });
19
- return [];
20
- }
21
- },
22
- };
23
- }
24
-
25
- /**
26
- * Inject manifest content into SSR bundle for vite-ssr-components.
27
- *
28
- * The worker environment builds before the client environment, so the client
29
- * manifest may not exist during the worker's transform phase. We handle both
30
- * cases:
31
- * 1. transform hook – works when a previous client build already exists.
32
- * 2. writeBundle hook – runs after the client build writes its manifest and
33
- * patches the already-emitted worker bundle on disk.
34
- */
35
- function injectManifest(): Plugin {
36
- let clientOutDir = "dist/client";
37
-
38
- const sentinel = '"__VITE_MANIFEST_CONTENT__"';
39
-
40
- function readManifest(): string | undefined {
41
- const manifestPath = resolve(
42
- process.cwd(),
43
- clientOutDir,
44
- ".vite/manifest.json",
45
- );
46
- try {
47
- return readFileSync(manifestPath, "utf-8");
48
- } catch {
49
- return undefined;
50
- }
51
- }
52
-
53
- function buildReplacement(manifestContent: string): string {
54
- return `{ "__manifest__": { default: ${manifestContent} } }`;
55
- }
56
-
57
- return {
58
- name: "inject-manifest",
59
- config(config) {
60
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
- clientOutDir =
62
- (config as any).environments?.client?.build?.outDir ?? "dist/client";
63
- },
64
-
65
- // 1. Try during transform (works when previous client build exists on disk)
66
- transform(code, _id, options) {
67
- if (!options?.ssr) return;
68
- if (!code.includes("__VITE_MANIFEST_CONTENT__")) return;
69
-
70
- const manifestContent = readManifest();
71
- if (!manifestContent) return;
72
-
73
- const newCode = code.replace(
74
- /"__VITE_MANIFEST_CONTENT__"/g,
75
- buildReplacement(manifestContent),
76
- );
77
-
78
- if (newCode !== code) {
79
- return { code: newCode, map: null };
80
- }
81
- },
82
-
83
- // 2. After the client build writes the manifest, patch worker output files
84
- writeBundle() {
85
- if (this.environment.name !== "client") return;
86
-
87
- const manifestContent = readManifest();
88
- if (!manifestContent) return;
89
-
90
- const replacement = buildReplacement(manifestContent);
91
- const distDir = resolve(process.cwd(), "dist");
92
- const clientDirName = clientOutDir.split("/").pop()!;
93
-
94
- let entries: import("fs").Dirent[];
95
- try {
96
- entries = readdirSync(distDir, { withFileTypes: true });
97
- } catch {
98
- return;
99
- }
100
-
101
- for (const entry of entries) {
102
- if (!entry.isDirectory() || entry.name === clientDirName) continue;
103
- const workerDir = resolve(distDir, entry.name);
104
- const files = readdirSync(workerDir, { recursive: true }) as string[];
105
- for (const file of files) {
106
- if (!String(file).endsWith(".js")) continue;
107
- const filePath = resolve(workerDir, String(file));
108
- const content = readFileSync(filePath, "utf-8");
109
- if (content.includes(sentinel)) {
110
- writeFileSync(filePath, content.replaceAll(sentinel, replacement));
111
- }
112
- }
113
- }
114
- },
115
- };
116
- }
117
-
118
- export default defineConfig({
119
- server: {
120
- port: 9019,
121
- host: true,
122
- allowedHosts: true,
123
- },
124
-
125
- preview: {
126
- port: 9019,
127
- },
128
-
129
- // Exclude @lingui/react from dependency optimization
130
- // Why: Source code uses `@lingui/react/macro` (for Lingui SWC plugin recognition),
131
- // but SWC rewrites imports to `@jant/core/i18n` at compile time (see runtimeModules config).
132
- // Vite's dependency scanner sees the source imports and warns about missing @lingui/react.
133
- // This is harmless but causes multiple reloads. Excluding prevents the warning.
134
- optimizeDeps: {
135
- exclude: ["@lingui/react"],
136
- },
137
-
138
- environments: {
139
- client: {
140
- build: {
141
- outDir: "dist/client",
142
- manifest: true,
143
- rollupOptions: {
144
- input: ["/src/client.ts", "/src/style.css"],
145
- },
146
- },
147
- },
148
- },
149
-
150
- plugins: [
151
- tailwindcss(),
152
- ssrReload(),
153
- swc.vite({
154
- jsc: {
155
- parser: { syntax: "typescript", tsx: true },
156
- transform: {
157
- react: {
158
- runtime: "automatic",
159
- importSource: "hono/jsx",
160
- throwIfNamespace: false,
161
- },
162
- },
163
- target: "es2022",
164
- experimental: {
165
- plugins: [
166
- [
167
- "@lingui/swc-plugin",
168
- {
169
- runtimeModules: {
170
- useLingui: ["@jant/core/i18n", "useLingui"],
171
- trans: ["@jant/core/i18n", "Trans"],
172
- },
173
- },
174
- ],
175
- ],
176
- },
177
- },
178
- module: { type: "es6" },
179
- }),
180
- cloudflare({
181
- configPath: process.env.WRANGLER_CONFIG || "./wrangler.toml",
182
- }),
183
- injectManifest(),
184
- ],
185
-
186
- build: {
187
- target: "esnext",
188
- minify: false,
189
- rollupOptions: {
190
- external: ["cloudflare:*", "__STATIC_CONTENT_MANIFEST"],
191
- },
192
- },
193
-
194
- // @create-jant: @remove-start
195
- resolve: {
196
- alias: {
197
- // Monorepo development aliases
198
- // - @lingui/react/macro: Prevents Vite dependency scan error. Source code imports
199
- // from @lingui/react/macro (for SWC plugin), but we use Hono JSX. SWC rewrites
200
- // these at compile time, but Vite scans before SWC runs.
201
- // - @jant/core: Points to source for HMR during development.
202
- // Note: User projects don't need @lingui/react/macro alias because they use
203
- // node_modules/@jant/core/dist/ (already compiled by SWC, imports rewritten).
204
- "@lingui/react/macro": resolve(
205
- __dirname,
206
- "../../packages/core/src/i18n/index.ts",
207
- ),
208
- "@jant/core": resolve(__dirname, "../../packages/core/src"),
209
- },
210
- },
211
- // @create-jant: @remove-end
212
- });
@@ -1,23 +0,0 @@
1
- # Demo environment configuration for demo.jant.me
2
- # This is a standalone config, not using wrangler environments
3
-
4
- name = "jant-demo"
5
- main = "src/index.ts"
6
- compatibility_date = "2026-01-20"
7
- compatibility_flags = ["nodejs_compat"]
8
- account_id = "03e7294bdb3750ed5a0d6afef6d770e4"
9
-
10
- [vars]
11
- SITE_URL = "https://demo.jant.me"
12
- DEMO_EMAIL = "demo@jant.me"
13
- DEMO_PASSWORD = "demodemo"
14
-
15
- [[d1_databases]]
16
- binding = "DB"
17
- database_name = "jant-demo-db"
18
- database_id = "76329154-291d-4580-af73-aa77397649f1"
19
- migrations_dir = "../../packages/core/src/db/migrations"
20
-
21
- [[r2_buckets]]
22
- binding = "R2"
23
- bucket_name = "jant-demo-media"