dinou 9.3.0 → 10.0.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/CHANGELOG.md +196 -0
- package/README.md +157 -132
- package/dinou/adapters/bun.js +34 -5
- package/dinou/adapters/cloudflare.js +110 -17
- package/dinou/adapters/deno.js +46 -8
- package/dinou/adapters/netlify.js +86 -50
- package/dinou/adapters/node.js +8 -0
- package/dinou/assets.d.ts +32 -5
- package/dinou/bun/build.js +190 -106
- package/dinou/cli.js +992 -532
- package/dinou/cloudflare/build.js +187 -106
- package/dinou/compiled/autoprefixer/index.js +509 -517
- package/dinou/compiled/babel-core/index.js +738 -716
- package/dinou/compiled/babel-generator/index.js +341 -299
- package/dinou/compiled/babel-loader/index.js +766 -744
- package/dinou/compiled/babel-parser/index.js +2 -2
- package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
- package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
- package/dinou/compiled/babel-preset-react/index.js +752 -730
- package/dinou/compiled/babel-preset-typescript/index.js +738 -716
- package/dinou/compiled/babel-traverse/index.js +463 -433
- package/dinou/compiled/babel-types/index.js +176 -176
- package/dinou/compiled/chokidar/index.js +4 -4
- package/dinou/compiled/commander/index.js +15 -15
- package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
- package/dinou/compiled/css-loader/index.js +289 -289
- package/dinou/compiled/css-loader/runtime/api.js +85 -0
- package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
- package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
- package/dinou/compiled/css-loader/runtime/package.json +3 -0
- package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
- package/dinou/compiled/fast-glob/index.js +5810 -0
- package/dinou/compiled/generic-names/index.js +16 -16
- package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
- package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
- package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
- package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
- package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
- package/dinou/compiled/postcss/index.js +83 -83
- package/dinou/compiled/postcss-import/index.js +147 -117
- package/dinou/compiled/postcss-modules/index.js +216 -216
- package/dinou/compiled/resolve/index.js +1224 -0
- package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
- package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
- package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
- package/dinou/compiled/rollup-plugin-json/index.js +22 -18
- package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
- package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
- package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
- package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
- package/dinou/compiled/vendors-manifest.json +59 -83
- package/dinou/core/asset-extensions.js +482 -33
- package/dinou/core/bailout-proxy.js +21 -2
- package/dinou/core/build-static-pages.js +523 -371
- package/dinou/core/builtin-asset-extensions.js +63 -0
- package/dinou/core/cache-revalidate.js +449 -256
- package/dinou/core/cache-slot.js +289 -79
- package/dinou/core/client-webpack.jsx +470 -39
- package/dinou/core/client.jsx +402 -39
- package/dinou/core/config.js +3 -0
- package/dinou/core/copy-static-dirs.js +98 -0
- package/dinou/core/createScopedName.js +22 -4
- package/dinou/core/dinou-paths.js +1 -1
- package/dinou/core/discover-layouts.js +200 -0
- package/dinou/core/edge-ssr.js +1 -1
- package/dinou/core/ensure-vendor-mode.js +78 -19
- package/dinou/core/env.js +544 -0
- package/dinou/core/export-static.js +41 -9
- package/dinou/core/generate-route-types.js +989 -95
- package/dinou/core/generate-static-rsc.js +5 -6
- package/dinou/core/generate-static.js +45 -6
- package/dinou/core/get-abs-path-with-ext.js +217 -75
- package/dinou/core/get-asset-from-manifest.js +19 -8
- package/dinou/core/get-error-jsx.js +4 -5
- package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
- package/dinou/core/get-jsx.js +220 -53
- package/dinou/core/handler.js +1647 -466
- package/dinou/core/import-module.js +7 -0
- package/dinou/core/layout-functions.js +72 -13
- package/dinou/core/link.jsx +34 -6
- package/dinou/core/load-dinou-config.js +520 -89
- package/dinou/core/manifest-provider.js +4 -14
- package/dinou/core/navigation-utils.js +141 -3
- package/dinou/core/navigation.js +134 -50
- package/dinou/core/node-middleware-runner.js +165 -0
- package/dinou/core/postcss-pipeline.js +236 -0
- package/dinou/core/ppr-context.js +114 -22
- package/dinou/core/ppr-runtime.js +391 -127
- package/dinou/core/redirect.jsx +1 -1
- package/dinou/core/render-jsx-to-client-jsx.js +216 -48
- package/dinou/core/request-context.js +59 -3
- package/dinou/core/resolve-contextual-dinou.js +523 -0
- package/dinou/core/resolve-setup-files.js +85 -27
- package/dinou/core/revalidating.js +10 -2
- package/dinou/core/route-generator.js +6 -2
- package/dinou/core/rsc-renderer.js +4 -1
- package/dinou/core/run-ssg.js +6 -0
- package/dinou/core/runtime-env.js +265 -0
- package/dinou/core/server-css-modules-plugin.js +155 -0
- package/dinou/core/server-function-proxy-webpack.js +27 -2
- package/dinou/core/server-function-proxy.js +27 -2
- package/dinou/core/slot.js +47 -2
- package/dinou/core/static-assets.js +503 -0
- package/dinou/core/storage-adapter.js +452 -24
- package/dinou/core/transform-server-functions.js +272 -24
- package/dinou/core/tsconfig-aliases.js +964 -0
- package/dinou/core/uneject.js +640 -0
- package/dinou/core/url-resolver.js +1 -1
- package/dinou/core/vfs.js +11 -2
- package/dinou/css.d.ts +4 -1
- package/dinou/deno/build.js +205 -153
- package/dinou/deno/seed-kv.js +4 -0
- package/dinou/env.d.ts +22 -2
- package/dinou/esbuild/build.js +40 -50
- package/dinou/esbuild/dev.js +33 -7
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
- package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
- package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
- package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
- package/dinou/esbuild/helpers-esbuild/write.js +13 -3
- package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
- package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
- package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
- package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
- package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
- package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
- package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
- package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
- package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
- package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
- package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
- package/dinou/index.d.ts +1028 -88
- package/dinou/node/build.js +138 -74
- package/dinou/node/bundle-dual-engine.js +393 -131
- package/dinou/node/dev.js +1005 -275
- package/dinou/package.json +11 -34
- package/dinou/rollup/postcss.config.js +3 -4
- package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
- package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
- package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
- package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
- package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
- package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
- package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
- package/dinou/rollup/rollup.config.js +174 -101
- package/dinou/scripts/build-vendors.js +123 -33
- package/dinou/server.d.ts +126 -15
- package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
- package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
- package/dinou/webpack/loaders/server-functions-loader.js +1 -1
- package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
- package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
- package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
- package/dinou/webpack/postcss.config.js +3 -4
- package/dinou/webpack/webpack.config.js +408 -132
- package/eject.js +6 -224
- package/package.json +7 -9
- package/dinou/compiled/cross-env/index.js +0 -661
- package/dinou/compiled/dotenv/index.js +0 -375
- package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
- package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
- package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
- package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
- package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
package/dinou/cli.js
CHANGED
|
@@ -1,532 +1,992 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.
|
|
225
|
-
.
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
.
|
|
318
|
-
.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
{ name: "
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
.
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
.
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
]
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
.
|
|
426
|
-
.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
program
|
|
451
|
-
.command("build:
|
|
452
|
-
.description("Build the app
|
|
453
|
-
.action(() => {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
for
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
.
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
.
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
.
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import ensureVendorMode, {
|
|
4
|
+
isUnvendorizedRequested,
|
|
5
|
+
} from "./core/ensure-vendor-mode.js";
|
|
6
|
+
if (!ensureVendorMode()) {
|
|
7
|
+
await new Promise(() => { });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
import { program } from "#commander";
|
|
11
|
+
import { spawnSync } from "node:child_process";
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { loadEnvFiles } from "./core/env.js";
|
|
17
|
+
|
|
18
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const dinouPath = __dirname;
|
|
20
|
+
const projectRoot = process.cwd();
|
|
21
|
+
|
|
22
|
+
const dinouRequire = createRequire(import.meta.url);
|
|
23
|
+
const projectRequire = createRequire(path.resolve(projectRoot, "package.json"));
|
|
24
|
+
|
|
25
|
+
function resolveToolBin(specifier) {
|
|
26
|
+
try {
|
|
27
|
+
return dinouRequire.resolve(specifier);
|
|
28
|
+
} catch {
|
|
29
|
+
return projectRequire.resolve(specifier);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dinouScript = (rel) => path.join(dinouPath, rel);
|
|
34
|
+
|
|
35
|
+
// Global CLI options (Dual-Mode Vendoring)
|
|
36
|
+
program
|
|
37
|
+
.name("dinou")
|
|
38
|
+
.description(
|
|
39
|
+
"Full-stack React 19 framework with native RSC, progressive streaming, and dual-mode vendoring"
|
|
40
|
+
)
|
|
41
|
+
.version("10.0.1")
|
|
42
|
+
.option(
|
|
43
|
+
"-u, --unvendorized",
|
|
44
|
+
"Run with standard node_modules dependencies instead of pre-bundled vendor packages"
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const pathKey =
|
|
48
|
+
Object.keys(process.env).find((k) => k.toLowerCase() === "path") || "PATH";
|
|
49
|
+
const projectBin = path.join(projectRoot, "node_modules", ".bin");
|
|
50
|
+
const dinouBin = path.join(dinouPath, "node_modules", ".bin");
|
|
51
|
+
const dinouParentBin = path.resolve(dinouPath, "..", "node_modules", ".bin");
|
|
52
|
+
const extendedPath = [
|
|
53
|
+
projectBin,
|
|
54
|
+
dinouBin,
|
|
55
|
+
dinouParentBin,
|
|
56
|
+
process.env[pathKey],
|
|
57
|
+
]
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.join(path.delimiter);
|
|
60
|
+
|
|
61
|
+
function buildChildEnv(extraEnv = {}) {
|
|
62
|
+
const unvendorized =
|
|
63
|
+
isUnvendorizedRequested(projectRoot) ||
|
|
64
|
+
Boolean(program.opts?.().unvendorized);
|
|
65
|
+
const baseNodeOptions = process.env.NODE_OPTIONS || "";
|
|
66
|
+
const nodeOptions =
|
|
67
|
+
unvendorized && !baseNodeOptions.includes("unvendorized")
|
|
68
|
+
? (baseNodeOptions ? `${baseNodeOptions} ` : "") +
|
|
69
|
+
"--conditions=unvendorized"
|
|
70
|
+
: baseNodeOptions;
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
unvendorized,
|
|
74
|
+
env: {
|
|
75
|
+
...process.env,
|
|
76
|
+
[pathKey]: extendedPath,
|
|
77
|
+
Path: extendedPath,
|
|
78
|
+
PATH: extendedPath,
|
|
79
|
+
...(unvendorized ? { DINOU_UNVENDORIZED: "true" } : {}),
|
|
80
|
+
...(nodeOptions ? { NODE_OPTIONS: nodeOptions } : {}),
|
|
81
|
+
...extraEnv,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function jsStep(runner, scriptOrResolver, args = [], env = {}) {
|
|
87
|
+
return { kind: "js", runner, scriptOrResolver, args, env };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function cmdStep(bin, args = [], env = {}) {
|
|
91
|
+
return { kind: "cmd", bin, args, env };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function runSteps(steps, baseEnv = {}) {
|
|
95
|
+
const isBunRuntime =
|
|
96
|
+
typeof Bun !== "undefined" || Boolean(process.versions?.bun);
|
|
97
|
+
|
|
98
|
+
for (const step of steps) {
|
|
99
|
+
const mergedExtraEnv = { ...baseEnv, ...(step.env || {}) };
|
|
100
|
+
const { unvendorized, env } = buildChildEnv(mergedExtraEnv);
|
|
101
|
+
|
|
102
|
+
let bin;
|
|
103
|
+
let finalArgs;
|
|
104
|
+
|
|
105
|
+
if (step.kind === "js") {
|
|
106
|
+
const targetScript =
|
|
107
|
+
typeof step.scriptOrResolver === "function"
|
|
108
|
+
? step.scriptOrResolver()
|
|
109
|
+
: step.scriptOrResolver;
|
|
110
|
+
|
|
111
|
+
if (step.runner === "bun") {
|
|
112
|
+
bin = isBunRuntime ? process.execPath : "bun";
|
|
113
|
+
} else {
|
|
114
|
+
bin = !isBunRuntime ? process.execPath : "node";
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const conditionPrefix = unvendorized ? ["--conditions=unvendorized"] : [];
|
|
118
|
+
finalArgs = [...conditionPrefix, targetScript, ...(step.args || [])];
|
|
119
|
+
} else {
|
|
120
|
+
bin =
|
|
121
|
+
step.bin === "bun" && isBunRuntime ? process.execPath : step.bin;
|
|
122
|
+
finalArgs = [...(step.args || [])];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let result = spawnSync(bin, finalArgs, {
|
|
126
|
+
stdio: "inherit",
|
|
127
|
+
cwd: projectRoot,
|
|
128
|
+
env,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
result.error &&
|
|
133
|
+
process.platform === "win32" &&
|
|
134
|
+
!path.isAbsolute(bin) &&
|
|
135
|
+
(result.error.code === "ENOENT" || result.error.code === "EINVAL")
|
|
136
|
+
) {
|
|
137
|
+
result = spawnSync(bin, finalArgs, {
|
|
138
|
+
stdio: "inherit",
|
|
139
|
+
cwd: projectRoot,
|
|
140
|
+
env,
|
|
141
|
+
shell: true,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (result.error) {
|
|
146
|
+
console.error(
|
|
147
|
+
`Error executing "${bin} ${finalArgs.join(" ")}":`,
|
|
148
|
+
result.error.message
|
|
149
|
+
);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (result.status !== 0) {
|
|
154
|
+
if (result.signal) {
|
|
155
|
+
process.kill(process.pid, result.signal);
|
|
156
|
+
}
|
|
157
|
+
process.exit(result.status ?? 1);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const runProdSteps = (steps, extraEnv = {}) =>
|
|
163
|
+
runSteps(steps, { NODE_ENV: "production", ...extraEnv });
|
|
164
|
+
|
|
165
|
+
function bundlerStep(bundler, runner = "node") {
|
|
166
|
+
if (bundler === "rollup") {
|
|
167
|
+
return jsStep(
|
|
168
|
+
runner,
|
|
169
|
+
() => resolveToolBin("rollup/dist/bin/rollup"),
|
|
170
|
+
["-c", dinouScript("rollup/rollup.config.js")],
|
|
171
|
+
{ NODE_ENV: "production", DINOU_BUILD_TOOL: "rollup" }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
if (bundler === "webpack") {
|
|
175
|
+
return jsStep(
|
|
176
|
+
runner,
|
|
177
|
+
() => resolveToolBin("webpack-cli/bin/cli.js"),
|
|
178
|
+
["--config", dinouScript("webpack/webpack.config.js")],
|
|
179
|
+
{ NODE_ENV: "production", DINOU_BUILD_TOOL: "webpack" }
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return jsStep(runner, dinouScript("esbuild/build.js"), [], {
|
|
183
|
+
NODE_ENV: "production",
|
|
184
|
+
DINOU_BUILD_TOOL: "esbuild",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// --- DEV ---
|
|
189
|
+
|
|
190
|
+
program
|
|
191
|
+
.command("dev")
|
|
192
|
+
.description("Start development server with Esbuild")
|
|
193
|
+
.action(() => {
|
|
194
|
+
runSteps([
|
|
195
|
+
jsStep("node", dinouScript("node/dev.js"), [], {
|
|
196
|
+
DINOU_BUILD_TOOL: "esbuild",
|
|
197
|
+
}),
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
program
|
|
202
|
+
.command("dev:esbuild")
|
|
203
|
+
.description("Start development server with Esbuild")
|
|
204
|
+
.action(() => {
|
|
205
|
+
runSteps([
|
|
206
|
+
jsStep("node", dinouScript("node/dev.js"), [], {
|
|
207
|
+
DINOU_BUILD_TOOL: "esbuild",
|
|
208
|
+
}),
|
|
209
|
+
]);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
program
|
|
213
|
+
.command("dev:rollup")
|
|
214
|
+
.description("Start development server with Rollup")
|
|
215
|
+
.action(() => {
|
|
216
|
+
runSteps([
|
|
217
|
+
jsStep("node", dinouScript("node/dev.js"), [], {
|
|
218
|
+
DINOU_BUILD_TOOL: "rollup",
|
|
219
|
+
}),
|
|
220
|
+
]);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
program
|
|
224
|
+
.command("dev:webpack")
|
|
225
|
+
.description("Start development server with Webpack")
|
|
226
|
+
.action(() => {
|
|
227
|
+
runSteps([
|
|
228
|
+
jsStep("node", dinouScript("node/dev.js"), [], {
|
|
229
|
+
DINOU_BUILD_TOOL: "webpack",
|
|
230
|
+
}),
|
|
231
|
+
]);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// --- NODE (BUILD & START) ---
|
|
235
|
+
|
|
236
|
+
const buildNodeSteps = (bundler, runner = "node") => [
|
|
237
|
+
bundlerStep(bundler, runner),
|
|
238
|
+
jsStep(runner, dinouScript("node/build.js"), [], {
|
|
239
|
+
NODE_ENV: "production",
|
|
240
|
+
DINOU_BUILD_TOOL: bundler,
|
|
241
|
+
}),
|
|
242
|
+
];
|
|
243
|
+
|
|
244
|
+
program
|
|
245
|
+
.command("build")
|
|
246
|
+
.description("Build the app for Node.js production (using esbuild)")
|
|
247
|
+
.action(() => {
|
|
248
|
+
runProdSteps(buildNodeSteps("esbuild", "node"));
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
program
|
|
252
|
+
.command("build:node")
|
|
253
|
+
.description("Build the app for Node.js production (using esbuild)")
|
|
254
|
+
.action(() => {
|
|
255
|
+
runProdSteps(buildNodeSteps("esbuild", "node"));
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
program
|
|
259
|
+
.command("build:node:esbuild")
|
|
260
|
+
.description("Build the app for Node.js with Esbuild")
|
|
261
|
+
.action(() => {
|
|
262
|
+
runProdSteps(buildNodeSteps("esbuild", "node"));
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
program
|
|
266
|
+
.command("build:node:rollup")
|
|
267
|
+
.description("Build the app for Node.js with Rollup")
|
|
268
|
+
.action(() => {
|
|
269
|
+
runProdSteps(buildNodeSteps("rollup", "node"));
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
program
|
|
273
|
+
.command("build:node:webpack")
|
|
274
|
+
.description("Build the app for Node.js with Webpack")
|
|
275
|
+
.action(() => {
|
|
276
|
+
runProdSteps(buildNodeSteps("webpack", "node"));
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
program
|
|
280
|
+
.command("start")
|
|
281
|
+
.description("Start the app in production mode (Node.js)")
|
|
282
|
+
.action(() => {
|
|
283
|
+
runProdSteps([jsStep("node", dinouScript("adapters/node.js"))]);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
program
|
|
287
|
+
.command("start:node")
|
|
288
|
+
.description("Start the app in production mode (Node.js)")
|
|
289
|
+
.action(() => {
|
|
290
|
+
runProdSteps([jsStep("node", dinouScript("adapters/node.js"))]);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
program
|
|
294
|
+
.command("start:node:esbuild")
|
|
295
|
+
.description("Start the app in production mode (Esbuild build)")
|
|
296
|
+
.action(() => {
|
|
297
|
+
runProdSteps([
|
|
298
|
+
jsStep("node", dinouScript("adapters/node.js"), [], {
|
|
299
|
+
DINOU_BUILD_TOOL: "esbuild",
|
|
300
|
+
}),
|
|
301
|
+
]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
program
|
|
305
|
+
.command("start:node:rollup")
|
|
306
|
+
.description("Start the app in production mode (Rollup build)")
|
|
307
|
+
.action(() => {
|
|
308
|
+
runProdSteps([
|
|
309
|
+
jsStep("node", dinouScript("adapters/node.js"), [], {
|
|
310
|
+
DINOU_BUILD_TOOL: "rollup",
|
|
311
|
+
}),
|
|
312
|
+
]);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
program
|
|
316
|
+
.command("start:node:webpack")
|
|
317
|
+
.description("Start the app in production mode (Webpack build)")
|
|
318
|
+
.action(() => {
|
|
319
|
+
runProdSteps([
|
|
320
|
+
jsStep("node", dinouScript("adapters/node.js"), [], {
|
|
321
|
+
DINOU_BUILD_TOOL: "webpack",
|
|
322
|
+
}),
|
|
323
|
+
]);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// --- NODE (COMPILE VIA BUN) ---
|
|
327
|
+
|
|
328
|
+
const nodeTargets = [
|
|
329
|
+
{ name: "", args: [], outfile: "dist/server" },
|
|
330
|
+
{
|
|
331
|
+
name: ":linux",
|
|
332
|
+
args: ["--target=bun-linux-x64"],
|
|
333
|
+
outfile: "dist/server-linux",
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: ":linux_arm",
|
|
337
|
+
args: ["--target=bun-linux-arm64"],
|
|
338
|
+
outfile: "dist/server-linux-arm",
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
name: ":mac",
|
|
342
|
+
args: ["--target=bun-darwin-arm64"],
|
|
343
|
+
outfile: "dist/server-mac",
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
name: ":win",
|
|
347
|
+
args: ["--target=bun-windows-x64"],
|
|
348
|
+
outfile: "dist/server-win",
|
|
349
|
+
},
|
|
350
|
+
];
|
|
351
|
+
|
|
352
|
+
for (const t of nodeTargets) {
|
|
353
|
+
for (const b of ["esbuild", "rollup", "webpack"]) {
|
|
354
|
+
const cmdNames =
|
|
355
|
+
b === "esbuild"
|
|
356
|
+
? [
|
|
357
|
+
`build:node:compile${t.name}`,
|
|
358
|
+
`build:node:compile${t.name}:esbuild`,
|
|
359
|
+
]
|
|
360
|
+
: [`build:node:compile${t.name}:${b}`];
|
|
361
|
+
for (const cmdName of cmdNames) {
|
|
362
|
+
program
|
|
363
|
+
.command(cmdName)
|
|
364
|
+
.description(
|
|
365
|
+
`Compile standalone Node.js server executable with Bun (${t.name || "host"}, ${b})`
|
|
366
|
+
)
|
|
367
|
+
.action(() => {
|
|
368
|
+
runProdSteps([
|
|
369
|
+
...buildNodeSteps(b, "node"),
|
|
370
|
+
cmdStep("bun", [
|
|
371
|
+
"build",
|
|
372
|
+
"--compile",
|
|
373
|
+
...t.args,
|
|
374
|
+
".dinou/node/server.mjs",
|
|
375
|
+
"--outfile",
|
|
376
|
+
t.outfile,
|
|
377
|
+
]),
|
|
378
|
+
]);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// --- NODE (PURE BUN RUNNER & COMPILE) ---
|
|
385
|
+
|
|
386
|
+
program
|
|
387
|
+
.command("build:node:pure")
|
|
388
|
+
.description("Build the app for Node.js with 100% Bun (using esbuild)")
|
|
389
|
+
.action(() => {
|
|
390
|
+
runProdSteps(buildNodeSteps("esbuild", "bun"));
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
program
|
|
394
|
+
.command("build:node:pure:esbuild")
|
|
395
|
+
.description("Build the app for Node.js with 100% Bun (Esbuild)")
|
|
396
|
+
.action(() => {
|
|
397
|
+
runProdSteps(buildNodeSteps("esbuild", "bun"));
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
program
|
|
401
|
+
.command("build:node:pure:rollup")
|
|
402
|
+
.description("Build the app for Node.js with 100% Bun (Rollup)")
|
|
403
|
+
.action(() => {
|
|
404
|
+
runProdSteps(buildNodeSteps("rollup", "bun"));
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
program
|
|
408
|
+
.command("build:node:pure:webpack")
|
|
409
|
+
.description("Build the app for Node.js with 100% Bun (Webpack)")
|
|
410
|
+
.action(() => {
|
|
411
|
+
runProdSteps(buildNodeSteps("webpack", "bun"));
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
for (const t of nodeTargets) {
|
|
415
|
+
for (const b of ["esbuild", "rollup", "webpack"]) {
|
|
416
|
+
const cmdNames =
|
|
417
|
+
b === "esbuild"
|
|
418
|
+
? [
|
|
419
|
+
`build:node:pure:compile${t.name}`,
|
|
420
|
+
`build:node:pure:compile${t.name}:esbuild`,
|
|
421
|
+
]
|
|
422
|
+
: [`build:node:pure:compile${t.name}:${b}`];
|
|
423
|
+
for (const cmdName of cmdNames) {
|
|
424
|
+
program
|
|
425
|
+
.command(cmdName)
|
|
426
|
+
.description(
|
|
427
|
+
`Compile standalone Node.js server executable with 100% Bun (${t.name || "host"}, ${b})`
|
|
428
|
+
)
|
|
429
|
+
.action(() => {
|
|
430
|
+
runProdSteps([
|
|
431
|
+
...buildNodeSteps(b, "bun"),
|
|
432
|
+
cmdStep("bun", [
|
|
433
|
+
"build",
|
|
434
|
+
"--compile",
|
|
435
|
+
...t.args,
|
|
436
|
+
".dinou/node/server.mjs",
|
|
437
|
+
"--outfile",
|
|
438
|
+
t.outfile,
|
|
439
|
+
]),
|
|
440
|
+
]);
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// --- NETLIFY FUNCTIONS V2 ---
|
|
447
|
+
|
|
448
|
+
const buildNetlifySteps = (bundler) => [bundlerStep(bundler, "node")];
|
|
449
|
+
|
|
450
|
+
program
|
|
451
|
+
.command("build:netlify")
|
|
452
|
+
.description("Build the app for Netlify Serverless Functions v2 (using esbuild)")
|
|
453
|
+
.action(() => {
|
|
454
|
+
runProdSteps(buildNetlifySteps("esbuild"));
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
program
|
|
458
|
+
.command("build:netlify:esbuild")
|
|
459
|
+
.description("Build the app for Netlify Serverless Functions v2 with Esbuild")
|
|
460
|
+
.action(() => {
|
|
461
|
+
runProdSteps(buildNetlifySteps("esbuild"));
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
program
|
|
465
|
+
.command("build:netlify:rollup")
|
|
466
|
+
.description("Build the app for Netlify Serverless Functions v2 with Rollup")
|
|
467
|
+
.action(() => {
|
|
468
|
+
runProdSteps(buildNetlifySteps("rollup"));
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
program
|
|
472
|
+
.command("build:netlify:webpack")
|
|
473
|
+
.description("Build the app for Netlify Serverless Functions v2 with Webpack")
|
|
474
|
+
.action(() => {
|
|
475
|
+
runProdSteps(buildNetlifySteps("webpack"));
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// --- CLOUDFLARE WORKERS ---
|
|
479
|
+
|
|
480
|
+
const buildCloudflareSteps = (bundler) => [
|
|
481
|
+
bundlerStep(bundler, "node"),
|
|
482
|
+
jsStep("node", dinouScript("cloudflare/build.js"), [], {
|
|
483
|
+
NODE_ENV: "production",
|
|
484
|
+
DINOU_BUILD_TOOL: bundler,
|
|
485
|
+
}),
|
|
486
|
+
];
|
|
487
|
+
|
|
488
|
+
program
|
|
489
|
+
.command("build:cloudflare")
|
|
490
|
+
.description("Build the app for Cloudflare Workers (using esbuild)")
|
|
491
|
+
.action(() => {
|
|
492
|
+
runProdSteps(buildCloudflareSteps("esbuild"));
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
program
|
|
496
|
+
.command("build:cloudflare:esbuild")
|
|
497
|
+
.description("Build the app for Cloudflare Workers with Esbuild")
|
|
498
|
+
.action(() => {
|
|
499
|
+
runProdSteps(buildCloudflareSteps("esbuild"));
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
program
|
|
503
|
+
.command("build:cloudflare:rollup")
|
|
504
|
+
.description("Build the app for Cloudflare Workers with Rollup")
|
|
505
|
+
.action(() => {
|
|
506
|
+
runProdSteps(buildCloudflareSteps("rollup"));
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
program
|
|
510
|
+
.command("build:cloudflare:webpack")
|
|
511
|
+
.description("Build the app for Cloudflare Workers with Webpack")
|
|
512
|
+
.action(() => {
|
|
513
|
+
runProdSteps(buildCloudflareSteps("webpack"));
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
// --- DENO DEPLOY / EDGE ---
|
|
517
|
+
|
|
518
|
+
const buildDenoSteps = (bundler) => [
|
|
519
|
+
bundlerStep(bundler, "node"),
|
|
520
|
+
jsStep("node", dinouScript("deno/build.js"), [], {
|
|
521
|
+
NODE_ENV: "production",
|
|
522
|
+
DINOU_BUILD_TOOL: bundler,
|
|
523
|
+
}),
|
|
524
|
+
cmdStep(
|
|
525
|
+
"deno",
|
|
526
|
+
[
|
|
527
|
+
"run",
|
|
528
|
+
"--unstable-kv",
|
|
529
|
+
"--allow-net",
|
|
530
|
+
"--allow-read",
|
|
531
|
+
"--allow-write",
|
|
532
|
+
"--allow-env",
|
|
533
|
+
dinouScript("deno/seed-kv.js"),
|
|
534
|
+
],
|
|
535
|
+
{ NODE_ENV: "production", DINOU_BUILD_TOOL: bundler }
|
|
536
|
+
),
|
|
537
|
+
];
|
|
538
|
+
|
|
539
|
+
program
|
|
540
|
+
.command("build:deno")
|
|
541
|
+
.description("Build the app for Deno Deploy / Edge (using esbuild)")
|
|
542
|
+
.action(() => {
|
|
543
|
+
runProdSteps(buildDenoSteps("esbuild"));
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
program
|
|
547
|
+
.command("build:deno:esbuild")
|
|
548
|
+
.description("Build the app for Deno Deploy with Esbuild")
|
|
549
|
+
.action(() => {
|
|
550
|
+
runProdSteps(buildDenoSteps("esbuild"));
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
program
|
|
554
|
+
.command("build:deno:rollup")
|
|
555
|
+
.description("Build the app for Deno Deploy with Rollup")
|
|
556
|
+
.action(() => {
|
|
557
|
+
runProdSteps(buildDenoSteps("rollup"));
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
program
|
|
561
|
+
.command("build:deno:webpack")
|
|
562
|
+
.description("Build the app for Deno Deploy with Webpack")
|
|
563
|
+
.action(() => {
|
|
564
|
+
runProdSteps(buildDenoSteps("webpack"));
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
program
|
|
568
|
+
.command("start:deno")
|
|
569
|
+
.description("Start the app in production mode with Deno")
|
|
570
|
+
.action(() => {
|
|
571
|
+
runProdSteps([
|
|
572
|
+
cmdStep("deno", [
|
|
573
|
+
"run",
|
|
574
|
+
"--unstable-kv",
|
|
575
|
+
"--allow-net",
|
|
576
|
+
"--allow-read",
|
|
577
|
+
"--allow-write",
|
|
578
|
+
"--allow-env",
|
|
579
|
+
"--allow-sys",
|
|
580
|
+
dinouScript("adapters/deno.js"),
|
|
581
|
+
]),
|
|
582
|
+
]);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
const denoTargets = [
|
|
586
|
+
{ name: "", args: [], outfile: "dist/deno-server" },
|
|
587
|
+
{
|
|
588
|
+
name: ":linux",
|
|
589
|
+
args: ["--target", "x86_64-unknown-linux-gnu"],
|
|
590
|
+
outfile: "dist/deno-server-linux",
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
name: ":linux_arm",
|
|
594
|
+
args: ["--target", "aarch64-unknown-linux-gnu"],
|
|
595
|
+
outfile: "dist/deno-server-linux-arm",
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
name: ":mac",
|
|
599
|
+
args: ["--target", "aarch64-apple-darwin"],
|
|
600
|
+
outfile: "dist/deno-server-mac",
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
name: ":win",
|
|
604
|
+
args: ["--target", "x86_64-pc-windows-msvc"],
|
|
605
|
+
outfile: "dist/deno-server-win",
|
|
606
|
+
},
|
|
607
|
+
];
|
|
608
|
+
|
|
609
|
+
for (const t of denoTargets) {
|
|
610
|
+
for (const b of ["esbuild", "rollup", "webpack"]) {
|
|
611
|
+
const cmdNames =
|
|
612
|
+
b === "esbuild"
|
|
613
|
+
? [
|
|
614
|
+
`build:deno:compile${t.name}`,
|
|
615
|
+
`build:deno:compile${t.name}:esbuild`,
|
|
616
|
+
]
|
|
617
|
+
: [`build:deno:compile${t.name}:${b}`];
|
|
618
|
+
for (const cmdName of cmdNames) {
|
|
619
|
+
program
|
|
620
|
+
.command(cmdName)
|
|
621
|
+
.description(
|
|
622
|
+
`Compile standalone Deno executable (${t.name || "host"}, ${b})`
|
|
623
|
+
)
|
|
624
|
+
.action(() => {
|
|
625
|
+
runProdSteps([
|
|
626
|
+
...buildDenoSteps(b),
|
|
627
|
+
cmdStep("deno", [
|
|
628
|
+
"compile",
|
|
629
|
+
...t.args,
|
|
630
|
+
"--unstable-kv",
|
|
631
|
+
"--no-check",
|
|
632
|
+
"--no-config",
|
|
633
|
+
"--allow-net",
|
|
634
|
+
"--allow-read",
|
|
635
|
+
"--allow-write",
|
|
636
|
+
"--allow-env",
|
|
637
|
+
"--allow-sys",
|
|
638
|
+
"--output",
|
|
639
|
+
t.outfile,
|
|
640
|
+
".dinou/deno/main.js",
|
|
641
|
+
]),
|
|
642
|
+
]);
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// --- BUN (STANDARD & PURE) ---
|
|
649
|
+
|
|
650
|
+
const buildBunSteps = (bundler, runner = "node") => [
|
|
651
|
+
bundlerStep(bundler, runner),
|
|
652
|
+
jsStep(runner, dinouScript("bun/build.js"), [], {
|
|
653
|
+
NODE_ENV: "production",
|
|
654
|
+
DINOU_BUILD_TOOL: bundler,
|
|
655
|
+
}),
|
|
656
|
+
];
|
|
657
|
+
|
|
658
|
+
program
|
|
659
|
+
.command("build:bun")
|
|
660
|
+
.description("Build the app for Bun (using esbuild)")
|
|
661
|
+
.action(() => {
|
|
662
|
+
runProdSteps(buildBunSteps("esbuild", "node"));
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
program
|
|
666
|
+
.command("build:bun:esbuild")
|
|
667
|
+
.description("Build the app for Bun with Esbuild")
|
|
668
|
+
.action(() => {
|
|
669
|
+
runProdSteps(buildBunSteps("esbuild", "node"));
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
program
|
|
673
|
+
.command("build:bun:rollup")
|
|
674
|
+
.description("Build the app for Bun with Rollup")
|
|
675
|
+
.action(() => {
|
|
676
|
+
runProdSteps(buildBunSteps("rollup", "node"));
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
program
|
|
680
|
+
.command("build:bun:webpack")
|
|
681
|
+
.description("Build the app for Bun with Webpack")
|
|
682
|
+
.action(() => {
|
|
683
|
+
runProdSteps(buildBunSteps("webpack", "node"));
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
program
|
|
687
|
+
.command("start:bun")
|
|
688
|
+
.description("Start the app in production mode with Bun")
|
|
689
|
+
.action(() => {
|
|
690
|
+
runProdSteps([jsStep("bun", dinouScript("adapters/bun.js"))]);
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
program
|
|
694
|
+
.command("start:bun:esbuild")
|
|
695
|
+
.description("Start the app in production mode with Bun (Esbuild)")
|
|
696
|
+
.action(() => {
|
|
697
|
+
runProdSteps([
|
|
698
|
+
jsStep("bun", dinouScript("adapters/bun.js"), [], {
|
|
699
|
+
DINOU_BUILD_TOOL: "esbuild",
|
|
700
|
+
}),
|
|
701
|
+
]);
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
program
|
|
705
|
+
.command("start:bun:rollup")
|
|
706
|
+
.description("Start the app in production mode with Bun (Rollup)")
|
|
707
|
+
.action(() => {
|
|
708
|
+
runProdSteps([
|
|
709
|
+
jsStep("bun", dinouScript("adapters/bun.js"), [], {
|
|
710
|
+
DINOU_BUILD_TOOL: "rollup",
|
|
711
|
+
}),
|
|
712
|
+
]);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
program
|
|
716
|
+
.command("start:bun:webpack")
|
|
717
|
+
.description("Start the app in production mode with Bun (Webpack)")
|
|
718
|
+
.action(() => {
|
|
719
|
+
runProdSteps([
|
|
720
|
+
jsStep("bun", dinouScript("adapters/bun.js"), [], {
|
|
721
|
+
DINOU_BUILD_TOOL: "webpack",
|
|
722
|
+
}),
|
|
723
|
+
]);
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
const bunTargets = [
|
|
727
|
+
{ name: "", args: [], outfile: "dist/server" },
|
|
728
|
+
{
|
|
729
|
+
name: ":linux",
|
|
730
|
+
args: ["--target=bun-linux-x64"],
|
|
731
|
+
outfile: "dist/server-linux",
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
name: ":linux_arm",
|
|
735
|
+
args: ["--target=bun-linux-arm64"],
|
|
736
|
+
outfile: "dist/server-linux-arm",
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: ":mac",
|
|
740
|
+
args: ["--target=bun-darwin-arm64"],
|
|
741
|
+
outfile: "dist/server-mac",
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
name: ":win",
|
|
745
|
+
args: ["--target=bun-windows-x64"],
|
|
746
|
+
outfile: "dist/server-win",
|
|
747
|
+
},
|
|
748
|
+
];
|
|
749
|
+
|
|
750
|
+
for (const t of bunTargets) {
|
|
751
|
+
for (const b of ["esbuild", "rollup", "webpack"]) {
|
|
752
|
+
const cmdNames =
|
|
753
|
+
b === "esbuild"
|
|
754
|
+
? [
|
|
755
|
+
`build:bun:compile${t.name}`,
|
|
756
|
+
`build:bun:compile${t.name}:esbuild`,
|
|
757
|
+
]
|
|
758
|
+
: [`build:bun:compile${t.name}:${b}`];
|
|
759
|
+
for (const cmdName of cmdNames) {
|
|
760
|
+
program
|
|
761
|
+
.command(cmdName)
|
|
762
|
+
.description(
|
|
763
|
+
`Compile standalone Bun executable (${t.name || "host"}, ${b})`
|
|
764
|
+
)
|
|
765
|
+
.action(() => {
|
|
766
|
+
runProdSteps([
|
|
767
|
+
...buildBunSteps(b, "node"),
|
|
768
|
+
cmdStep("bun", [
|
|
769
|
+
"build",
|
|
770
|
+
"--compile",
|
|
771
|
+
...t.args,
|
|
772
|
+
".dinou/bun/server.js",
|
|
773
|
+
"--outfile",
|
|
774
|
+
t.outfile,
|
|
775
|
+
]),
|
|
776
|
+
]);
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
program
|
|
783
|
+
.command("build:bun:pure")
|
|
784
|
+
.description("Build the app with 100% Bun (using esbuild)")
|
|
785
|
+
.action(() => {
|
|
786
|
+
runProdSteps(buildBunSteps("esbuild", "bun"));
|
|
787
|
+
});
|
|
788
|
+
|
|
789
|
+
program
|
|
790
|
+
.command("build:bun:pure:esbuild")
|
|
791
|
+
.description("Build the app with 100% Bun (Esbuild)")
|
|
792
|
+
.action(() => {
|
|
793
|
+
runProdSteps(buildBunSteps("esbuild", "bun"));
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
program
|
|
797
|
+
.command("build:bun:pure:rollup")
|
|
798
|
+
.description("Build the app with 100% Bun (Rollup)")
|
|
799
|
+
.action(() => {
|
|
800
|
+
runProdSteps(buildBunSteps("rollup", "bun"));
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
program
|
|
804
|
+
.command("build:bun:pure:webpack")
|
|
805
|
+
.description("Build the app with 100% Bun (Webpack)")
|
|
806
|
+
.action(() => {
|
|
807
|
+
runProdSteps(buildBunSteps("webpack", "bun"));
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
for (const t of bunTargets) {
|
|
811
|
+
for (const b of ["esbuild", "rollup", "webpack"]) {
|
|
812
|
+
const cmdNames =
|
|
813
|
+
b === "esbuild"
|
|
814
|
+
? [
|
|
815
|
+
`build:bun:pure:compile${t.name}`,
|
|
816
|
+
`build:bun:pure:compile${t.name}:esbuild`,
|
|
817
|
+
]
|
|
818
|
+
: [`build:bun:pure:compile${t.name}:${b}`];
|
|
819
|
+
for (const cmdName of cmdNames) {
|
|
820
|
+
program
|
|
821
|
+
.command(cmdName)
|
|
822
|
+
.description(
|
|
823
|
+
`Compile standalone Bun Pure executable (${t.name || "host"}, ${b})`
|
|
824
|
+
)
|
|
825
|
+
.action(() => {
|
|
826
|
+
runProdSteps([
|
|
827
|
+
...buildBunSteps(b, "bun"),
|
|
828
|
+
cmdStep("bun", [
|
|
829
|
+
"build",
|
|
830
|
+
"--compile",
|
|
831
|
+
...t.args,
|
|
832
|
+
".dinou/bun/server.js",
|
|
833
|
+
"--outfile",
|
|
834
|
+
t.outfile,
|
|
835
|
+
]),
|
|
836
|
+
]);
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// --- EXPORT STATIC ---
|
|
843
|
+
|
|
844
|
+
const exportStaticSteps = (bundler) => [
|
|
845
|
+
bundlerStep(bundler, "node"),
|
|
846
|
+
jsStep("node", dinouScript("core/export-static.js"), [], {
|
|
847
|
+
NODE_ENV: "production",
|
|
848
|
+
DINOU_BUILD_TOOL: bundler,
|
|
849
|
+
}),
|
|
850
|
+
];
|
|
851
|
+
|
|
852
|
+
program
|
|
853
|
+
.command("export-static")
|
|
854
|
+
.description("Export standalone static website (using esbuild)")
|
|
855
|
+
.action(() => {
|
|
856
|
+
runProdSteps(exportStaticSteps("esbuild"));
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
program
|
|
860
|
+
.command("export-static:esbuild")
|
|
861
|
+
.description("Export standalone static website with Esbuild")
|
|
862
|
+
.action(() => {
|
|
863
|
+
runProdSteps(exportStaticSteps("esbuild"));
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
program
|
|
867
|
+
.command("export-static:rollup")
|
|
868
|
+
.description("Export standalone static website with Rollup")
|
|
869
|
+
.action(() => {
|
|
870
|
+
runProdSteps(exportStaticSteps("rollup"));
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
program
|
|
874
|
+
.command("export-static:webpack")
|
|
875
|
+
.description("Export standalone static website with Webpack")
|
|
876
|
+
.action(() => {
|
|
877
|
+
runProdSteps(exportStaticSteps("webpack"));
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
// --- VENDORS ---
|
|
881
|
+
|
|
882
|
+
program
|
|
883
|
+
.command("build:vendors")
|
|
884
|
+
.description("Bundle dependencies into dinou/compiled vendors")
|
|
885
|
+
.action(() => {
|
|
886
|
+
runSteps([jsStep("node", dinouScript("scripts/build-vendors.js"))]);
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
// --- TYPEGEN ---
|
|
890
|
+
|
|
891
|
+
program
|
|
892
|
+
.command("typegen")
|
|
893
|
+
.description(
|
|
894
|
+
"Generate .dinou/types/routes.d.ts and .dinou/routes/**/dinou.{js,d.ts} from src/"
|
|
895
|
+
)
|
|
896
|
+
.action(async () => {
|
|
897
|
+
loadEnvFiles(projectRoot);
|
|
898
|
+
const { generateRouteTypes } = await import("./core/generate-route-types.js");
|
|
899
|
+
const stats = generateRouteTypes(projectRoot);
|
|
900
|
+
if (stats) {
|
|
901
|
+
console.log(
|
|
902
|
+
`🦖 [Dinou] Generated .dinou/types/routes.d.ts & contextual "./dinou" modules (${stats.totalRoutes} routes, ${stats.layoutCount} layouts, ${stats.slotCount} slots, ${stats.contextualDirCount} route dirs)`
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
// --- EJECT / UNEJECT ---
|
|
908
|
+
|
|
909
|
+
program
|
|
910
|
+
.command("eject")
|
|
911
|
+
.description("Copy the framework into ./dinou at the root of the project")
|
|
912
|
+
.option(
|
|
913
|
+
"-f, --force",
|
|
914
|
+
"Overwrite an existing ./dinou directory when running from node_modules"
|
|
915
|
+
)
|
|
916
|
+
.option(
|
|
917
|
+
"--skip-install",
|
|
918
|
+
"Skip running package manager install after updating package.json"
|
|
919
|
+
)
|
|
920
|
+
.action(async (opts) => {
|
|
921
|
+
const localDinouDir = path.resolve(projectRoot, "dinou");
|
|
922
|
+
const normCurrent = path
|
|
923
|
+
.resolve(dinouPath)
|
|
924
|
+
.replace(/\\/g, "/")
|
|
925
|
+
.toLowerCase();
|
|
926
|
+
const normTarget = localDinouDir.replace(/\\/g, "/").toLowerCase();
|
|
927
|
+
|
|
928
|
+
if (normCurrent === normTarget) {
|
|
929
|
+
console.log(
|
|
930
|
+
'ℹ️ [Dinou Eject] This project is already ejected in ./dinou. Skipping to prevent overwriting your local framework customizations. (Run "npm run uneject" to revert to node_modules/dinou.)'
|
|
931
|
+
);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
if (fs.existsSync(localDinouDir) && !opts.force) {
|
|
936
|
+
console.log(
|
|
937
|
+
'ℹ️ [Dinou Eject] Directory ./dinou already exists. Skipping to prevent overwriting local changes (pass --force from node_modules/dinou to overwrite, or run "npm run uneject" first).'
|
|
938
|
+
);
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
let ejectMod;
|
|
943
|
+
try {
|
|
944
|
+
ejectMod = await import("../eject.js");
|
|
945
|
+
} catch (err) {
|
|
946
|
+
if (
|
|
947
|
+
err &&
|
|
948
|
+
(err.code === "ERR_MODULE_NOT_FOUND" ||
|
|
949
|
+
err.code === "MODULE_NOT_FOUND")
|
|
950
|
+
) {
|
|
951
|
+
console.log(
|
|
952
|
+
'ℹ️ [Dinou Eject] This project is already running in Ejected Mode (./dinou). Skipping eject to protect local changes. (Run "npm run uneject" to revert to node_modules/dinou.)'
|
|
953
|
+
);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
throw err;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
console.log("Executing eject...");
|
|
960
|
+
ejectMod.eject({
|
|
961
|
+
force: Boolean(opts.force),
|
|
962
|
+
skipInstall: Boolean(opts.skipInstall),
|
|
963
|
+
projectRoot,
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
program
|
|
968
|
+
.command("uneject [version]")
|
|
969
|
+
.description(
|
|
970
|
+
"Revert an ejected ./dinou directory back to the node_modules dinou package"
|
|
971
|
+
)
|
|
972
|
+
.option("-y, --yes", "Skip interactive confirmation prompt")
|
|
973
|
+
.option(
|
|
974
|
+
"--skip-install",
|
|
975
|
+
"Update package.json and remove ./dinou without running package manager install"
|
|
976
|
+
)
|
|
977
|
+
.option(
|
|
978
|
+
"--keep-dinou",
|
|
979
|
+
"Keep the local ./dinou directory on disk instead of deleting it"
|
|
980
|
+
)
|
|
981
|
+
.action(async (version, opts) => {
|
|
982
|
+
const { uneject } = await import("./core/uneject.js");
|
|
983
|
+
await uneject({
|
|
984
|
+
spec: version || "latest",
|
|
985
|
+
yes: Boolean(opts.yes),
|
|
986
|
+
skipInstall: Boolean(opts.skipInstall),
|
|
987
|
+
keepDinouDir: Boolean(opts.keepDinou),
|
|
988
|
+
projectRoot,
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
program.parse(process.argv);
|