vinext 1.0.0 → 1.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 (148) hide show
  1. package/THIRD_PARTY_LICENSES.md +26 -0
  2. package/dist/build/lifecycle.js +10 -10
  3. package/dist/build/pages-client-assets-module.js +6 -1
  4. package/dist/build/precompress.js +1 -1
  5. package/dist/build/prerender-paths.js +3 -7
  6. package/dist/build/prerender.d.ts +8 -1
  7. package/dist/build/prerender.js +134 -38
  8. package/dist/build/run-prerender.js +4 -3
  9. package/dist/build/server-entry.d.ts +2 -0
  10. package/dist/build/server-entry.js +7 -1
  11. package/dist/client/browser-globals.d.ts +4 -0
  12. package/dist/client/browser-globals.js +5 -0
  13. package/dist/client/navigation-runtime.d.ts +0 -1
  14. package/dist/client/navigation-runtime.js +2 -2
  15. package/dist/config/dotenv.js +14 -3
  16. package/dist/entries/app-rsc-entry.js +3 -2
  17. package/dist/index.js +142 -71
  18. package/dist/init-cloudflare.d.ts +1 -1
  19. package/dist/init-cloudflare.js +6 -6
  20. package/dist/init-platform.js +1 -1
  21. package/dist/init.js +4 -2
  22. package/dist/plugins/commonjs-syntax.d.ts +16 -0
  23. package/dist/plugins/commonjs-syntax.js +22 -0
  24. package/dist/plugins/ignore-dynamic-requests.d.ts +11 -0
  25. package/dist/plugins/ignore-dynamic-requests.js +54 -3
  26. package/dist/plugins/import-meta-url.js +6 -6
  27. package/dist/plugins/og-asset-ownership.d.ts +2 -0
  28. package/dist/plugins/og-asset-ownership.js +24 -13
  29. package/dist/plugins/og-assets.d.ts +18 -0
  30. package/dist/plugins/og-assets.js +50 -8
  31. package/dist/plugins/og-harfbuzz.js +38 -27
  32. package/dist/plugins/optimize-imports.js +2 -1
  33. package/dist/plugins/require-context.d.ts +1 -0
  34. package/dist/plugins/require-context.js +28 -1
  35. package/dist/plugins/scan-build-css.d.ts +12 -0
  36. package/dist/plugins/scan-build-css.js +39 -0
  37. package/dist/plugins/strip-server-exports.d.ts +2 -0
  38. package/dist/plugins/strip-server-exports.js +3 -1
  39. package/dist/plugins/transform-result.d.ts +18 -0
  40. package/dist/plugins/transform-result.js +23 -2
  41. package/dist/plugins/typeof-window.d.ts +10 -0
  42. package/dist/plugins/typeof-window.js +33 -9
  43. package/dist/routing/app-route-graph.d.ts +0 -1
  44. package/dist/routing/app-route-graph.js +2 -4
  45. package/dist/routing/app-route-ids.d.ts +3 -0
  46. package/dist/routing/app-route-ids.js +6 -0
  47. package/dist/server/app-bfcache-id.d.ts +1 -0
  48. package/dist/server/app-bfcache-id.js +7 -1
  49. package/dist/server/app-bfcache-identity.js +1 -2
  50. package/dist/server/app-browser-entry.js +4 -2
  51. package/dist/server/app-browser-hydration.d.ts +1 -1
  52. package/dist/server/app-browser-hydration.js +2 -2
  53. package/dist/server/app-browser-navigation-controller.js +1 -1
  54. package/dist/server/app-browser-state.js +1 -1
  55. package/dist/server/app-browser-stream.d.ts +1 -1
  56. package/dist/server/app-history-state.d.ts +0 -1
  57. package/dist/server/app-history-state.js +2 -5
  58. package/dist/server/app-page-cache-render.js +2 -1
  59. package/dist/server/app-page-render.js +2 -1
  60. package/dist/server/app-page-search-params-observation.js +1 -1
  61. package/dist/server/app-page-stream.js +1 -1
  62. package/dist/server/app-page-tracing.js +2 -1
  63. package/dist/server/app-pages-bridge.js +3 -2
  64. package/dist/server/app-render-abort-error.d.ts +3 -0
  65. package/dist/server/app-render-abort-error.js +8 -0
  66. package/dist/server/app-request-stage-independent-entry.js +4 -7
  67. package/dist/server/app-route-handler-cache.d.ts +2 -1
  68. package/dist/server/app-route-handler-cache.js +11 -7
  69. package/dist/server/app-route-handler-dispatch.js +10 -3
  70. package/dist/server/app-route-handler-execution.d.ts +9 -1
  71. package/dist/server/app-route-handler-execution.js +28 -13
  72. package/dist/server/app-route-handler-policy.js +2 -2
  73. package/dist/server/app-route-handler-response.d.ts +1 -1
  74. package/dist/server/app-route-handler-response.js +14 -5
  75. package/dist/server/app-router-entry.d.ts +2 -1
  76. package/dist/server/app-router-entry.js +5 -9
  77. package/dist/server/app-rsc-errors.d.ts +0 -1
  78. package/dist/server/app-rsc-errors.js +2 -6
  79. package/dist/server/app-rsc-handler.d.ts +1 -0
  80. package/dist/server/app-rsc-handler.js +18 -7
  81. package/dist/server/app-rsc-request-normalization.d.ts +1 -1
  82. package/dist/server/app-rsc-request-normalization.js +3 -2
  83. package/dist/server/app-rsc-response-finalizer.js +4 -1
  84. package/dist/server/app-rsc-route-matching.js +1 -1
  85. package/dist/server/app-server-action-execution.d.ts +2 -1
  86. package/dist/server/app-ssr-entry.js +3 -3
  87. package/dist/server/app-ssr-search-params-gate.js +1 -1
  88. package/dist/server/app-ssr-stream.js +1 -1
  89. package/dist/server/cache-control.js +3 -11
  90. package/dist/server/cacheability-request.js +49 -49
  91. package/dist/server/config-headers.js +1 -1
  92. package/dist/server/dev-server.js +11 -3
  93. package/dist/server/headers.d.ts +2 -0
  94. package/dist/server/headers.js +5 -1
  95. package/dist/server/http-error-responses.js +1 -0
  96. package/dist/server/isr-cache.d.ts +2 -0
  97. package/dist/server/isr-cache.js +6 -1
  98. package/dist/server/metadata-route-response.js +94 -37
  99. package/dist/server/pages-api-route.js +8 -2
  100. package/dist/server/pages-asset-tags.d.ts +1 -0
  101. package/dist/server/pages-asset-tags.js +73 -22
  102. package/dist/server/pages-client-assets.d.ts +2 -0
  103. package/dist/server/pages-page-data.d.ts +6 -1
  104. package/dist/server/pages-page-data.js +71 -65
  105. package/dist/server/pages-page-handler.js +29 -11
  106. package/dist/server/pages-page-response.js +3 -1
  107. package/dist/server/pages-request-pipeline.d.ts +2 -1
  108. package/dist/server/pages-request-pipeline.js +20 -5
  109. package/dist/server/pages-request-stage-entry.js +6 -4
  110. package/dist/server/prerender-manifest.d.ts +6 -0
  111. package/dist/server/prerender-manifest.js +1 -1
  112. package/dist/server/prod-server.js +3 -13
  113. package/dist/server/response-stage-cacheability.js +1 -1
  114. package/dist/server/worker-revalidation-context.d.ts +2 -1
  115. package/dist/server/worker-revalidation-context.js +1 -0
  116. package/dist/server/workers-tracing.d.ts +17 -0
  117. package/dist/server/workers-tracing.js +48 -8
  118. package/dist/shims/cache-request-state.d.ts +3 -14
  119. package/dist/shims/cache-request-state.js +2 -13
  120. package/dist/shims/cache-runtime.js +4 -2
  121. package/dist/shims/cache.d.ts +2 -1
  122. package/dist/shims/cache.js +4 -2
  123. package/dist/shims/cacheability-classification.d.ts +1 -1
  124. package/dist/shims/cacheability-classification.js +2 -2
  125. package/dist/shims/cdn-cache.d.ts +10 -1
  126. package/dist/shims/cdn-cache.js +16 -9
  127. package/dist/shims/error.d.ts +4 -18
  128. package/dist/shims/error.js +17 -10
  129. package/dist/shims/error.react-server.d.ts +4 -6
  130. package/dist/shims/error.react-server.js +4 -1
  131. package/dist/shims/fetch-cache.js +4 -3
  132. package/dist/shims/headers.d.ts +6 -69
  133. package/dist/shims/headers.js +37 -181
  134. package/dist/shims/internal/cache-context-accessor.d.ts +16 -0
  135. package/dist/shims/internal/cache-context-accessor.js +15 -0
  136. package/dist/shims/internal/headers-state.d.ts +74 -0
  137. package/dist/shims/internal/headers-state.js +157 -0
  138. package/dist/shims/navigation.js +2 -2
  139. package/dist/shims/request-state-types.d.ts +2 -1
  140. package/dist/shims/root-params.js +1 -1
  141. package/dist/shims/server.js +52 -2
  142. package/dist/shims/unified-request-context.d.ts +1 -1
  143. package/dist/utils/encode-cache-tag.d.ts +1 -0
  144. package/dist/utils/encode-cache-tag.js +11 -1
  145. package/dist/utils/vite-cli-invocation.js +8 -1
  146. package/package.json +6 -2
  147. package/dist/server/metadata-route-cache-policy.d.ts +0 -5
  148. package/dist/server/metadata-route-cache-policy.js +0 -6
package/dist/index.js CHANGED
@@ -11,7 +11,8 @@ import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from "./shims/consta
11
11
  import { VINEXT_MW_CTX_HEADER } from "./utils/protocol-headers.js";
12
12
  import { encodeMiddlewareRequestHeaders } from "./utils/middleware-request-headers.js";
13
13
  import { matchesRewriteSource, proxyExternalRequest } from "./config/config-matchers.js";
14
- import { resolveAssetsDir } from "./utils/asset-prefix.js";
14
+ import { omitUnusedBuildSourcemap } from "./plugins/transform-result.js";
15
+ import { assetPrefixPathname, isNextStaticPath, resolveAssetsDir } from "./utils/asset-prefix.js";
15
16
  import { RESOLVED_VIRTUAL_GOOGLE_FONTS, VIRTUAL_GOOGLE_FONTS, createGoogleFontsPlugin, createLocalFontsPlugin, generateGoogleFontsVirtualModule, parseStaticObjectLiteral } from "./plugins/fonts.js";
16
17
  import { VINEXT_NEXT_CONFIG_PLUGIN_PROPERTY, createRscCompatibilityId, findNextConfigPath, loadNextConfig, resolveNextConfig, resolveNextConfigInput } from "./config/next-config.js";
17
18
  import { normalizePathnameForRouteMatchStrict } from "./routing/utils.js";
@@ -23,7 +24,7 @@ import { resolveRuntimeEntryModule } from "./entries/runtime-entry-module.js";
23
24
  import { INTERNAL_HEADERS, NEXTJS_DEPLOYMENT_ID_HEADER, VINEXT_INTERNAL_HEADERS, VINEXT_TIMING_HEADER } from "./server/headers.js";
24
25
  import { normalizePath as normalizePath$1 } from "./server/normalize-path.js";
25
26
  import { validateMiddlewareMatcherPatterns } from "./server/middleware-matcher-pattern.js";
26
- import { methodNotAllowedResponse } from "./server/http-error-responses.js";
27
+ import { methodNotAllowedResponse, notFoundStaticAssetResponse } from "./server/http-error-responses.js";
27
28
  import { isOpenRedirectShaped } from "./server/open-redirect.js";
28
29
  import { canonicalizeRequestUrlPathname, filterInternalHeaders, normalizeTrailingSlash } from "./server/request-pipeline.js";
29
30
  import { resolvePagesI18nRequest, stripI18nLocaleForApiRoute } from "./server/pages-i18n.js";
@@ -78,6 +79,7 @@ import { dataUrlCssPlugin } from "./plugins/css-data-url.js";
78
79
  import { createCssModuleImportCompatibilityPlugin } from "./plugins/css-module-imports.js";
79
80
  import { createRscClientReferenceLoadersPlugin } from "./plugins/rsc-client-reference-loaders.js";
80
81
  import { createRscReferenceValidationNormalizerPlugin } from "./plugins/rsc-reference-validation-normalizer.js";
82
+ import { createScanBuildCssPlugin } from "./plugins/scan-build-css.js";
81
83
  import { createInstrumentationClientTransformPlugin, createInstrumentationServerTransformPlugin } from "./plugins/instrumentation-client.js";
82
84
  import { createStyledJsxPlugin } from "./plugins/styled-jsx.js";
83
85
  import { INSTRUMENTATION_CLIENT_EMPTY_MODULE, generateInstrumentationClientInjectModule } from "./client/instrumentation-client-inject.js";
@@ -88,6 +90,7 @@ import { validateMiddlewareModuleExports } from "./plugins/middleware-export-val
88
90
  import { createOptimizeImportsPlugin } from "./plugins/optimize-imports.js";
89
91
  import { augmentSsrManifestFromBundle, relativeWithinRoot, tryRealpathSync } from "./build/ssr-manifest.js";
90
92
  import { createDynamicPreloadMetadataPlugin } from "./plugins/dynamic-preload-metadata.js";
93
+ import { createTransformCache } from "./plugins/transform-cache.js";
91
94
  import { createOgHarfbuzzPlugin } from "./plugins/og-harfbuzz.js";
92
95
  import { createOgAssetsPlugin, createOgInlineFetchAssetsPlugin } from "./plugins/og-assets.js";
93
96
  import { createUseCacheCallablePlugin } from "./plugins/use-cache-callable.js";
@@ -102,16 +105,16 @@ import { createModuleDependencyCache } from "./build/module-dependency-cache.js"
102
105
  import { markCssUrlAssetReferences, restoreDedupedCssAssetReferences } from "./build/css-url-assets.js";
103
106
  import { buildSassPreprocessorOptions, createSassAwareFileSystemLoader, createSassCssUrlAssetImporter, createSassTildeImporter, createSassTsconfigPathImporters } from "./plugins/sass.js";
104
107
  import { createClientAssetFileNames, createClientCodeSplittingConfig, createClientFileNameConfig, createClientManualChunks, createMultiStageChunkFileNames, createMultiStageCodeSplittingConfig, createRscFrameworkChunkOutputConfig, getBuildBundlerOptions, getClientTreeshakeConfig, withBuildBundlerOptions } from "./build/client-build-config.js";
105
- import { hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
108
+ import { EXPORT_ALL_CANDIDATE_FILTER, hasExportAllCandidate, stripServerExports, validatePageExports } from "./plugins/strip-server-exports.js";
106
109
  import { removeConsoleCalls } from "./plugins/remove-console.js";
107
110
  import { createImportMetaUrlPlugin } from "./plugins/import-meta-url.js";
108
111
  import { createWorkerImageImportsPlugin } from "./plugins/worker-image-imports.js";
109
112
  import { createRequireContextPlugin } from "./plugins/require-context.js";
113
+ import { COMMONJS_SYNTAX_CODE_FILTER } from "./plugins/commonjs-syntax.js";
110
114
  import { createRequireConditionResolutionPlugin, isConditionalRequireScriptModuleId } from "./plugins/require-condition-resolution.js";
111
- import { createTransformCache } from "./plugins/transform-cache.js";
112
115
  import { createExtensionlessDynamicImportPlugin } from "./plugins/extensionless-dynamic-import.js";
113
116
  import { createWasmModuleImportPlugin } from "./plugins/wasm-module-import.js";
114
- import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
117
+ import { consumerEnvironmentConditionFilter, getTypeofWindowReplacement, mayFoldChangeScannedImports, replaceConsumerEnvironmentConditions } from "./plugins/typeof-window.js";
115
118
  import { hasMdxFiles } from "./utils/mdx-scan.js";
116
119
  import { publicFilePathVariants } from "./utils/public-file-path.js";
117
120
  import { scanPublicFileRoutes } from "./utils/public-routes.js";
@@ -133,17 +136,23 @@ const PAGES_CLOUDFLARE_WORKER_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
133
136
  "react-dom",
134
137
  "react-dom/server.edge",
135
138
  "react/jsx-runtime",
136
- "react/jsx-dev-runtime",
137
- "use-sync-external-store/with-selector"
139
+ "react/jsx-dev-runtime"
140
+ ]);
141
+ const APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE = Object.freeze([
142
+ "use-sync-external-store/shim",
143
+ "use-sync-external-store/shim/index.js",
144
+ "use-sync-external-store/shim/with-selector",
145
+ "use-sync-external-store/shim/with-selector.js",
146
+ "use-sync-external-store/with-selector",
147
+ "use-sync-external-store/with-selector.js"
138
148
  ]);
139
- const OPTIONAL_OPTIMIZE_DEPS_WARNING_RE = /Failed to resolve dependency: .*use-sync-external-store\/with-selector.*present in .* 'optimizeDeps\.include'/;
140
- const VINEXT_FILTERED_OPTIMIZE_DEPS_WARN = Symbol.for("vinext.filteredOptimizeDepsWarn");
141
149
  const ANSI_ESCAPE_RE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
142
150
  const RSC_ENVIRONMENTS = /* @__PURE__ */ new Set([
143
151
  "rsc",
144
152
  "ssr",
145
153
  "client"
146
154
  ]);
155
+ const VINEXT_GENERATED_DIR_RE = /(?:^|[/\\])\.vinext(?:[/\\]|$)/;
147
156
  function scopeRscPlugin(plugin) {
148
157
  const applyToEnvironment = plugin.applyToEnvironment;
149
158
  return {
@@ -544,15 +553,24 @@ function mergeStringArrayValues(value, additions) {
544
553
  function stripAnsi(value) {
545
554
  return value.replace(ANSI_ESCAPE_RE, "");
546
555
  }
547
- function suppressOptionalOptimizeDepsWarnings(logger) {
548
- const marker = logger;
549
- if (marker[VINEXT_FILTERED_OPTIMIZE_DEPS_WARN]) return;
550
- const warn = logger.warn.bind(logger);
551
- logger.warn = (msg, options) => {
552
- if (OPTIONAL_OPTIMIZE_DEPS_WARNING_RE.test(stripAnsi(msg))) return;
553
- warn(msg, options);
556
+ function createOptionalOptimizeDepsLogger(logger, warnings) {
557
+ if (warnings.size === 0) return logger;
558
+ return {
559
+ get hasWarned() {
560
+ return logger.hasWarned;
561
+ },
562
+ set hasWarned(value) {
563
+ logger.hasWarned = value;
564
+ },
565
+ info: logger.info.bind(logger),
566
+ warn(msg, options) {
567
+ if (!warnings.has(stripAnsi(msg))) logger.warn(msg, options);
568
+ },
569
+ warnOnce: logger.warnOnce.bind(logger),
570
+ error: logger.error.bind(logger),
571
+ clearScreen: logger.clearScreen.bind(logger),
572
+ hasErrorLogged: logger.hasErrorLogged.bind(logger)
554
573
  };
555
- marker[VINEXT_FILTERED_OPTIMIZE_DEPS_WARN] = true;
556
574
  }
557
575
  const _tsconfigAliasCache = /* @__PURE__ */ new Map();
558
576
  /**
@@ -847,6 +865,7 @@ function vinext(options = {}) {
847
865
  let nitroBuildDir;
848
866
  let fileMatcher;
849
867
  let middlewarePath = null;
868
+ let canonicalMiddlewarePath = null;
850
869
  let instrumentationPath = null;
851
870
  let instrumentationClientPath = null;
852
871
  let clientInjectModule = null;
@@ -1115,33 +1134,44 @@ function vinext(options = {}) {
1115
1134
  }
1116
1135
  };
1117
1136
  const cachedConsumerConditionTransform = createTransformCache();
1137
+ const cachedJsxInJsTransform = createTransformCache();
1118
1138
  let transformProjectLocalCommonJs = false;
1119
1139
  let transformBundledCommonJsDependencies = false;
1120
1140
  const commonJsPlugin = commonjs({ filter(id) {
1141
+ if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return false;
1121
1142
  return commonjsTransformFilter(id, transformProjectLocalCommonJs, transformBundledCommonJsDependencies, importMetaUrlCapability.isBundledCommonJsDependencyId);
1122
1143
  } });
1123
1144
  const commonJsTransform = commonJsPlugin.transform;
1124
- if (typeof commonJsTransform === "function") commonJsPlugin.transform = function environmentAwareCommonJsTransform(code, id, ...args) {
1125
- const normalizedId = toSlash(stripViteModuleQuery(id));
1126
- const nitroServicePath = this.environment.name === "nitro" && nitroBuildDir && normalizedId.endsWith("/entry.js") ? path.relative(path.join(canonicalize(nitroBuildDir), "vite/services"), normalizedId) : "";
1127
- if (/^[^/]+\/entry\.js$/.test(nitroServicePath)) return null;
1128
- if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return null;
1129
- if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
1130
- const isDev = this.environment.mode === "dev";
1131
- const isServer = this.environment.config.consumer === "server";
1132
- const bundledDependency = isDev && isServer && (code.includes("__filename") || code.includes("__dirname")) && importMetaUrlCapability.isBundledCommonJsDependencyId(id);
1133
- const projectLocal = !bundledDependency && !id.includes("/node_modules/") && !id.includes("\\node_modules\\");
1134
- const previousProjectLocal = transformProjectLocalCommonJs;
1135
- const previous = transformBundledCommonJsDependencies;
1136
- transformProjectLocalCommonJs = projectLocal && isDev;
1137
- transformBundledCommonJsDependencies = bundledDependency;
1138
- try {
1139
- return commonJsTransform.call(this, code, id, ...args);
1140
- } finally {
1141
- transformProjectLocalCommonJs = previousProjectLocal;
1142
- transformBundledCommonJsDependencies = previous;
1143
- }
1144
- };
1145
+ if (typeof commonJsTransform === "function") {
1146
+ const environmentAwareCommonJsTransform = function(code, id, ...args) {
1147
+ const normalizedId = toSlash(stripViteModuleQuery(id));
1148
+ const nitroServicePath = this.environment.name === "nitro" && nitroBuildDir && normalizedId.endsWith("/entry.js") ? path.relative(path.join(canonicalize(nitroBuildDir), "vite/services"), normalizedId) : "";
1149
+ if (/^[^/]+\/entry\.js$/.test(nitroServicePath)) return null;
1150
+ if (isPathInside(__dirname, toSlash(stripViteModuleQuery(id)))) return null;
1151
+ if (this.environment.mode === "dev" && this.environment.depsOptimizer?.isOptimizedDepFile(id)) return null;
1152
+ const isDev = this.environment.mode === "dev";
1153
+ const isServer = this.environment.config.consumer === "server";
1154
+ const bundledDependency = isDev && isServer && (code.includes("__filename") || code.includes("__dirname")) && importMetaUrlCapability.isBundledCommonJsDependencyId(id);
1155
+ const projectLocal = !bundledDependency && !id.includes("/node_modules/") && !id.includes("\\node_modules\\");
1156
+ const userCondition = commonjsTransformFilter(id, projectLocal && isDev, bundledDependency, importMetaUrlCapability.isBundledCommonJsDependencyId);
1157
+ if (userCondition === false) return null;
1158
+ if (userCondition !== true && id.includes("node_modules")) return null;
1159
+ const previousProjectLocal = transformProjectLocalCommonJs;
1160
+ const previous = transformBundledCommonJsDependencies;
1161
+ transformProjectLocalCommonJs = projectLocal && isDev;
1162
+ transformBundledCommonJsDependencies = bundledDependency;
1163
+ try {
1164
+ return commonJsTransform.call(this, code, id, ...args);
1165
+ } finally {
1166
+ transformProjectLocalCommonJs = previousProjectLocal;
1167
+ transformBundledCommonJsDependencies = previous;
1168
+ }
1169
+ };
1170
+ commonJsPlugin.transform = {
1171
+ filter: { code: { include: COMMONJS_SYNTAX_CODE_FILTER } },
1172
+ handler: environmentAwareCommonJsTransform
1173
+ };
1174
+ }
1145
1175
  const buildLifecyclePlugins = createBuildLifecyclePlugins({
1146
1176
  isEnabled: (builder) => buildLifecycleEnabled && builder.config.build.write !== false && !builder.config.build.lib && (buildLifecycleInvocation !== void 0 || !builder.config.build.watch && !builder.config.build.ssr && getBuildBundlerOptions(builder.config.build)?.input === void 0),
1147
1177
  onComplete: () => buildLifecycleInvocation?.onComplete?.(),
@@ -1229,15 +1259,17 @@ function vinext(options = {}) {
1229
1259
  if (!code.includes("use client") && !code.includes("use server")) return;
1230
1260
  if (!hasReactDirective(code)) return;
1231
1261
  }
1232
- const result = await transformWithOxc(code, id, {
1233
- lang: "jsx",
1234
- jsx: { runtime: "automatic" },
1235
- sourcemap: true
1262
+ return cachedJsxInJsTransform(id, code, void 0, async () => {
1263
+ const result = await transformWithOxc(code, id, {
1264
+ lang: "jsx",
1265
+ jsx: { runtime: "automatic" },
1266
+ sourcemap: true
1267
+ });
1268
+ return {
1269
+ code: result.code,
1270
+ map: result.map
1271
+ };
1236
1272
  });
1237
- return {
1238
- code: result.code,
1239
- map: result.map
1240
- };
1241
1273
  }
1242
1274
  }
1243
1275
  },
@@ -1366,6 +1398,8 @@ function vinext(options = {}) {
1366
1398
  instrumentationClientPath = findInstrumentationClientFile(root, fileMatcher);
1367
1399
  const middlewareConventionDir = canonicalize(baseDir) === canonicalize(path.join(root, "src")) ? path.join(root, "src") : root;
1368
1400
  middlewarePath = findMiddlewareFile(root, fileMatcher, middlewareConventionDir);
1401
+ pageTransformCanonicalPaths.clear();
1402
+ canonicalMiddlewarePath = middlewarePath ? canonicalize(middlewarePath) : null;
1369
1403
  if (middlewarePath) {
1370
1404
  const staticMatcher = extractMiddlewareMatcherConfigValue(middlewarePath);
1371
1405
  if (staticMatcher !== void 0) validateMiddlewareMatcherPatterns(staticMatcher);
@@ -1522,6 +1556,7 @@ function vinext(options = {}) {
1522
1556
  const viteConfig = {
1523
1557
  appType: "custom",
1524
1558
  ...devCliLifecycleEnabled ? { [VINEXT_DEV_CLI_LIFECYCLE]: true } : {},
1559
+ ...hasAppDir && hasNitroPlugin ? { rsc: { serverHandler: false } } : {},
1525
1560
  ...!hasAppDir && hasCloudflarePlugin ? { builder: {
1526
1561
  ...config.builder,
1527
1562
  sharedConfigBuild: true
@@ -1553,6 +1588,10 @@ function vinext(options = {}) {
1553
1588
  },
1554
1589
  worker: { plugins: () => [createWorkerImageImportsPlugin({ deploymentId: nextConfig.deploymentId })] },
1555
1590
  server: {
1591
+ watch: config.server?.watch === null ? null : {
1592
+ ignored: [VINEXT_GENERATED_DIR_RE],
1593
+ exclude: [VINEXT_GENERATED_DIR_RE]
1594
+ },
1556
1595
  cors: {
1557
1596
  preflightContinue: true,
1558
1597
  origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/
@@ -1714,8 +1753,10 @@ function vinext(options = {}) {
1714
1753
  }
1715
1754
  const appClientInput = { index: VIRTUAL_APP_BROWSER_ENTRY };
1716
1755
  if (hasPagesDir) appClientInput["vinext-client-entry"] = VIRTUAL_CLIENT_ENTRY;
1756
+ const nitroDevEnvironmentResolve = hasNitroPlugin && env?.command === "serve" ? { resolve: { noExternal: ["next"] } } : {};
1717
1757
  viteConfig.environments = {
1718
1758
  rsc: {
1759
+ ...nitroDevEnvironmentResolve,
1719
1760
  ...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
1720
1761
  external: userSsrExternal === true ? true : [
1721
1762
  "satori",
@@ -1745,6 +1786,7 @@ function vinext(options = {}) {
1745
1786
  }
1746
1787
  },
1747
1788
  ssr: {
1789
+ ...nitroDevEnvironmentResolve,
1748
1790
  ...hasCloudflarePlugin || hasNitroPlugin ? {} : { resolve: {
1749
1791
  external: userSsrExternal === true ? true : [
1750
1792
  ...userSsrExternal,
@@ -1895,7 +1937,19 @@ function vinext(options = {}) {
1895
1937
  if (!config.server.middlewareMode) applyDevServerDefaults(config.server, {});
1896
1938
  }
1897
1939
  }
1898
- if (isServeCommand && hasCloudflarePlugin && hasPagesDir && !hasAppDir) suppressOptionalOptimizeDepsWarnings(config.logger);
1940
+ if (isServeCommand && (hasAppDir || hasCloudflarePlugin && hasPagesDir)) {
1941
+ const optionalWarnings = /* @__PURE__ */ new Set();
1942
+ for (const [name, environment] of Object.entries(config.environments)) {
1943
+ const optimizer = environment.optimizeDeps;
1944
+ const optionalIncludes = hasAppDir ? name === "client" && !optimizer.noDiscovery ? APP_CLIENT_OPTIONAL_OPTIMIZE_DEPS_INCLUDE : [] : name !== "client" ? ["use-sync-external-store/with-selector"] : [];
1945
+ for (const id of optionalIncludes) {
1946
+ if (optimizer.include?.includes(id) || optimizer.exclude?.some((excluded) => id === excluded || id.startsWith(`${excluded}/`))) continue;
1947
+ (optimizer.include ??= []).push(id);
1948
+ optionalWarnings.add(`Failed to resolve dependency: ${id}, present in ${name} 'optimizeDeps.include'`);
1949
+ }
1950
+ }
1951
+ Object.assign(config, { logger: createOptionalOptimizeDepsLogger(config.logger, optionalWarnings) });
1952
+ }
1899
1953
  if (config.worker?.rolldownOptions) {
1900
1954
  const workerFileNames = `${resolveAssetsDir(nextConfig.assetPrefix ?? "")}/workers/[name]-[hash].js`;
1901
1955
  const workerOutputs = config.worker.rolldownOptions.output;
@@ -2530,6 +2584,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
2530
2584
  const devBuildId = nextConfig?.buildId ?? process.env.__VINEXT_BUILD_ID ?? "development";
2531
2585
  server.middlewares.use((req, _res, next) => {
2532
2586
  req.__vinextOriginalEncodedUrl ??= req.url;
2587
+ delete req.headers[VINEXT_MW_CTX_HEADER];
2533
2588
  next();
2534
2589
  });
2535
2590
  server.middlewares.use((req, _res, next) => {
@@ -3116,7 +3171,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3116
3171
  const apiRouteUrl = stripI18nLocaleForApiRoute(pathname, nextConfig?.i18n ?? null);
3117
3172
  filePathMatchesPagesRoute = matchRoute(pageRouteUrl, pageRoutes) !== null || matchRoute(apiRouteUrl, apiRoutes) !== null;
3118
3173
  }
3119
- if (isFilePathRequest && !isDataReq && !filePathMatchesRewrite && !filePathMatchesPagesRoute && !isExistingPublicMutation) return next();
3174
+ if (isFilePathRequest && !isDataReq && !filePathMatchesRewrite && !filePathMatchesPagesRoute && !isNextStaticPath(pathname, "", assetPrefixPathname(nextConfig?.assetPrefix ?? "")) && !isExistingPublicMutation) return next();
3120
3175
  const rawHeaders = new Headers(Object.fromEntries(Object.entries(req.headers).filter(([k, v]) => v !== void 0 && !k.startsWith(":")).map(([k, v]) => [k, Array.isArray(v) ? v.join(", ") : String(v)])));
3121
3176
  const isDataRequest = isDataReq;
3122
3177
  const nodeRequestHeaders = filterInternalHeaders(rawHeaders);
@@ -3161,6 +3216,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3161
3216
  const getDevAppRoutes = () => devAppRoutesPromise ??= hasAppDir && appDir ? appRouter(appDir, nextConfig?.pageExtensions, fileMatcher) : Promise.resolve([]);
3162
3217
  const classifyDevPageRoute = (route) => classifyDevPageFile(route.filePath);
3163
3218
  const pipelineDeps = {
3219
+ assetPrefix: nextConfig?.assetPrefix,
3164
3220
  basePath: bp,
3165
3221
  trailingSlash: nextConfig?.trailingSlash ?? false,
3166
3222
  i18nConfig: nextConfig?.i18n ?? null,
@@ -3294,6 +3350,12 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3294
3350
  const appMatch = matchAppRoute(resolvedPathname, appRoutes);
3295
3351
  if (appMatch && !pagesRouteHasPriorityOverAppRoute(renderMatch.route, appMatch.route)) return next();
3296
3352
  }
3353
+ if (!renderMatch && isNextStaticPath(resolvedPathname, "", assetPrefixPathname(nextConfig?.assetPrefix ?? ""))) {
3354
+ const headers = new Headers();
3355
+ forEachStagedHeader((key, value) => headers.append(key, value));
3356
+ await writeWebResponseToNodeRes(res, notFoundStaticAssetResponse(headers));
3357
+ return;
3358
+ }
3297
3359
  if (!cachedSSRHandler || cachedSSRHandler.routes !== routes) cachedSSRHandler = {
3298
3360
  routes,
3299
3361
  handler: createSSRHandler(server, getPagesRunner(), routes, pagesDir, nextConfig?.i18n, fileMatcher, nextConfig?.basePath ?? "", nextConfig?.trailingSlash ?? false, middlewarePath !== null, (nextConfig?.rewrites.beforeFiles.length ?? 0) > 0 || (nextConfig?.rewrites.afterFiles.length ?? 0) > 0 || (nextConfig?.rewrites.fallback.length ?? 0) > 0, nextConfig?.clientTraceMetadata, nextConfig?.htmlLimitedBots, nextConfig?.reactStrictMode === true, nextConfig?.expireTime, nextConfig?.crossOrigin, devBuildId, middlewarePath ? compileClientMiddlewareMatchers(extractMiddlewareMatcherConfig(middlewarePath)) : void 0, classifyDevPageRoute)
@@ -3360,12 +3422,15 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3360
3422
  {
3361
3423
  name: "vinext:validate-middleware-exports",
3362
3424
  enforce: "pre",
3363
- transform(code, id) {
3364
- if (!middlewarePath) return null;
3365
- const modulePath = stripViteModuleQuery(id);
3366
- if (canonicalize(modulePath) !== canonicalize(middlewarePath)) return null;
3367
- validateMiddlewareModuleExports(code, modulePath, middlewarePath, isProxyFile(middlewarePath));
3368
- return null;
3425
+ transform: {
3426
+ filter: { id: { exclude: VIRTUAL_MODULE_ID_RE } },
3427
+ handler(code, id) {
3428
+ if (!middlewarePath) return null;
3429
+ const modulePath = stripViteModuleQuery(id);
3430
+ if (canonicalizePageTransformPath(modulePath) !== canonicalMiddlewarePath) return null;
3431
+ validateMiddlewareModuleExports(code, modulePath, middlewarePath, isProxyFile(middlewarePath));
3432
+ return null;
3433
+ }
3369
3434
  }
3370
3435
  },
3371
3436
  {
@@ -3373,7 +3438,7 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3373
3438
  transform: {
3374
3439
  filter: {
3375
3440
  id: { exclude: VIRTUAL_MODULE_ID_RE },
3376
- code: /\bexport\b[\s\S]*\*/
3441
+ code: EXPORT_ALL_CANDIDATE_FILTER
3377
3442
  },
3378
3443
  handler(code, id) {
3379
3444
  if (this.environment?.name !== "client") return null;
@@ -3470,6 +3535,8 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3470
3535
  filter: { code: consumerEnvironmentConditionFilter },
3471
3536
  handler(code, id) {
3472
3537
  const scansImports = this.environment.config.build.write === false;
3538
+ const skipsUnobservableFold = scansImports && useNativeTypeofWindowFolding && this.environment.config.isBundled;
3539
+ if (skipsUnobservableFold && !mayFoldChangeScannedImports(code)) return null;
3473
3540
  const replaceTypeofWindow = !useNativeTypeofWindowFolding || scansImports;
3474
3541
  const replaceProcessBrowser = scansImports;
3475
3542
  if (!replaceTypeofWindow && !replaceProcessBrowser) return null;
@@ -3477,12 +3544,13 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
3477
3544
  if (toSlash(id).startsWith(cacheDir)) return null;
3478
3545
  const typeofWindow = getTypeofWindowReplacement(this.environment);
3479
3546
  const processBrowser = this.environment.config.consumer === "client";
3480
- const variant = `${replaceTypeofWindow ? typeofWindow : "-"}:${replaceProcessBrowser ? processBrowser : "-"}`;
3481
- return cachedConsumerConditionTransform(id, code, variant, () => replaceConsumerEnvironmentConditions(code, {
3547
+ const variant = `${replaceTypeofWindow ? typeofWindow : "-"}:${replaceProcessBrowser ? processBrowser : "-"}:${skipsUnobservableFold ? "gated" : "full"}`;
3548
+ return omitUnusedBuildSourcemap(this.environment, cachedConsumerConditionTransform(id, code, variant, () => replaceConsumerEnvironmentConditions(code, {
3482
3549
  ...replaceTypeofWindow ? { typeofWindow } : {},
3483
3550
  ...replaceProcessBrowser ? { processBrowser } : {},
3484
- pruneUnreachableImports: scansImports
3485
- }, id));
3551
+ pruneUnreachableImports: scansImports,
3552
+ onlyIfScannedImportsChange: skipsUnobservableFold
3553
+ }, id)));
3486
3554
  }
3487
3555
  }
3488
3556
  },
@@ -4038,18 +4106,21 @@ export const loadServerActionClient = ${hasServerActions ? `() => import(${JSON.
4038
4106
  }
4039
4107
  });
4040
4108
  if (rscPluginPromise) plugins.push(rscPluginPromise);
4041
- if (earlyAppDirExists) plugins.push(createActionOwnerManifestPlugin({
4042
- canonicalizeModuleId: canonicalize,
4043
- async getManager(config) {
4044
- return (await rscPluginModulePromise)?.getPluginApi(config)?.manager;
4045
- },
4046
- getRoutes: () => rscActionOwnerRoutes ?? [],
4047
- getSharedRoots: () => rscActionOwnerSharedRoots,
4048
- onComplete() {
4049
- rscActionOwnerRoutes = null;
4050
- rscActionOwnerSharedRoots = [];
4051
- }
4052
- }));
4109
+ if (earlyAppDirExists) {
4110
+ plugins.push(createActionOwnerManifestPlugin({
4111
+ canonicalizeModuleId: canonicalize,
4112
+ async getManager(config) {
4113
+ return (await rscPluginModulePromise)?.getPluginApi(config)?.manager;
4114
+ },
4115
+ getRoutes: () => rscActionOwnerRoutes ?? [],
4116
+ getSharedRoots: () => rscActionOwnerSharedRoots,
4117
+ onComplete() {
4118
+ rscActionOwnerRoutes = null;
4119
+ rscActionOwnerSharedRoots = [];
4120
+ }
4121
+ }));
4122
+ plugins.push(createScanBuildCssPlugin());
4123
+ }
4053
4124
  if (rscPluginPromise) {
4054
4125
  plugins.push(createRscReferenceValidationNormalizerPlugin());
4055
4126
  plugins.push(createRscClientReferenceLoadersPlugin());
@@ -37,7 +37,7 @@ export declare function cssModulesConfigSource(indent?: string): string;
37
37
  /** Generate vite.config.ts for App Router */
38
38
  export declare function generateAppRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, assetsBinding?: string, assetsDirectory?: string, hasCssModules?: boolean): string;
39
39
  /** Generate vite.config.ts for Pages Router */
40
- export declare function generatePagesRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, hasCssModules?: boolean): string;
40
+ export declare function generatePagesRouterViteConfig(info?: CloudflareProjectInfo, options?: CloudflareInitOptions, imagesBinding?: string, versionMetadataBinding?: string, serviceBinding?: boolean, hasCssModules?: boolean, assetsBinding?: string, assetsDirectory?: string): string;
41
41
  export declare function updateViteConfigForCssModules(filePath: string, code: string): {
42
42
  code: string;
43
43
  preservedExistingGenerateScopedName: boolean;
@@ -26,7 +26,6 @@ const CACHE_METADATA_EXPORT = {
26
26
  };
27
27
  const CTX_EXPORTS_DEFAULT_DATE = "2025-11-17";
28
28
  function validateCloudflarePlatformSetup(context, cloudflare) {
29
- if (cloudflare.cdnCache === "static-assets" && !context.isAppRouter) throw new Error("The Static Assets cache currently requires an App Router project.");
30
29
  if (!cloudflare.legacyWrangler) {
31
30
  const existingWrangler = [
32
31
  "wrangler.toml",
@@ -107,7 +106,7 @@ function setupCloudflarePlatform(context, cloudflare) {
107
106
  generatedViteConfig = true;
108
107
  } else skippedViteConfig = true;
109
108
  } else {
110
- const configContent = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, assetsBinding, assetsDirectory, context.hasCssModules) : generatePagesRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, context.hasCssModules);
109
+ const configContent = context.isAppRouter ? generateAppRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, assetsBinding, assetsDirectory, context.hasCssModules) : generatePagesRouterViteConfig(projectInfo, cloudflare, imagesBinding, versionMetadataBinding, false, context.hasCssModules, assetsBinding, assetsDirectory);
111
110
  fs.writeFileSync(path.join(context.root, "vite.config.ts"), configContent, "utf-8");
112
111
  generatedViteConfig = true;
113
112
  }
@@ -799,7 +798,8 @@ ${plugins.join("\n")}
799
798
  `;
800
799
  }
801
800
  /** Generate vite.config.ts for Pages Router */
802
- function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING, serviceBinding = false, hasCssModules = false) {
801
+ function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_OPTIONS, imagesBinding = "IMAGES", versionMetadataBinding = DEFAULT_VERSION_METADATA_BINDING, serviceBinding = false, hasCssModules = false, assetsBinding = "ASSETS", assetsDirectory = "dist/client") {
802
+ const legacyStaticAssets = options.legacyWrangler && options.cdnCache === "static-assets";
803
803
  const imports = [
804
804
  `import { defineConfig } from "vite";`,
805
805
  `import vinext from "vinext";`,
@@ -816,9 +816,9 @@ function generatePagesRouterViteConfig(info, options = DEFAULT_CLOUDFLARE_INIT_O
816
816
  return `${imports.join("\n")}
817
817
 
818
818
  export default defineConfig({
819
- plugins: [
820
- ${hasCssModules ? " patchCssModules({ exportMode: \"default\" }),\n" : ""} ${vinextExpression(options, "vinext", "imagesOptimizer", imagesBinding, versionMetadataBinding).replace(/\n/g, "\n ")},
821
- cloudflare(${serviceBinding ? "{ auxiliaryWorkers: [{ config: responseStoreServiceBinding }] }" : ""}),
819
+ ${legacyStaticAssets ? ` environments: { client: { build: { outDir: ${JSON.stringify(assetsDirectory)} } }, ssr: { build: { outDir: "dist/server" } } },\n` : ""} plugins: [
820
+ ${hasCssModules ? " patchCssModules({ exportMode: \"default\" }),\n" : ""} ${vinextExpression(options, "vinext", "imagesOptimizer", imagesBinding, versionMetadataBinding, "responseStoreAdapter", assetsBinding, assetsDirectory).replace(/\n/g, "\n ")},
821
+ cloudflare(${legacyStaticAssets ? "{ viteEnvironment: { name: \"ssr\" } }" : serviceBinding ? "{ auxiliaryWorkers: [{ config: responseStoreServiceBinding }] }" : ""}),
822
822
  ],${resolveBlock}${hasCssModules ? cssModulesConfigSource() : ""}
823
823
  });
824
824
  `;
@@ -269,7 +269,7 @@ async function resolveCloudflareInitOptions(args, options = {}) {
269
269
  }
270
270
  output.write(" Please answer yes or no.\n");
271
271
  }
272
- const cdnCache = await promptChoice(selectedCdnCache, " Choose a CDN cache:\n 1. Workers Response Store (default)\n 2. Workers Cache\n 3. Data cache\n 4. Static Assets (read-only; App Router only)\n CDN cache [1]: ", {
272
+ const cdnCache = await promptChoice(selectedCdnCache, " Choose a CDN cache:\n 1. Workers Response Store (default)\n 2. Workers Cache\n 3. Data cache\n 4. Static Assets (read-only)\n CDN cache [1]: ", {
273
273
  "1": "response-store",
274
274
  "response-store": "response-store",
275
275
  "2": "workers-cache",
package/dist/init.js CHANGED
@@ -412,8 +412,9 @@ async function init(options) {
412
412
  existingViteConfigPath = renamedPath;
413
413
  }
414
414
  const addedTypeModule = ensureESModule(root);
415
+ const deployResponseStore = platform === "cloudflare" && options.cloudflare?.cdnCache === "response-store" && (options.cloudflare.responseStoreMode ?? "service-binding") === "service-binding";
415
416
  const addedScripts = addScripts(root, options.port, platform, {
416
- deployResponseStore: options.cloudflare?.cdnCache === "response-store" && (options.cloudflare.responseStoreMode ?? "service-binding") === "service-binding",
417
+ deployResponseStore,
417
418
  warmCdnCache: options.cloudflare?.warmCdnCache ?? false,
418
419
  legacyWrangler: options.cloudflare?.legacyWrangler,
419
420
  scriptNames: options.scriptNames
@@ -516,6 +517,7 @@ async function init(options) {
516
517
  const nextSteps = [...platformSetup.nextSteps];
517
518
  if (dependencyInstallNeedsApproval) nextSteps.push("Dependency installation is incomplete because pnpm blocked dependency build scripts:", "1. Review and approve the required build scripts:", " pnpm approve-builds", "2. Finish installing dependencies:", " pnpm install");
518
519
  const scriptName = (name) => options.scriptNames === "standard" ? name : `${name}:vinext`;
520
+ const deployResponseStoreCommandStep = deployResponseStore ? ` ${pmName} run deploy:response-store Deploy Workers Response Store before the application\n` : "";
519
521
  const deployCommandStep = platform === "cloudflare" ? ` ${pmName} run ${scriptName("deploy")} Deploy to Cloudflare Workers\n` : "";
520
522
  const startCommandDescription = platform === "cloudflare" ? !options.cloudflare?.legacyWrangler ? "Preview the built Worker locally" : "Start the built Worker locally with Wrangler" : "Start vinext production server";
521
523
  console.log(`
@@ -524,7 +526,7 @@ ${nextSteps.map((step) => ` ${step}`).join("\n")}${nextSteps.length > 0 ? "\n
524
526
  ${pmName} run ${scriptName("dev")} Start the vinext dev server
525
527
  ${pmName} run ${scriptName("build")} Build production output
526
528
  ${pmName} run ${scriptName("start")} ${startCommandDescription}
527
- ${deployCommandStep}${options.scriptNames === "standard" ? "" : ` ${pmName} run dev Start Next.js (still works as before)\n`}
529
+ ${deployResponseStoreCommandStep}${deployCommandStep}${options.scriptNames === "standard" ? "" : ` ${pmName} run dev Start Next.js (still works as before)\n`}
528
530
  `);
529
531
  return {
530
532
  installedDeps: [.../* @__PURE__ */ new Set([...dependencyEntriesAdded, ...devDependencyEntriesAdded])],
@@ -0,0 +1,16 @@
1
+ //#region src/plugins/commonjs-syntax.d.ts
2
+ /**
3
+ * Conservative source-level superset of what vite-plugin-commonjs rewrites,
4
+ * as a transform `filter.code.include` list (a module matches when any
5
+ * pattern does; strings match as substrings).
6
+ *
7
+ * Its analyzer only acts on calls whose callee is the identifier `require` and
8
+ * on assignments to a member of the identifiers `module` / `exports`, and the
9
+ * transform returns nothing when neither is present. Text inside strings or
10
+ * comments can produce false positives (the module is then analyzed as
11
+ * before), and identifiers written with unicode escapes are never ruled out.
12
+ */
13
+ export declare const COMMONJS_SYNTAX_CODE_FILTER: (string | RegExp)[];
14
+ /** Whether `code` passes {@link COMMONJS_SYNTAX_CODE_FILTER}. */
15
+ export declare function mayContainCommonJsSyntax(code: string): boolean;
16
+ //#endregion
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Conservative source-level superset of what vite-plugin-commonjs rewrites,
3
+ * as a transform `filter.code.include` list (a module matches when any
4
+ * pattern does; strings match as substrings).
5
+ *
6
+ * Its analyzer only acts on calls whose callee is the identifier `require` and
7
+ * on assignments to a member of the identifiers `module` / `exports`, and the
8
+ * transform returns nothing when neither is present. Text inside strings or
9
+ * comments can produce false positives (the module is then analyzed as
10
+ * before), and identifiers written with unicode escapes are never ruled out.
11
+ */
12
+ const COMMONJS_SYNTAX_CODE_FILTER = [
13
+ /(?<![\w$])require(?![\w$])[\s)]*(?:\/[*/]|\(|\?\.)/,
14
+ "\\u",
15
+ /(?<![\w$]|(?<!\.)\.)(?:module|exports)(?![\w$])[\s)]*(?:\/[*/]|\??\.|\[)/
16
+ ];
17
+ /** Whether `code` passes {@link COMMONJS_SYNTAX_CODE_FILTER}. */
18
+ function mayContainCommonJsSyntax(code) {
19
+ return COMMONJS_SYNTAX_CODE_FILTER.some((pattern) => typeof pattern === "string" ? code.includes(pattern) : pattern.test(code));
20
+ }
21
+ //#endregion
22
+ export { COMMONJS_SYNTAX_CODE_FILTER, mayContainCommonJsSyntax };
@@ -1,7 +1,18 @@
1
1
  import { MagicStringTransformResult } from "./transform-result.js";
2
2
  import { Plugin } from "vite";
3
3
  //#region src/plugins/ignore-dynamic-requests.d.ts
4
+ /**
5
+ * Cheap, conservative check run before parsing: whether any `require` or
6
+ * `import` occurrence could be a request this transform rewrites. Occurrences
7
+ * that are part of a longer identifier, member properties, static imports,
8
+ * non-callee positions (`typeof require`, `require,`), and calls with a
9
+ * single-line string literal argument other than "/" are left unchanged, so a
10
+ * module containing only those is skipped. Anything else, including escaped
11
+ * identifiers, falls through to the AST pass.
12
+ */
13
+ declare function mayContainVeryDynamicRequest(code: string): boolean;
4
14
  declare function transformVeryDynamicRequests(code: string, id: string): MagicStringTransformResult | null;
5
15
  export declare function createIgnoreDynamicRequestsPlugin(getTranspiledPackages?: () => readonly string[]): Plugin;
6
16
  export declare const _transformVeryDynamicRequests: typeof transformVeryDynamicRequests;
17
+ export declare const _mayContainVeryDynamicRequest: typeof mayContainVeryDynamicRequest;
7
18
  //#endregion