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.
Files changed (166) hide show
  1. package/CHANGELOG.md +196 -0
  2. package/README.md +157 -132
  3. package/dinou/adapters/bun.js +34 -5
  4. package/dinou/adapters/cloudflare.js +110 -17
  5. package/dinou/adapters/deno.js +46 -8
  6. package/dinou/adapters/netlify.js +86 -50
  7. package/dinou/adapters/node.js +8 -0
  8. package/dinou/assets.d.ts +32 -5
  9. package/dinou/bun/build.js +190 -106
  10. package/dinou/cli.js +992 -532
  11. package/dinou/cloudflare/build.js +187 -106
  12. package/dinou/compiled/autoprefixer/index.js +509 -517
  13. package/dinou/compiled/babel-core/index.js +738 -716
  14. package/dinou/compiled/babel-generator/index.js +341 -299
  15. package/dinou/compiled/babel-loader/index.js +766 -744
  16. package/dinou/compiled/babel-parser/index.js +2 -2
  17. package/dinou/compiled/babel-plugin-react-compiler/index.js +178 -178
  18. package/dinou/compiled/babel-plugin-syntax-import-meta/index.js +4 -4
  19. package/dinou/compiled/babel-preset-react/index.js +752 -730
  20. package/dinou/compiled/babel-preset-typescript/index.js +738 -716
  21. package/dinou/compiled/babel-traverse/index.js +463 -433
  22. package/dinou/compiled/babel-types/index.js +176 -176
  23. package/dinou/compiled/chokidar/index.js +4 -4
  24. package/dinou/compiled/commander/index.js +15 -15
  25. package/dinou/compiled/copy-webpack-plugin/index.js +433 -425
  26. package/dinou/compiled/css-loader/index.js +289 -289
  27. package/dinou/compiled/css-loader/runtime/api.js +85 -0
  28. package/dinou/compiled/css-loader/runtime/getUrl.js +26 -0
  29. package/dinou/compiled/css-loader/runtime/noSourceMaps.js +5 -0
  30. package/dinou/compiled/css-loader/runtime/package.json +3 -0
  31. package/dinou/compiled/css-loader/runtime/sourceMaps.js +16 -0
  32. package/dinou/compiled/fast-glob/index.js +5810 -0
  33. package/dinou/compiled/generic-names/index.js +16 -16
  34. package/dinou/compiled/mini-css-extract-plugin/{chunk-YYEJWYXE.js → chunk-R6DP5ZYM.js} +36 -36
  35. package/dinou/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +253 -0
  36. package/dinou/compiled/mini-css-extract-plugin/hmr/normalize-url.js +39 -0
  37. package/dinou/compiled/mini-css-extract-plugin/hmr/package.json +3 -0
  38. package/dinou/compiled/mini-css-extract-plugin/index.js +1 -1
  39. package/dinou/compiled/mini-css-extract-plugin/loader.js +5 -5
  40. package/dinou/compiled/postcss/index.js +83 -83
  41. package/dinou/compiled/postcss-import/index.js +147 -117
  42. package/dinou/compiled/postcss-modules/index.js +216 -216
  43. package/dinou/compiled/resolve/index.js +1224 -0
  44. package/dinou/compiled/rollup-plugin-babel/index.js +753 -731
  45. package/dinou/compiled/rollup-plugin-commonjs/index.js +43 -38
  46. package/dinou/compiled/rollup-plugin-delete/index.js +615 -253
  47. package/dinou/compiled/rollup-plugin-json/index.js +22 -18
  48. package/dinou/compiled/rollup-plugin-node-resolve/index.js +130 -100
  49. package/dinou/compiled/rollup-plugin-postcss/index.js +3299 -3277
  50. package/dinou/compiled/rollup-plugin-replace/index.js +34 -29
  51. package/dinou/compiled/tailwindcss-postcss/index.js +214 -211
  52. package/dinou/compiled/vendors-manifest.json +59 -83
  53. package/dinou/core/asset-extensions.js +482 -33
  54. package/dinou/core/bailout-proxy.js +21 -2
  55. package/dinou/core/build-static-pages.js +523 -371
  56. package/dinou/core/builtin-asset-extensions.js +63 -0
  57. package/dinou/core/cache-revalidate.js +449 -256
  58. package/dinou/core/cache-slot.js +289 -79
  59. package/dinou/core/client-webpack.jsx +470 -39
  60. package/dinou/core/client.jsx +402 -39
  61. package/dinou/core/config.js +3 -0
  62. package/dinou/core/copy-static-dirs.js +98 -0
  63. package/dinou/core/createScopedName.js +22 -4
  64. package/dinou/core/dinou-paths.js +1 -1
  65. package/dinou/core/discover-layouts.js +200 -0
  66. package/dinou/core/edge-ssr.js +1 -1
  67. package/dinou/core/ensure-vendor-mode.js +78 -19
  68. package/dinou/core/env.js +544 -0
  69. package/dinou/core/export-static.js +41 -9
  70. package/dinou/core/generate-route-types.js +989 -95
  71. package/dinou/core/generate-static-rsc.js +5 -6
  72. package/dinou/core/generate-static.js +45 -6
  73. package/dinou/core/get-abs-path-with-ext.js +217 -75
  74. package/dinou/core/get-asset-from-manifest.js +19 -8
  75. package/dinou/core/get-error-jsx.js +4 -5
  76. package/dinou/core/get-file-path-and-dynamic-params.js +561 -338
  77. package/dinou/core/get-jsx.js +220 -53
  78. package/dinou/core/handler.js +1647 -466
  79. package/dinou/core/import-module.js +7 -0
  80. package/dinou/core/layout-functions.js +72 -13
  81. package/dinou/core/link.jsx +34 -6
  82. package/dinou/core/load-dinou-config.js +520 -89
  83. package/dinou/core/manifest-provider.js +4 -14
  84. package/dinou/core/navigation-utils.js +141 -3
  85. package/dinou/core/navigation.js +134 -50
  86. package/dinou/core/node-middleware-runner.js +165 -0
  87. package/dinou/core/postcss-pipeline.js +236 -0
  88. package/dinou/core/ppr-context.js +114 -22
  89. package/dinou/core/ppr-runtime.js +391 -127
  90. package/dinou/core/redirect.jsx +1 -1
  91. package/dinou/core/render-jsx-to-client-jsx.js +216 -48
  92. package/dinou/core/request-context.js +59 -3
  93. package/dinou/core/resolve-contextual-dinou.js +523 -0
  94. package/dinou/core/resolve-setup-files.js +85 -27
  95. package/dinou/core/revalidating.js +10 -2
  96. package/dinou/core/route-generator.js +6 -2
  97. package/dinou/core/rsc-renderer.js +4 -1
  98. package/dinou/core/run-ssg.js +6 -0
  99. package/dinou/core/runtime-env.js +265 -0
  100. package/dinou/core/server-css-modules-plugin.js +155 -0
  101. package/dinou/core/server-function-proxy-webpack.js +27 -2
  102. package/dinou/core/server-function-proxy.js +27 -2
  103. package/dinou/core/slot.js +47 -2
  104. package/dinou/core/static-assets.js +503 -0
  105. package/dinou/core/storage-adapter.js +452 -24
  106. package/dinou/core/transform-server-functions.js +272 -24
  107. package/dinou/core/tsconfig-aliases.js +964 -0
  108. package/dinou/core/uneject.js +640 -0
  109. package/dinou/core/url-resolver.js +1 -1
  110. package/dinou/core/vfs.js +11 -2
  111. package/dinou/css.d.ts +4 -1
  112. package/dinou/deno/build.js +205 -153
  113. package/dinou/deno/seed-kv.js +4 -0
  114. package/dinou/env.d.ts +22 -2
  115. package/dinou/esbuild/build.js +40 -50
  116. package/dinou/esbuild/dev.js +33 -7
  117. package/dinou/esbuild/helpers-esbuild/get-config-esbuild-prod.js +41 -16
  118. package/dinou/esbuild/helpers-esbuild/get-config-esbuild.js +51 -49
  119. package/dinou/esbuild/helpers-esbuild/get-esbuild-entries.js +73 -60
  120. package/dinou/esbuild/helpers-esbuild/swc-disk-cache.js +35 -16
  121. package/dinou/esbuild/helpers-esbuild/write.js +13 -3
  122. package/dinou/esbuild/plugins-esbuild/assets-plugin.js +100 -238
  123. package/dinou/esbuild/plugins-esbuild/babel-react-compiler-plugin.js +73 -29
  124. package/dinou/esbuild/plugins-esbuild/css-processor-plugin.js +283 -91
  125. package/dinou/esbuild/plugins-esbuild/manifest-generator-plugin.js +3 -5
  126. package/dinou/esbuild/plugins-esbuild/react-client-manifest-plugin.js +9 -3
  127. package/dinou/esbuild/plugins-esbuild/server-functions-plugin.js +4 -3
  128. package/dinou/esbuild/plugins-esbuild/stable-chunk-names-and-maps-plugin.js +10 -1
  129. package/dinou/esbuild/plugins-postcss/postcss-extract-plugin.js +84 -21
  130. package/dinou/esbuild/react-refresh/esm-hmr/client.js +31 -10
  131. package/dinou/esbuild/react-refresh/esm-hmr-plugin.js +48 -18
  132. package/dinou/esbuild/react-refresh/is-react-refresh-boundary.js +9 -1
  133. package/dinou/esbuild/react-refresh/react-refresh-runtime.js +13 -7
  134. package/dinou/index.d.ts +1028 -88
  135. package/dinou/node/build.js +138 -74
  136. package/dinou/node/bundle-dual-engine.js +393 -131
  137. package/dinou/node/dev.js +1005 -275
  138. package/dinou/package.json +11 -34
  139. package/dinou/rollup/postcss.config.js +3 -4
  140. package/dinou/rollup/react-refresh/esm-hmr/client.js +31 -10
  141. package/dinou/rollup/react-refresh/react-refresh-wrap-modules.js +16 -13
  142. package/dinou/rollup/react-refresh/rollup-plugin-esm-hmr.js +53 -7
  143. package/dinou/rollup/rollup-plugins/dinou-asset-plugin.js +58 -20
  144. package/dinou/rollup/rollup-plugins/manifest-generator-plugin.js +16 -7
  145. package/dinou/rollup/rollup-plugins/rollup-plugin-react-client-manifest.js +118 -42
  146. package/dinou/rollup/rollup-plugins/rollup-plugin-server-functions.js +48 -36
  147. package/dinou/rollup/rollup.config.js +174 -101
  148. package/dinou/scripts/build-vendors.js +123 -33
  149. package/dinou/server.d.ts +126 -15
  150. package/dinou/webpack/helpers/get-webpack-entries.js +87 -41
  151. package/dinou/webpack/helpers/patch-webpack-internals.js +93 -1
  152. package/dinou/webpack/loaders/server-functions-loader.js +1 -1
  153. package/dinou/webpack/plugins/manifest-generator-plugin.js +27 -7
  154. package/dinou/webpack/plugins/server-functions-plugin.js +39 -12
  155. package/dinou/webpack/plugins/webpack-memory-plugin.js +25 -12
  156. package/dinou/webpack/postcss.config.js +3 -4
  157. package/dinou/webpack/webpack.config.js +408 -132
  158. package/eject.js +6 -224
  159. package/package.json +7 -9
  160. package/dinou/compiled/cross-env/index.js +0 -661
  161. package/dinou/compiled/dotenv/index.js +0 -375
  162. package/dinou/compiled/esbuild-copy-static-files/index.js +0 -63
  163. package/dinou/compiled/esbuild-tsconfig-paths/index.js +0 -1314
  164. package/dinou/compiled/rollup-plugin-copy/index.js +0 -12066
  165. package/dinou/compiled/rollup-plugin-tsconfig-paths/index.js +0 -569
  166. package/dinou/compiled/tsconfig-paths-webpack-plugin/index.js +0 -3956
@@ -150,7 +150,13 @@ socket.addEventListener("message", ({ data: _data }) => {
150
150
 
151
151
  if (data.type === "rsc-update") {
152
152
  if (typeof window !== "undefined" && typeof window.__DINOU_ROUTER_REFRESH__ === "function") {
153
- window.__DINOU_ROUTER_REFRESH__();
153
+ const refreshLayout = Boolean(
154
+ data.layout ||
155
+ (data.path &&
156
+ (/(?:^|[\\/])layout\.[jt]sx?$/i.test(data.path) ||
157
+ /\.module\.css$/i.test(data.path)))
158
+ );
159
+ window.__DINOU_ROUTER_REFRESH__({ layout: refreshLayout });
154
160
  return;
155
161
  }
156
162
  reload();
@@ -162,16 +168,31 @@ socket.addEventListener("message", ({ data: _data }) => {
162
168
  (data.type === "update" && data.url && (data.url.endsWith(".css") || data.url.includes("styles.css")))
163
169
  ) {
164
170
  const targetUrl = data.url ? data.url.split("?")[0] : "";
165
- const links = document.querySelectorAll('link[rel="stylesheet"]');
166
- for (const link of links) {
167
- const rawHref = link.getAttribute("href");
168
- if (!rawHref) continue;
169
- const cleanHref = rawHref.split("?")[0];
170
- if (!targetUrl || cleanHref.endsWith(targetUrl) || targetUrl.endsWith(cleanHref) || cleanHref.includes("styles.css")) {
171
- const nextUrl = new URL(link.href, window.location.origin);
172
- nextUrl.searchParams.set("t", String(Date.now()));
173
- link.href = nextUrl.href;
171
+ const applyStyleUpdate = () => {
172
+ const links = document.querySelectorAll('link[rel="stylesheet"]');
173
+ for (const link of links) {
174
+ const rawHref = link.getAttribute("href");
175
+ if (!rawHref) continue;
176
+ const cleanHref = rawHref.split("?")[0];
177
+ if (!targetUrl || cleanHref.endsWith(targetUrl) || targetUrl.endsWith(cleanHref) || cleanHref.includes("styles.css")) {
178
+ const nextUrl = new URL(link.href, window.location.origin);
179
+ nextUrl.searchParams.set("t", String(Date.now()));
180
+ link.href = nextUrl.href;
181
+ }
174
182
  }
183
+ };
184
+
185
+ if (typeof document !== "undefined" && document.body?.getAttribute("data-hydrated") === "true") {
186
+ applyStyleUpdate();
187
+ } else if (typeof window !== "undefined") {
188
+ let attempts = 0;
189
+ const waitHydration = setInterval(() => {
190
+ attempts++;
191
+ if (document.body?.getAttribute("data-hydrated") === "true" || attempts >= 60) {
192
+ clearInterval(waitHydration);
193
+ applyStyleUpdate();
194
+ }
195
+ }, 50);
175
196
  }
176
197
  return;
177
198
  }
@@ -64,10 +64,28 @@ async function saveSwcCache() {
64
64
  export default function esmHmrPlugin({
65
65
  entryNames = ["main", "error"],
66
66
  changedIds,
67
+ cssModuleClassChanges,
67
68
  hmrEngine,
68
69
  hmrPort,
69
70
  } = {}) {
70
- const port = hmrPort || Number(process.env.HMR_PORT || (Number(process.env.PORT || 3000) + 1));
71
+ const port =
72
+ hmrPort !== undefined
73
+ ? hmrPort
74
+ : Number(process.env.HMR_PORT || Number(process.env.PORT || 3000) + 1);
75
+
76
+ const isPureCssStyleUpdate = (lowerPath) => {
77
+ if (
78
+ !lowerPath.endsWith(".css") &&
79
+ !lowerPath.endsWith(".scss") &&
80
+ !lowerPath.endsWith(".less")
81
+ ) {
82
+ return false;
83
+ }
84
+ if (!lowerPath.endsWith(".module.css")) {
85
+ return true;
86
+ }
87
+ return !cssModuleClassChanges?.has(lowerPath);
88
+ };
71
89
 
72
90
  return {
73
91
  name: "esm-hmr",
@@ -83,7 +101,7 @@ export default function esmHmrPlugin({
83
101
  const entryAbsPaths = [];
84
102
  const entryOutputNames = [];
85
103
 
86
- if (!serverStarted) {
104
+ if (!serverStarted && !hmrEngine?.value) {
87
105
  const server = createServer();
88
106
  server.on("error", (err) => {
89
107
  if (err.code === "EADDRINUSE") {
@@ -202,6 +220,15 @@ export default function esmHmrPlugin({
202
220
  const outfile_basename = path.basename(outfile);
203
221
  const urlId = "/" + outfile_basename;
204
222
  const safeId = JSON.stringify(urlId);
223
+ if (outfile_basename === "main.js") {
224
+ const mainSource = new TextDecoder().decode(outputFile.contents);
225
+ if (!/^\s*import\s+["']\/runtime\.js["'];/.test(mainSource)) {
226
+ outputFile.contents = new TextEncoder().encode(
227
+ `import "/runtime.js";\n${mainSource}`
228
+ );
229
+ }
230
+ continue;
231
+ }
205
232
  const frameworkEntries = new Set([
206
233
  "main.js",
207
234
  "serverFunctionProxy.js",
@@ -238,13 +265,16 @@ export default function esmHmrPlugin({
238
265
  }
239
266
  const wrappedCode = `
240
267
  const RefreshRuntime = window.__reactRefreshRuntime;
268
+ const actualRuntime = RefreshRuntime?.default || RefreshRuntime;
241
269
  let prevRefreshReg = window.$RefreshReg$;
242
270
  let prevRefreshSig = window.$RefreshSig$;
243
271
  window.$RefreshReg$ = (type, id) => {
244
272
  const fullId = (id && id.includes('#')) ? id : (${safeId} + '#' + id);
245
- RefreshRuntime.register(type, fullId);
273
+ actualRuntime?.register(type, fullId);
246
274
  };
247
- window.$RefreshSig$ = RefreshRuntime?.createSignatureFunctionForTransform;
275
+ window.$RefreshSig$ = actualRuntime?.createSignatureFunctionForTransform
276
+ ? actualRuntime.createSignatureFunctionForTransform.bind(actualRuntime)
277
+ : (prevRefreshSig || (() => (type) => type));
248
278
  if (!import.meta.hot) import.meta.hot = window.__hotContext?.(${safeId});
249
279
  // --- original code ---
250
280
  ${source}
@@ -252,7 +282,7 @@ export default function esmHmrPlugin({
252
282
  if (import.meta.hot) {
253
283
  import.meta.hot.accept(({module}) => {
254
284
  if (window.__isReactRefreshBoundary && window.__isReactRefreshBoundary(module)) {
255
- window.__debouncePerformReactRefresh();
285
+ window.__debouncePerformReactRefresh?.();
256
286
  } else {
257
287
  // Fallback: full reload if it is not a boundary
258
288
  import.meta.hot.invalidate();
@@ -279,6 +309,7 @@ export default function esmHmrPlugin({
279
309
  if (isInitialBuild) {
280
310
  isInitialBuild = false;
281
311
  changedIds?.clear();
312
+ cssModuleClassChanges?.clear();
282
313
  return;
283
314
  }
284
315
 
@@ -286,19 +317,20 @@ export default function esmHmrPlugin({
286
317
  return;
287
318
  }
288
319
 
289
- if (changedIds.size === 0) return;
320
+ if (changedIds.size === 0) {
321
+ cssModuleClassChanges?.clear();
322
+ return;
323
+ }
290
324
 
291
- // If only CSS files were modified, styles are updated via style-update in cssProcessorPlugin.
325
+ // If only CSS files (or CSS Modules whose exported class names did not change)
326
+ // were modified, styles are updated via style-update in cssProcessorPlugin.
292
327
  // Do NOT trigger full reload or JS component updates.
293
- const isCssOnly = Array.from(changedIds).every((id) => {
294
- const lower = id.toLowerCase();
295
- return (
296
- (lower.endsWith(".css") || lower.endsWith(".scss") || lower.endsWith(".less")) &&
297
- !lower.endsWith(".module.css")
298
- );
299
- });
328
+ const isCssOnly = Array.from(changedIds).every((id) =>
329
+ isPureCssStyleUpdate(id.toLowerCase())
330
+ );
300
331
  if (isCssOnly) {
301
332
  changedIds.clear();
333
+ cssModuleClassChanges?.clear();
302
334
  return;
303
335
  }
304
336
 
@@ -330,10 +362,7 @@ export default function esmHmrPlugin({
330
362
  const cleanPath = stripNamespace(modulePath);
331
363
  const norm = normKey(cleanPath);
332
364
  const lower = norm.toLowerCase();
333
- if (
334
- (lower.endsWith(".css") || lower.endsWith(".scss") || lower.endsWith(".less")) &&
335
- !lower.endsWith(".module.css")
336
- ) {
365
+ if (isPureCssStyleUpdate(lower)) {
337
366
  return false;
338
367
  }
339
368
  return changedIds.has(norm);
@@ -379,6 +408,7 @@ export default function esmHmrPlugin({
379
408
  }
380
409
  saveSwcCache().catch(() => {});
381
410
  changedIds.clear();
411
+ cssModuleClassChanges?.clear();
382
412
  globalThis.__DINOU_BROADCAST_TIME__ = Date.now() - tBroadcast0;
383
413
  });
384
414
  },
@@ -1,4 +1,7 @@
1
1
  export function isReactRefreshBoundary(RefreshRuntime, moduleExports) {
2
+ if (!RefreshRuntime?.isLikelyComponentType) {
3
+ return false;
4
+ }
2
5
  if (RefreshRuntime.isLikelyComponentType(moduleExports)) {
3
6
  return true;
4
7
  }
@@ -29,7 +32,12 @@ export function isReactRefreshBoundary(RefreshRuntime, moduleExports) {
29
32
  }
30
33
 
31
34
  hasExports = true;
32
- const exportValue = moduleExports[key];
35
+ let exportValue;
36
+ try {
37
+ exportValue = moduleExports[key];
38
+ } catch (e) {
39
+ return false;
40
+ }
33
41
  if (!RefreshRuntime.isLikelyComponentType(exportValue)) {
34
42
  areAllExportsComponents = false;
35
43
  }
@@ -1,24 +1,30 @@
1
1
  import RefreshRuntime from "/react-refresh-entry.js";
2
2
  import { isReactRefreshBoundary } from "./is-react-refresh-boundary.js";
3
3
 
4
+ const runtime = RefreshRuntime?.default || RefreshRuntime;
5
+
4
6
  if (
5
7
  typeof window !== "undefined" &&
6
8
  !window.__REACT_REFRESH_RUNTIME_INSTALLED__
7
9
  ) {
8
- RefreshRuntime.injectIntoGlobalHook(window);
10
+ runtime.injectIntoGlobalHook(window);
9
11
 
10
- window.__reactRefreshRuntime = RefreshRuntime;
11
- window.$RefreshReg$ = () => { };
12
- window.$RefreshSig$ = () => (type) => type;
12
+ window.__reactRefreshRuntime = runtime;
13
+ window.$RefreshReg$ = (type, id) => {
14
+ runtime?.register(type, id);
15
+ };
16
+ window.$RefreshSig$ = runtime?.createSignatureFunctionForTransform
17
+ ? runtime.createSignatureFunctionForTransform.bind(runtime)
18
+ : () => (type) => type;
13
19
  window.__REACT_REFRESH_RUNTIME_INSTALLED__ = true;
14
20
 
15
21
  let refreshTimeout;
16
- window.performReactRefresh = RefreshRuntime.performReactRefresh;
22
+ window.performReactRefresh = runtime.performReactRefresh;
17
23
  window.__debouncePerformReactRefresh = () => {
18
24
  clearTimeout(refreshTimeout);
19
25
  refreshTimeout = setTimeout(() => {
20
26
  try {
21
- RefreshRuntime.performReactRefresh();
27
+ runtime.performReactRefresh();
22
28
  } catch (err) {
23
29
  console.warn("React Refresh failed:", err);
24
30
  }
@@ -26,5 +32,5 @@ if (
26
32
  };
27
33
 
28
34
  window.__isReactRefreshBoundary = (moduleExports) =>
29
- isReactRefreshBoundary(RefreshRuntime, moduleExports);
35
+ isReactRefreshBoundary(runtime, moduleExports);
30
36
  }