vinext 0.0.39 → 0.0.40

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 (50) hide show
  1. package/dist/build/standalone.js +7 -0
  2. package/dist/build/standalone.js.map +1 -1
  3. package/dist/entries/app-rsc-entry.d.ts +2 -1
  4. package/dist/entries/app-rsc-entry.js +131 -245
  5. package/dist/entries/app-rsc-entry.js.map +1 -1
  6. package/dist/index.d.ts +32 -1
  7. package/dist/index.js +80 -6
  8. package/dist/index.js.map +1 -1
  9. package/dist/plugins/server-externals-manifest.d.ts +11 -1
  10. package/dist/plugins/server-externals-manifest.js +10 -3
  11. package/dist/plugins/server-externals-manifest.js.map +1 -1
  12. package/dist/routing/app-router.d.ts +10 -2
  13. package/dist/routing/app-router.js +37 -22
  14. package/dist/routing/app-router.js.map +1 -1
  15. package/dist/server/app-page-response.d.ts +12 -1
  16. package/dist/server/app-page-response.js +26 -7
  17. package/dist/server/app-page-response.js.map +1 -1
  18. package/dist/server/app-page-route-wiring.d.ts +79 -0
  19. package/dist/server/app-page-route-wiring.js +165 -0
  20. package/dist/server/app-page-route-wiring.js.map +1 -0
  21. package/dist/server/app-page-stream.js +3 -0
  22. package/dist/server/app-page-stream.js.map +1 -1
  23. package/dist/server/app-route-handler-response.js +4 -1
  24. package/dist/server/app-route-handler-response.js.map +1 -1
  25. package/dist/server/app-router-entry.d.ts +6 -1
  26. package/dist/server/app-router-entry.js +9 -2
  27. package/dist/server/app-router-entry.js.map +1 -1
  28. package/dist/server/prod-server.d.ts +1 -1
  29. package/dist/server/prod-server.js +37 -11
  30. package/dist/server/prod-server.js.map +1 -1
  31. package/dist/server/worker-utils.d.ts +4 -1
  32. package/dist/server/worker-utils.js +31 -1
  33. package/dist/server/worker-utils.js.map +1 -1
  34. package/dist/shims/error-boundary.d.ts +13 -4
  35. package/dist/shims/error-boundary.js +23 -3
  36. package/dist/shims/error-boundary.js.map +1 -1
  37. package/dist/shims/head.js.map +1 -1
  38. package/dist/shims/navigation.d.ts +16 -1
  39. package/dist/shims/navigation.js +18 -3
  40. package/dist/shims/navigation.js.map +1 -1
  41. package/dist/shims/router.js +127 -38
  42. package/dist/shims/router.js.map +1 -1
  43. package/dist/shims/script.js.map +1 -1
  44. package/dist/shims/server.d.ts +17 -4
  45. package/dist/shims/server.js +91 -73
  46. package/dist/shims/server.js.map +1 -1
  47. package/dist/shims/slot.d.ts +28 -0
  48. package/dist/shims/slot.js +49 -0
  49. package/dist/shims/slot.js.map +1 -0
  50. package/package.json +1 -2
package/dist/index.d.ts CHANGED
@@ -96,6 +96,9 @@ declare const clientOutputConfig: {
96
96
  * tryCatchDeoptimization: false, which can break specific libraries
97
97
  * that rely on property access side effects or try/catch for feature detection
98
98
  * - 'recommended' + 'no-external' gives most of the benefit with less risk
99
+ *
100
+ * @deprecated Use getClientTreeshakeConfigForVite(viteMajorVersion) instead
101
+ * for Vite version compatibility. Kept for backward compatibility.
99
102
  */
100
103
  declare const clientTreeshakeConfig: {
101
104
  preset: "recommended";
@@ -112,6 +115,33 @@ declare function getClientOutputConfigForVite(viteMajorVersion: number): {
112
115
  }[];
113
116
  };
114
117
  };
118
+ /**
119
+ * Returns treeshake configuration appropriate for the Vite version.
120
+ *
121
+ * Rollup (Vite 7) supports presets like "recommended" which set multiple
122
+ * treeshake options at once. Rolldown (Vite 8+) doesn't support presets,
123
+ * so we only return moduleSideEffects for Vite 8+.
124
+ *
125
+ * The Rollup "recommended" preset sets:
126
+ * - annotations: true (Rolldown default is also true)
127
+ * - manualPureFunctions: [] (Rolldown default is also [])
128
+ * - propertyReadSideEffects: true (Rolldown equivalent is 'always', the default)
129
+ * - unknownGlobalSideEffects: false (Rolldown default is true — this is a known acceptable
130
+ * divergence. Slightly less aggressive DCE on unknown globals, acceptable for client bundles)
131
+ * - correctVarValueBeforeDeclaration and tryCatchDeoptimization (Rolldown handles these differently)
132
+ *
133
+ * The key optimization is moduleSideEffects: "no-external", which is supported
134
+ * by both bundlers and provides the DCE benefits for barrel-exporting libraries.
135
+ * It treats node_modules as side-effect-free (enabling aggressive DCE) while
136
+ * preserving side effects in local code.
137
+ */
138
+ declare function getClientTreeshakeConfigForVite(viteMajorVersion: number): {
139
+ moduleSideEffects: "no-external";
140
+ preset?: undefined;
141
+ } | {
142
+ preset: "recommended";
143
+ moduleSideEffects: "no-external";
144
+ };
115
145
  type BundleBackfillChunk = {
116
146
  type: "chunk";
117
147
  fileName: string;
@@ -229,6 +259,7 @@ declare const _mdxScanCache: Map<string, boolean>;
229
259
  * Check if the project has .mdx files in app/ or pages/ directories.
230
260
  */
231
261
  declare function hasMdxFiles(root: string, appDir: string | null, pagesDir: string | null): boolean;
262
+ declare function scanPublicFileRoutes(root: string): string[];
232
263
  //#endregion
233
- export { type AppStaticExportOptions, type NextConfig, type StaticExportOptions, type StaticExportResult, VinextOptions, asyncHooksStubPlugin as _asyncHooksStubPlugin, augmentSsrManifestFromBundle as _augmentSsrManifestFromBundle, _findBalancedObject, _findCallEnd, hasMdxFiles as _hasMdxFiles, _mdxScanCache, parseStaticObjectLiteral as _parseStaticObjectLiteral, _postcssCache, resolvePostcssStringPlugins as _resolvePostcssStringPlugins, stripServerExports as _stripServerExports, clientManualChunks, clientOutputConfig, clientTreeshakeConfig, computeLazyChunks, vinext as default, getClientOutputConfigForVite, matchConfigPattern, staticExportApp, staticExportPages };
264
+ export { type AppStaticExportOptions, type NextConfig, type StaticExportOptions, type StaticExportResult, VinextOptions, asyncHooksStubPlugin as _asyncHooksStubPlugin, augmentSsrManifestFromBundle as _augmentSsrManifestFromBundle, _findBalancedObject, _findCallEnd, hasMdxFiles as _hasMdxFiles, _mdxScanCache, parseStaticObjectLiteral as _parseStaticObjectLiteral, _postcssCache, resolvePostcssStringPlugins as _resolvePostcssStringPlugins, scanPublicFileRoutes as _scanPublicFileRoutes, stripServerExports as _stripServerExports, clientManualChunks, clientOutputConfig, clientTreeshakeConfig, computeLazyChunks, vinext as default, getClientOutputConfigForVite, getClientTreeshakeConfigForVite, matchConfigPattern, staticExportApp, staticExportPages };
234
265
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -382,6 +382,9 @@ const clientCodeSplittingConfig = {
382
382
  * tryCatchDeoptimization: false, which can break specific libraries
383
383
  * that rely on property access side effects or try/catch for feature detection
384
384
  * - 'recommended' + 'no-external' gives most of the benefit with less risk
385
+ *
386
+ * @deprecated Use getClientTreeshakeConfigForVite(viteMajorVersion) instead
387
+ * for Vite version compatibility. Kept for backward compatibility.
385
388
  */
386
389
  const clientTreeshakeConfig = {
387
390
  preset: "recommended",
@@ -397,6 +400,33 @@ function withBuildBundlerOptions(viteMajorVersion, bundlerOptions) {
397
400
  function getClientOutputConfigForVite(viteMajorVersion) {
398
401
  return viteMajorVersion >= 8 ? { codeSplitting: clientCodeSplittingConfig } : clientOutputConfig;
399
402
  }
403
+ /**
404
+ * Returns treeshake configuration appropriate for the Vite version.
405
+ *
406
+ * Rollup (Vite 7) supports presets like "recommended" which set multiple
407
+ * treeshake options at once. Rolldown (Vite 8+) doesn't support presets,
408
+ * so we only return moduleSideEffects for Vite 8+.
409
+ *
410
+ * The Rollup "recommended" preset sets:
411
+ * - annotations: true (Rolldown default is also true)
412
+ * - manualPureFunctions: [] (Rolldown default is also [])
413
+ * - propertyReadSideEffects: true (Rolldown equivalent is 'always', the default)
414
+ * - unknownGlobalSideEffects: false (Rolldown default is true — this is a known acceptable
415
+ * divergence. Slightly less aggressive DCE on unknown globals, acceptable for client bundles)
416
+ * - correctVarValueBeforeDeclaration and tryCatchDeoptimization (Rolldown handles these differently)
417
+ *
418
+ * The key optimization is moduleSideEffects: "no-external", which is supported
419
+ * by both bundlers and provides the DCE benefits for barrel-exporting libraries.
420
+ * It treats node_modules as side-effect-free (enabling aggressive DCE) while
421
+ * preserving side effects in local code.
422
+ */
423
+ function getClientTreeshakeConfigForVite(viteMajorVersion) {
424
+ if (viteMajorVersion >= 8) return { moduleSideEffects: "no-external" };
425
+ return {
426
+ preset: "recommended",
427
+ moduleSideEffects: "no-external"
428
+ };
429
+ }
400
430
  function tryRealpathSync(candidate) {
401
431
  try {
402
432
  return fs.realpathSync.native(candidate);
@@ -730,7 +760,7 @@ function vinext(options = {}) {
730
760
  else defaultHandler(warning);
731
761
  };
732
762
  })(),
733
- ...!isSSR && !isMultiEnv ? { treeshake: clientTreeshakeConfig } : {},
763
+ ...!isSSR && !isMultiEnv ? { treeshake: getClientTreeshakeConfigForVite(viteMajorVersion) } : {},
734
764
  ...!isSSR && !isMultiEnv ? { output: getClientOutputConfigForVite(viteMajorVersion) } : {}
735
765
  }) },
736
766
  server: { cors: {
@@ -847,7 +877,7 @@ function vinext(options = {}) {
847
877
  ...withBuildBundlerOptions(viteMajorVersion, {
848
878
  input: { index: VIRTUAL_APP_BROWSER_ENTRY },
849
879
  output: getClientOutputConfigForVite(viteMajorVersion),
850
- treeshake: clientTreeshakeConfig
880
+ treeshake: getClientTreeshakeConfigForVite(viteMajorVersion)
851
881
  })
852
882
  }
853
883
  }
@@ -861,7 +891,7 @@ function vinext(options = {}) {
861
891
  ...withBuildBundlerOptions(viteMajorVersion, {
862
892
  input: { index: VIRTUAL_CLIENT_ENTRY },
863
893
  output: getClientOutputConfigForVite(viteMajorVersion),
864
- treeshake: clientTreeshakeConfig
894
+ treeshake: getClientTreeshakeConfigForVite(viteMajorVersion)
865
895
  })
866
896
  }
867
897
  } };
@@ -876,7 +906,7 @@ function vinext(options = {}) {
876
906
  ...withBuildBundlerOptions(viteMajorVersion, {
877
907
  input: { index: VIRTUAL_CLIENT_ENTRY },
878
908
  output: getClientOutputConfigForVite(viteMajorVersion),
879
- treeshake: clientTreeshakeConfig
909
+ treeshake: getClientTreeshakeConfigForVite(viteMajorVersion)
880
910
  })
881
911
  }
882
912
  },
@@ -957,7 +987,8 @@ function vinext(options = {}) {
957
987
  allowedDevOrigins: nextConfig?.allowedDevOrigins,
958
988
  bodySizeLimit: nextConfig?.serverActionsBodySizeLimit,
959
989
  i18n: nextConfig?.i18n,
960
- hasPagesDir
990
+ hasPagesDir,
991
+ publicFiles: scanPublicFileRoutes(root)
961
992
  }, instrumentationPath);
962
993
  }
963
994
  if (id === RESOLVED_APP_SSR_ENTRY && hasAppDir) return generateSsrEntry(hasPagesDir);
@@ -2042,7 +2073,50 @@ function scanDirForMdx(dir) {
2042
2073
  } catch {}
2043
2074
  return false;
2044
2075
  }
2076
+ function scanPublicFileRoutes(root) {
2077
+ const publicDir = path.join(root, "public");
2078
+ const routes = [];
2079
+ const visitedDirs = /* @__PURE__ */ new Set();
2080
+ function walk(dir) {
2081
+ let realDir;
2082
+ try {
2083
+ realDir = fs.realpathSync(dir);
2084
+ } catch {
2085
+ return;
2086
+ }
2087
+ if (visitedDirs.has(realDir)) return;
2088
+ visitedDirs.add(realDir);
2089
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
2090
+ for (const entry of entries) {
2091
+ const fullPath = path.join(dir, entry.name);
2092
+ if (entry.isDirectory()) {
2093
+ walk(fullPath);
2094
+ continue;
2095
+ }
2096
+ if (entry.isSymbolicLink()) {
2097
+ let stat;
2098
+ try {
2099
+ stat = fs.statSync(fullPath);
2100
+ } catch {
2101
+ continue;
2102
+ }
2103
+ if (stat.isDirectory()) {
2104
+ walk(fullPath);
2105
+ continue;
2106
+ }
2107
+ if (!stat.isFile()) continue;
2108
+ } else if (!entry.isFile()) continue;
2109
+ const relativePath = path.relative(publicDir, fullPath).split(path.sep).join("/");
2110
+ routes.push("/" + relativePath);
2111
+ }
2112
+ }
2113
+ if (fs.existsSync(publicDir)) try {
2114
+ walk(publicDir);
2115
+ } catch {}
2116
+ routes.sort();
2117
+ return routes;
2118
+ }
2045
2119
  //#endregion
2046
- export { asyncHooksStubPlugin as _asyncHooksStubPlugin, augmentSsrManifestFromBundle as _augmentSsrManifestFromBundle, _findBalancedObject, _findCallEnd, hasMdxFiles as _hasMdxFiles, _mdxScanCache, parseStaticObjectLiteral as _parseStaticObjectLiteral, _postcssCache, resolvePostcssStringPlugins as _resolvePostcssStringPlugins, stripServerExports as _stripServerExports, clientManualChunks, clientOutputConfig, clientTreeshakeConfig, computeLazyChunks, vinext as default, getClientOutputConfigForVite, matchConfigPattern, staticExportApp, staticExportPages };
2120
+ export { asyncHooksStubPlugin as _asyncHooksStubPlugin, augmentSsrManifestFromBundle as _augmentSsrManifestFromBundle, _findBalancedObject, _findCallEnd, hasMdxFiles as _hasMdxFiles, _mdxScanCache, parseStaticObjectLiteral as _parseStaticObjectLiteral, _postcssCache, resolvePostcssStringPlugins as _resolvePostcssStringPlugins, scanPublicFileRoutes as _scanPublicFileRoutes, stripServerExports as _stripServerExports, clientManualChunks, clientOutputConfig, clientTreeshakeConfig, computeLazyChunks, vinext as default, getClientOutputConfigForVite, getClientTreeshakeConfigForVite, matchConfigPattern, staticExportApp, staticExportPages };
2047
2121
 
2048
2122
  //# sourceMappingURL=index.js.map