vike 0.4.236 → 0.4.237

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 (170) hide show
  1. package/dist/cjs/client/shared/createGetGlobalContextClient.js +20 -12
  2. package/dist/cjs/client/shared/getJsonSerializedInHtml.js +10 -1
  3. package/dist/cjs/client/shared/utils.js +1 -0
  4. package/dist/cjs/node/runtime/globalContext.js +118 -31
  5. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  6. package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +3 -1
  7. package/dist/cjs/node/runtime/html/serializeContext.js +25 -64
  8. package/dist/cjs/node/runtime/html/stream.js +1 -1
  9. package/dist/cjs/node/runtime/renderPage/createPageContextServerSide.js +4 -7
  10. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
  11. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +15 -12
  12. package/dist/cjs/node/runtime/renderPage/handlePageContextRequestUrl.js +50 -14
  13. package/dist/cjs/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +20 -6
  14. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -5
  15. package/dist/cjs/node/runtime/renderPage.js +9 -8
  16. package/dist/cjs/node/runtime/utils.js +4 -0
  17. package/dist/cjs/node/shared/utils.js +1 -0
  18. package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +16 -14
  19. package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +10 -4
  20. package/dist/cjs/node/vite/index.js +2 -0
  21. package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +22 -14
  22. package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +2 -2
  23. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
  24. package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -3
  25. package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +17 -5
  26. package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
  27. package/dist/cjs/node/vite/plugins/pluginCommon.js +1 -0
  28. package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +118 -72
  29. package/dist/cjs/node/vite/plugins/pluginEnvVars.js +3 -3
  30. package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -4
  31. package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +2 -2
  32. package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +51 -0
  33. package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +1 -1
  34. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +67 -0
  35. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +2 -2
  36. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.js +6 -3
  37. package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +4 -5
  38. package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +1 -0
  39. package/dist/cjs/node/vite/shared/getMagicString.js +18 -0
  40. package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +10 -0
  41. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
  42. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -3
  43. package/dist/cjs/node/vite/shared/resolveVikeConfigInternal.js +7 -18
  44. package/dist/cjs/node/vite/utils.js +1 -0
  45. package/dist/cjs/shared/createGlobalContextShared.js +27 -6
  46. package/dist/cjs/shared/getPageFiles/parseVirtualFileExports.js +6 -0
  47. package/dist/cjs/shared/getProxyForPublicUsage.js +2 -2
  48. package/dist/cjs/shared/modifyUrlSameOrigin.js +9 -4
  49. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +13 -13
  50. package/dist/cjs/shared/utils.js +2 -0
  51. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  52. package/dist/cjs/utils/assertSetup.js +7 -5
  53. package/dist/cjs/utils/cast.js +1 -1
  54. package/dist/cjs/utils/debug.js +1 -0
  55. package/dist/cjs/utils/getViteRPC.js +79 -0
  56. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -0
  57. package/dist/cjs/utils/isRunnableDevEnvironment.js +9 -0
  58. package/dist/cjs/utils/virtualFileId.js +39 -0
  59. package/dist/esm/client/node.js +1 -1
  60. package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
  61. package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +2 -2
  62. package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.js +35 -48
  63. package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
  64. package/dist/esm/client/runtime-client-routing/history.d.ts +3 -5
  65. package/dist/esm/client/runtime-client-routing/history.js +39 -22
  66. package/dist/esm/client/runtime-client-routing/initClientRouter.js +2 -3
  67. package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +1 -1
  68. package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +43 -30
  69. package/dist/esm/client/runtime-client-routing/utils.d.ts +2 -0
  70. package/dist/esm/client/runtime-client-routing/utils.js +2 -0
  71. package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
  72. package/dist/esm/client/runtime-server-routing/globalContext.d.ts +1 -1
  73. package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +1 -1
  74. package/dist/esm/client/shared/createGetGlobalContextClient.js +20 -12
  75. package/dist/esm/client/shared/getJsonSerializedInHtml.js +10 -1
  76. package/dist/esm/client/shared/utils.d.ts +1 -0
  77. package/dist/esm/client/shared/utils.js +1 -0
  78. package/dist/esm/node/prerender/runPrerender.d.ts +40 -132
  79. package/dist/esm/node/runtime/globalContext.d.ts +35 -55
  80. package/dist/esm/node/runtime/globalContext.js +119 -32
  81. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  82. package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +4 -2
  83. package/dist/esm/node/runtime/html/serializeContext.d.ts +11 -6
  84. package/dist/esm/node/runtime/html/serializeContext.js +25 -64
  85. package/dist/esm/node/runtime/html/stream.js +1 -1
  86. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +11 -34
  87. package/dist/esm/node/runtime/renderPage/createPageContextServerSide.js +4 -7
  88. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
  89. package/dist/esm/node/runtime/renderPage/getPageAssets.js +16 -13
  90. package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
  91. package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.d.ts +1 -1
  92. package/dist/esm/node/runtime/renderPage/handlePageContextRequestUrl.js +51 -15
  93. package/dist/esm/node/runtime/renderPage/loadPageConfigsLazyServerSide.js +21 -7
  94. package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
  95. package/dist/esm/node/runtime/renderPage/preparePageContextForPublicUsageServer.d.ts +0 -1
  96. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +24 -71
  97. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -5
  98. package/dist/esm/node/runtime/renderPage.d.ts +11 -33
  99. package/dist/esm/node/runtime/renderPage.js +9 -8
  100. package/dist/esm/node/runtime/utils.d.ts +4 -0
  101. package/dist/esm/node/runtime/utils.js +4 -0
  102. package/dist/esm/node/shared/utils.d.ts +1 -0
  103. package/dist/esm/node/shared/utils.js +1 -0
  104. package/dist/esm/node/shared/virtualFiles/virtualFileEntry.js +16 -14
  105. package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +11 -5
  106. package/dist/esm/node/vite/index.js +2 -0
  107. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +1 -1
  108. package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +22 -14
  109. package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +2 -2
  110. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
  111. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +0 -2
  112. package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -2
  113. package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +17 -5
  114. package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
  115. package/dist/esm/node/vite/plugins/pluginCommon.d.ts +3 -0
  116. package/dist/esm/node/vite/plugins/pluginCommon.js +1 -0
  117. package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +120 -74
  118. package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -4
  119. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +26 -0
  120. package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +49 -0
  121. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.d.ts +14 -0
  122. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getConfigValueSourcesRelevant.js +65 -0
  123. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +2 -2
  124. package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.js +6 -3
  125. package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +3 -4
  126. package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +1 -0
  127. package/dist/esm/node/vite/shared/getMagicString.d.ts +9 -0
  128. package/dist/esm/node/vite/shared/getMagicString.js +13 -0
  129. package/dist/esm/node/vite/shared/getManifestFilePathRelative.d.ts +2 -0
  130. package/dist/esm/node/vite/shared/getManifestFilePathRelative.js +8 -0
  131. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.d.ts +2 -2
  132. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/configDefinitionsBuiltIn.js +31 -3
  133. package/dist/esm/node/vite/shared/resolveVikeConfigInternal/crawlPlusFiles.js +1 -3
  134. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.d.ts +1 -3
  135. package/dist/esm/node/vite/shared/resolveVikeConfigInternal.js +8 -19
  136. package/dist/esm/node/vite/utils.d.ts +1 -0
  137. package/dist/esm/node/vite/utils.js +1 -0
  138. package/dist/esm/shared/createGlobalContextShared.d.ts +3 -3
  139. package/dist/esm/shared/createGlobalContextShared.js +28 -7
  140. package/dist/esm/shared/getPageFiles/parseVirtualFileExports.js +6 -0
  141. package/dist/esm/shared/modifyUrlSameOrigin.d.ts +1 -1
  142. package/dist/esm/shared/modifyUrlSameOrigin.js +9 -4
  143. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +3 -2
  144. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +14 -14
  145. package/dist/esm/shared/utils.d.ts +2 -0
  146. package/dist/esm/shared/utils.js +2 -0
  147. package/dist/esm/types/Config.d.ts +33 -98
  148. package/dist/esm/types/index.d.ts +3 -1
  149. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  150. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  151. package/dist/esm/utils/assertSetup.js +7 -5
  152. package/dist/esm/utils/cast.d.ts +2 -2
  153. package/dist/esm/utils/cast.js +1 -1
  154. package/dist/esm/utils/debug.d.ts +1 -1
  155. package/dist/esm/utils/debug.js +1 -0
  156. package/dist/esm/utils/getViteRPC.d.ts +6 -0
  157. package/dist/esm/utils/getViteRPC.js +77 -0
  158. package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +7 -0
  159. package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -0
  160. package/dist/esm/utils/isRunnableDevEnvironment.d.ts +3 -0
  161. package/dist/esm/utils/isRunnableDevEnvironment.js +7 -0
  162. package/dist/esm/utils/objectFilter.d.ts +1 -1
  163. package/dist/esm/utils/virtualFileId.d.ts +6 -0
  164. package/dist/esm/{node/shared/virtualFiles.js → utils/virtualFileId.js} +15 -17
  165. package/package.json +14 -5
  166. package/dist/cjs/node/shared/virtualFiles.js +0 -41
  167. package/dist/cjs/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -23
  168. package/dist/esm/node/shared/virtualFiles.d.ts +0 -8
  169. package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.d.ts +0 -7
  170. package/dist/esm/node/vite/plugins/pluginVirtualFiles/isRuntimeEnvMatch.js +0 -21
@@ -7,10 +7,10 @@ const createGlobalContextShared_js_1 = require("../../shared/createGlobalContext
7
7
  const getJsonSerializedInHtml_js_1 = require("./getJsonSerializedInHtml.js");
8
8
  const utils_js_1 = require("./utils.js");
9
9
  const globalObject = (0, utils_js_1.getGlobalObject)('createGetGlobalContextClient.ts', (() => {
10
- const { promise: globalContextPromise, resolve: globalContextPromiseResolve } = (0, utils_js_1.genPromise)();
10
+ const { promise: globalContextInitialPromise, resolve: globalContextInitialPromiseResolve } = (0, utils_js_1.genPromise)();
11
11
  return {
12
- globalContextPromise,
13
- globalContextPromiseResolve,
12
+ globalContextInitialPromise,
13
+ globalContextInitialPromiseResolve,
14
14
  };
15
15
  })());
16
16
  function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGlobalContext) {
@@ -20,19 +20,21 @@ function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGl
20
20
  getGlobalContext();
21
21
  return getGlobalContext;
22
22
  async function getGlobalContext() {
23
- // Cache
24
- if (globalObject.globalContext &&
25
- // Don't break HMR
26
- globalObject.globalContext._virtualFileExports !== virtualFileExports) {
27
- return globalObject.globalContext;
23
+ // HMR => virtualFileExports differ
24
+ if (globalObject.virtualFileExports === virtualFileExports) {
25
+ const globalContext = await globalObject.globalContextPromise;
26
+ return globalContext;
27
+ }
28
+ else {
29
+ globalObject.virtualFileExports = virtualFileExports;
28
30
  }
29
31
  // Create
30
- const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, async (globalContext) => {
32
+ const globalContextPromise = (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, undefined, async (globalContext) => {
31
33
  const globalContextAddendum = {
32
34
  /**
33
35
  * Whether the environment is client-side or server-side / pre-rendering.
34
36
  *
35
- * We recommend using `import.meta.env.SSR` instead, see https://vike.dev/globalContext
37
+ * We recommend using `({}).SSR` instead, see https://vike.dev/globalContext
36
38
  */
37
39
  isClientSide: true,
38
40
  };
@@ -40,18 +42,24 @@ function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGl
40
42
  (0, utils_js_1.objectAssign)(globalContextAddendum, await addGlobalContext?.(globalContext));
41
43
  return globalContextAddendum;
42
44
  });
43
- (0, utils_js_1.assert)(globalObject.globalContext);
44
- globalObject.globalContextPromiseResolve(globalObject.globalContext);
45
+ globalObject.globalContextPromise = globalContextPromise;
46
+ const globalContext = await globalContextPromise;
47
+ (0, utils_js_1.assert)(globalObject.globalContext === globalContext);
48
+ globalObject.globalContextInitialPromiseResolve();
45
49
  // Return
46
50
  return globalContext;
47
51
  }
48
52
  }
49
53
  async function getGlobalContext() {
54
+ await globalObject.globalContextInitialPromise;
50
55
  const globalContext = await globalObject.globalContextPromise;
56
+ (0, utils_js_1.assert)(globalContext);
57
+ (0, utils_js_1.checkType)(globalContext);
51
58
  return globalContext;
52
59
  }
53
60
  function getGlobalContextSync() {
54
61
  const { globalContext } = globalObject;
55
62
  (0, utils_js_1.assertUsage)(globalContext, createGlobalContextShared_js_1.getGlobalContextSyncErrMsg);
63
+ (0, utils_js_1.checkType)(globalContext);
56
64
  return globalContext;
57
65
  }
@@ -26,6 +26,15 @@ function findAndParseJson(id) {
26
26
  `Couldn't find #${id} (which Vike automatically injects in the HTML): make sure it exists (i.e. don't remove it and make sure your HTML isn't malformed)`);
27
27
  const jsonStr = elem.textContent;
28
28
  (0, utils_js_1.assert)(jsonStr);
29
- const json = (0, parse_1.parse)(jsonStr);
29
+ const json = (0, parse_1.parse)(jsonStr, {
30
+ // Prevent Google from crawling URLs in JSON:
31
+ // - https://github.com/vikejs/vike/pull/2603
32
+ // - https://github.com/brillout/json-serializer/blob/38edbb9945de4938da1e65d6285ce1dd123a45ef/test/main.spec.ts#L44-L95
33
+ reviver(_key, value) {
34
+ if (typeof value === 'string') {
35
+ return { replacement: value.replaceAll('\\/', '/'), resolved: false };
36
+ }
37
+ },
38
+ });
30
39
  return json;
31
40
  }
@@ -20,3 +20,4 @@ __exportStar(require("../../utils/getGlobalObject.js"), exports);
20
20
  __exportStar(require("../../utils/objectAssign.js"), exports);
21
21
  __exportStar(require("../../utils/hasProp.js"), exports);
22
22
  __exportStar(require("../../utils/genPromise.js"), exports);
23
+ __exportStar(require("../../utils/checkType.js"), exports);
@@ -21,6 +21,12 @@ exports.setGlobalContext_buildEntry = setGlobalContext_buildEntry;
21
21
  exports.clearGlobalContext = clearGlobalContext;
22
22
  exports.assertBuildInfo = assertBuildInfo;
23
23
  exports.updateUserFiles = updateUserFiles;
24
+ // TODO/now: use isProductionEnvironment() instead of globalObject.isProduction
25
+ // TODO/now: rename:
26
+ // - isProduction => isProductionEnvironment
27
+ // - setIsProduction => setIsProductionEnvironment
28
+ // - setGlobalContext_isProduction => setGlobalContext_isProductionEnvironment
29
+ // - sProductionEnvironment => sDevEnv
24
30
  // The core logic revolves around:
25
31
  // - virtualFileExports is the main requirement
26
32
  // - In production: globalObject.buildEntry which is the production entry set by @brillout/vite-plugin-server-entry
@@ -48,6 +54,7 @@ const globalObject = (0, utils_js_1.getGlobalObject)('runtime/globalContext.ts',
48
54
  const globalObjectTyped = globalObject;
49
55
  const vikeConfigErrorRecoverMsg = picocolors_1.default.bold(picocolors_1.default.green('Vike config loaded'));
50
56
  exports.vikeConfigErrorRecoverMsg = vikeConfigErrorRecoverMsg;
57
+ (0, utils_js_1.assertIsNotBrowser)();
51
58
  async function getGlobalContextServerInternal() {
52
59
  // getGlobalContextServerInternal() should always be called after initGlobalContext()
53
60
  (0, utils_js_1.assert)(globalObject.isInitialized);
@@ -134,10 +141,12 @@ async function setGlobalContext_viteDevServer(viteDevServer) {
134
141
  (0, utils_js_1.assert)(globalObject.viteConfig);
135
142
  globalObject.viteDevServer = viteDevServer;
136
143
  globalObject.viteDevServerPromiseResolve(viteDevServer);
137
- const { success } = await updateUserFiles();
138
- if (!success)
139
- return;
140
- assertGlobalContextIsDefined();
144
+ if (isRunnable(viteDevServer)) {
145
+ const { success } = await updateUserFiles();
146
+ if (!success)
147
+ return;
148
+ assertGlobalContextIsDefined();
149
+ }
141
150
  }
142
151
  function setGlobalContext_viteConfig(viteConfig, viteConfigRuntime) {
143
152
  if (globalObject.viteConfig)
@@ -154,7 +163,10 @@ function setGlobalContext_isPrerendering() {
154
163
  globalObject.isPrerendering = true;
155
164
  setIsProduction(true);
156
165
  }
157
- function setGlobalContext_isProduction(isProduction, tolerateContraditction) {
166
+ // TODO/now: `rename tolerateContraditction tolerateContradiction`
167
+ function setGlobalContext_isProduction(isProduction, tolerateContraditction = false) {
168
+ if (debug.isActivated)
169
+ debug('setGlobalContext_isProduction()', { isProduction, tolerateContraditction });
158
170
  if (globalObject.isProduction === undefined) {
159
171
  setIsProduction(isProduction);
160
172
  }
@@ -203,7 +215,13 @@ async function initGlobalContext() {
203
215
  const { isProduction } = globalObject;
204
216
  (0, utils_js_1.assert)(typeof isProduction === 'boolean');
205
217
  if (!isProduction) {
206
- await globalObject.viteDevServerPromise;
218
+ if (isProcessSharedWithVite()) {
219
+ await globalObject.viteDevServerPromise;
220
+ }
221
+ else {
222
+ (0, utils_js_1.assert)(isNonRunnableDev());
223
+ await updateUserFiles();
224
+ }
207
225
  (0, utils_js_1.assert)(globalObject.waitForUserFilesUpdate);
208
226
  await globalObject.waitForUserFilesUpdate;
209
227
  }
@@ -260,7 +278,7 @@ async function loadBuildEntry(outDir) {
260
278
  assertBuildEntry(buildEntry);
261
279
  globalObject.assetsManifest = buildEntry.assetsManifest;
262
280
  globalObject.buildInfo = buildEntry.buildInfo;
263
- await setGlobalContext(buildEntry.virtualFileExports);
281
+ await createGlobalContext(buildEntry.virtualFileExports);
264
282
  }
265
283
  // This is the production entry, see:
266
284
  // https://github.com/vikejs/vike/blob/798e5465dc3e3e6723b38b601a50350c0a006fb8/packages/vike/node/vite/plugins/pluginBuild/pluginBuildEntry.ts#L47
@@ -305,6 +323,7 @@ function assertVersionAtBuildTime(versionAtBuildTime) {
305
323
  (0, utils_js_1.assertUsage)(versionAtBuildTime === versionAtRuntime, `Re-build your app (you're using ${pretty(versionAtRuntime)} but your app was built with ${pretty(versionAtBuildTime)})`);
306
324
  }
307
325
  async function updateUserFiles() {
326
+ debug('updateUserFiles()');
308
327
  (0, utils_js_1.assert)(!globalObject.isProduction);
309
328
  const { promise, resolve } = (0, utils_js_1.genPromise)();
310
329
  globalObject.waitForUserFilesUpdate = promise;
@@ -337,16 +356,46 @@ async function updateUserFiles() {
337
356
  // Avoid race condition: abort if there is a new globalObject.viteDevServer (happens when vite.config.js is modified => Vite's dev server is fully reloaded).
338
357
  viteDevServer !== globalObject.viteDevServer;
339
358
  const { viteDevServer } = globalObject;
340
- (0, utils_js_1.assert)(viteDevServer);
341
359
  let hasError = false;
342
360
  let virtualFileExports;
343
361
  let err;
344
- try {
345
- virtualFileExports = await viteDevServer.ssrLoadModule(virtualFileEntry_js_1.virtualFileIdEntryServer);
362
+ if (viteDevServer) {
363
+ (0, utils_js_1.assert)(isRunnable(viteDevServer));
364
+ /* We don't use runner.import() yet, because as of vite@7.0.6 (July 2025) runner.import() unexpectedly invalidates the module graph, which is a unexpected behavior that doesn't happen with ssrLoadModule()
365
+ // Vite 6
366
+ try {
367
+ virtualFileExports = await (viteDevServer.environments.ssr as RunnableDevEnvironment).runner.import(
368
+ 'virtual:vike:entry:server',
369
+ )
370
+ } catch (err_) {
371
+ hasError = true
372
+ err = err_
373
+ }
374
+ */
375
+ // Vite 5
376
+ try {
377
+ virtualFileExports = await viteDevServer.ssrLoadModule(virtualFileEntry_js_1.virtualFileIdEntryServer);
378
+ }
379
+ catch (err_) {
380
+ hasError = true;
381
+ err = err_;
382
+ }
346
383
  }
347
- catch (err_) {
348
- hasError = true;
349
- err = err_;
384
+ else {
385
+ try {
386
+ /* We use __VIKE__DYNAMIC_IMPORT instead of directly using import() to workaround what seems to be a Vite HMR bug:
387
+ ```js
388
+ assert(false)
389
+ // This line breaks the HMR of regular (runnable) apps, even though (as per the assert() above) it's never run. It seems to be a Vite bug: handleHotUpdate() receives an empty `modules` list.
390
+ import('virtual:vike:entry:server')
391
+ ```
392
+ */
393
+ virtualFileExports = await __VIKE__DYNAMIC_IMPORT('virtual:vike:entry:server');
394
+ }
395
+ catch (err_) {
396
+ hasError = true;
397
+ err = err_;
398
+ }
350
399
  }
351
400
  if (isOutdated())
352
401
  return { success: false };
@@ -357,7 +406,7 @@ async function updateUserFiles() {
357
406
  return { success: false };
358
407
  }
359
408
  try {
360
- await setGlobalContext(virtualFileExports);
409
+ await createGlobalContext(virtualFileExports);
361
410
  }
362
411
  catch (err_) {
363
412
  hasError = true;
@@ -369,26 +418,26 @@ async function updateUserFiles() {
369
418
  return onError(err);
370
419
  return onSuccess();
371
420
  }
372
- async function setGlobalContext(virtualFileExports) {
373
- debug('setGlobalContext()');
421
+ async function createGlobalContext(virtualFileExports) {
422
+ debug('createGlobalContext()');
374
423
  (0, utils_js_1.assert)(!(0, getVikeConfigError_js_1.getVikeConfigErrorBuild)());
375
- const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContextAsync, addGlobalContextSync);
424
+ const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
376
425
  (0, assertV1Design_js_1.assertV1Design)(
377
426
  // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
378
427
  globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
379
428
  assertGlobalContextIsDefined();
380
429
  (0, utils_js_1.onSetupRuntime)();
381
- debug('setGlobalContext() - done');
382
- // Never actually used, only used for TypeScript `ReturnType<typeof setGlobalContext>`
430
+ debug('createGlobalContext() - done');
431
+ // Never actually used, only used for TypeScript `ReturnType<typeof createGlobalContext>`
383
432
  return globalContext;
384
433
  }
385
- async function addGlobalContextAsync(globalContext) {
386
- debug('addGlobalContextAsync()');
434
+ async function addGlobalContextTmp(globalContext) {
435
+ debug('addGlobalContextTmp()');
387
436
  const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(globalContext._pageFilesAll, globalContext._pageConfigs, globalContext._pageConfigGlobal, globalContext._allPageIds);
388
437
  return addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook);
389
438
  }
390
- function addGlobalContextSync(globalContext) {
391
- debug('addGlobalContextSync()');
439
+ function addGlobalContext(globalContext) {
440
+ debug('addGlobalContext()');
392
441
  const { pageRoutes, onBeforeRouteHook } = (0, loadPageRoutes_js_1.loadPageRoutesSync)(globalContext._pageFilesAll, globalContext._pageConfigs, globalContext._pageConfigGlobal, globalContext._allPageIds);
393
442
  return addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook);
394
443
  }
@@ -398,23 +447,18 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
398
447
  _pageRoutes: pageRoutes,
399
448
  _onBeforeRouteHook: onBeforeRouteHook,
400
449
  };
401
- const { viteDevServer, viteConfig, viteConfigRuntime, isPrerendering, isProduction } = globalObject;
450
+ const { viteDevServer, viteConfig, isPrerendering, isProduction } = globalObject;
402
451
  (0, utils_js_1.assert)(typeof isProduction === 'boolean');
403
452
  if (!isProduction) {
404
- (0, utils_js_1.assert)(viteDevServer);
405
453
  (0, utils_js_1.assert)(globalContext); // main common requirement
406
- (0, utils_js_1.assert)(viteConfig);
407
- (0, utils_js_1.assert)(viteConfigRuntime);
408
454
  (0, utils_js_1.assert)(!isPrerendering);
409
455
  return {
410
456
  ...globalContextBase,
411
- ...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
412
457
  _isProduction: false,
413
458
  _isPrerendering: false,
414
459
  assetsManifest: null,
415
460
  _viteDevServer: viteDevServer,
416
461
  viteConfig,
417
- viteConfigRuntime,
418
462
  };
419
463
  }
420
464
  else {
@@ -425,11 +469,9 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
425
469
  (0, utils_js_1.assert)(assetsManifest);
426
470
  const globalContextBase2 = {
427
471
  ...globalContextBase,
428
- ...resolveBaseRuntime(buildInfo.viteConfigRuntime, globalContext.config),
429
472
  _isProduction: true,
430
473
  assetsManifest,
431
474
  _viteDevServer: null,
432
- viteConfigRuntime: buildInfo.viteConfigRuntime,
433
475
  _usesClientRouter: buildInfo.usesClientRouter,
434
476
  };
435
477
  if (isPrerendering) {
@@ -449,6 +491,27 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
449
491
  }
450
492
  }
451
493
  }
494
+ async function addGlobalContextAsync(globalContext) {
495
+ debug('addGlobalContextAsync()');
496
+ let { viteConfigRuntime, buildInfo } = globalObject;
497
+ if (!viteConfigRuntime) {
498
+ if (buildInfo) {
499
+ viteConfigRuntime = buildInfo.viteConfigRuntime;
500
+ }
501
+ else {
502
+ (0, utils_js_1.assert)(!isProcessSharedWithVite()); // process shared with Vite => globalObject.viteConfigRuntime should be set
503
+ (0, utils_js_1.assert)(!globalObject.isProduction); // production => globalObject.buildInfo.viteConfigRuntime should be set
504
+ (0, utils_js_1.assert)(isNonRunnableDev());
505
+ const rpc = (0, utils_js_1.getViteRPC)();
506
+ viteConfigRuntime = await rpc.getViteConfigRuntimeRPC();
507
+ }
508
+ }
509
+ (0, utils_js_1.assert)(viteConfigRuntime);
510
+ return {
511
+ viteConfigRuntime,
512
+ ...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
513
+ };
514
+ }
452
515
  function clearGlobalContext() {
453
516
  debug('clearGlobalContext()');
454
517
  (0, utils_js_1.objectReplace)(globalObject, getInitialGlobalObject(), ['buildEntryPrevious']);
@@ -457,6 +520,7 @@ function getInitialGlobalObject() {
457
520
  debug('getInitialGlobalObject()');
458
521
  const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
459
522
  return {
523
+ isProduction: isNonRunnableDev() ? false : undefined,
460
524
  viteDevServerPromise,
461
525
  viteDevServerPromiseResolve,
462
526
  };
@@ -467,3 +531,26 @@ function resolveBaseRuntime(viteConfigRuntime, config) {
467
531
  const baseAssetsUnresolved = config.baseAssets ?? null;
468
532
  return (0, resolveBase_js_1.resolveBase)(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
469
533
  }
534
+ function isProcessSharedWithVite() {
535
+ const yes = globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE ?? false;
536
+ if (yes)
537
+ (0, utils_js_1.assert)(!isNonRunnableDev());
538
+ return yes;
539
+ }
540
+ function isRunnable(viteDevServer) {
541
+ const yes =
542
+ // Vite 5
543
+ !viteDevServer.environments ||
544
+ // Vite 6 or above
545
+ (0, utils_js_1.isRunnableDevEnvironment)(viteDevServer.environments.ssr);
546
+ if (yes)
547
+ (0, utils_js_1.assert)(!isNonRunnableDev());
548
+ return yes;
549
+ }
550
+ function isNonRunnableDev() {
551
+ if (typeof __VIKE__IS_NON_RUNNABLE_DEV === 'undefined')
552
+ return null;
553
+ const yes = __VIKE__IS_NON_RUNNABLE_DEV;
554
+ (0, utils_js_1.assert)(typeof yes === 'boolean');
555
+ return yes;
556
+ }
@@ -187,7 +187,7 @@ function mergeScriptEntries(pageAssets, viteDevScript) {
187
187
  return scriptEntry;
188
188
  }
189
189
  function getPageContextJsonScriptTag(pageContext) {
190
- const pageContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getPageContextClientSerialized)(pageContext));
190
+ const pageContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getPageContextClientSerialized)(pageContext, true));
191
191
  const htmlTag = `<script id="${htmlElementIds_js_1.htmlElementId_pageContext}" type="application/json">${pageContextClientSerialized}</script>`;
192
192
  // Used by contra.com https://github.com/gajus
193
193
  // @ts-expect-error
@@ -195,7 +195,7 @@ function getPageContextJsonScriptTag(pageContext) {
195
195
  return htmlTag;
196
196
  }
197
197
  function getGlobalContextJsonScriptTag(pageContext) {
198
- const globalContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getGlobalContextClientSerialized)(pageContext));
198
+ const globalContextClientSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializeContext_js_1.getGlobalContextClientSerialized)(pageContext, true));
199
199
  const htmlTag = `<script id="${htmlElementIds_js_1.htmlElementId_globalContext}" type="application/json">${globalContextClientSerialized}</script>`;
200
200
  return htmlTag;
201
201
  }
@@ -16,7 +16,9 @@ async function getViteDevScript(pageContext) {
16
16
  const fakeHtmlBegin = '<html> <head>'; // White space to test whether user is using a minifier
17
17
  const fakeHtmlEnd = '</head><body></body></html>';
18
18
  let fakeHtml = fakeHtmlBegin + fakeHtmlEnd;
19
- fakeHtml = await viteDevServer.transformIndexHtml('/', fakeHtml);
19
+ fakeHtml = viteDevServer
20
+ ? await viteDevServer.transformIndexHtml('/', fakeHtml)
21
+ : await (0, utils_js_1.getViteRPC)().transformIndexHtmlRPC(fakeHtml);
20
22
  (0, utils_js_1.assertUsage)(!fakeHtml.includes('vite-plugin-pwa'), `The HTML transformer of ${picocolors_1.default.cyan('vite-plugin-pwa')} cannot be applied, see workaround at https://github.com/vikejs/vike/issues/388#issuecomment-1199280084`);
21
23
  (0, utils_js_1.assertUsage)(!fakeHtml.startsWith(fakeHtmlBegin.replace(' ', '')), `Vite plugins that minify the HTML cannot be applied, see https://github.com/vikejs/vike/issues/224`);
22
24
  (0, utils_js_1.assertUsage)(fakeHtml.startsWith(fakeHtmlBegin) && fakeHtml.endsWith(fakeHtmlEnd), `You are using a Vite Plugin that transforms the HTML in a way that conflicts with Vike. ${reachOutCTA}`);
@@ -30,63 +30,42 @@ const passToClientBuiltInPageContext = [
30
30
  'data', // for data() hook
31
31
  ];
32
32
  const pageToClientBuiltInPageContextError = ['pageProps', 'is404', isServerSideError_js_1.isServerSideError];
33
- function getPageContextClientSerialized(pageContext) {
33
+ function getPageContextClientSerialized(pageContext, isHtmlJsonScript) {
34
34
  const passToClientPageContext = getPassToClientPageContext(pageContext);
35
- const getObj = (passToClientEntry) => {
36
- if (passToClientEntry.once)
37
- return undefined; // pass it to client-side globalContext
38
- return { obj: pageContext, objName: 'pageContext' };
39
- };
40
- const res = applyPassToClient(passToClientPageContext, getObj);
35
+ const res = applyPassToClient(passToClientPageContext, pageContext);
41
36
  const pageContextClient = res.objClient;
42
37
  const pageContextClientProps = res.objClientProps;
43
38
  if (pageContextClientProps.some((prop) => (0, propKeys_js_1.getPropVal)(pageContext._pageContextInit, prop))) {
44
39
  pageContextClient[pageContextInitIsPassedToClient_js_1.pageContextInitIsPassedToClient] = true;
45
40
  }
46
- const pageContextClientSerialized = serializeObject(pageContextClient, passToClientPageContext, getObj);
41
+ const pageContextClientSerialized = serializeObject(pageContextClient, passToClientPageContext, 'pageContext', isHtmlJsonScript);
47
42
  return pageContextClientSerialized;
48
43
  }
49
- function getGlobalContextClientSerialized(pageContext) {
44
+ function getGlobalContextClientSerialized(pageContext, isHtmlJsonScript) {
50
45
  const passToClient = pageContext._passToClient;
51
46
  const globalContext = pageContext._globalContext;
52
- const getObj = ({ prop, once }) => {
53
- if (once && (0, propKeys_js_1.getPropVal)(pageContext, prop)) {
54
- (0, utils_js_1.assert)(typeof pageContext.isClientSideNavigation === 'boolean');
55
- if (!pageContext.isClientSideNavigation) {
56
- return { obj: pageContext, objName: 'pageContext' }; // pass it to client-side globalContext
57
- }
58
- else {
59
- return undefined; // already passed to client-side
60
- }
61
- }
62
- return { obj: globalContext, objName: 'globalContext' };
63
- };
64
- const res = applyPassToClient(passToClient, getObj);
47
+ const res = applyPassToClient(passToClient, globalContext);
65
48
  const globalContextClient = res.objClient;
66
- const globalContextClientSerialized = serializeObject(globalContextClient, passToClient, getObj);
49
+ const globalContextClientSerialized = serializeObject(globalContextClient, passToClient, 'globalContext', isHtmlJsonScript);
67
50
  return globalContextClientSerialized;
68
51
  }
69
- function serializeObject(obj, passToClient, getObj) {
52
+ function serializeObject(obj, passToClient, objName, isHtmlJsonScript) {
70
53
  let serialized;
71
54
  try {
72
- serialized = serializeValue(obj);
55
+ serialized = serializeValue(obj, isHtmlJsonScript);
73
56
  }
74
57
  catch (err) {
75
58
  const h = (s) => picocolors_1.default.cyan(s);
76
59
  let hasWarned = false;
77
60
  const propsNonSerializable = [];
78
- passToClient.forEach((entry) => {
79
- const entryNormalized = normalizePassToClientEntry(entry);
80
- const { prop } = entryNormalized;
61
+ passToClient.forEach((prop) => {
81
62
  const res = (0, propKeys_js_1.getPropVal)(obj, prop);
82
63
  if (!res)
83
64
  return;
84
65
  const { value } = res;
85
- const { objName } = getObj(entryNormalized) ?? {};
86
- (0, utils_js_1.assert)(objName);
87
66
  const varName = `${objName}${(0, propKeys_js_1.getPropKeys)(prop).map(utils_js_1.getPropAccessNotation).join('')}`;
88
67
  try {
89
- serializeValue(value, varName);
68
+ serializeValue(value, isHtmlJsonScript, varName);
90
69
  }
91
70
  catch (err) {
92
71
  propsNonSerializable.push(prop);
@@ -124,7 +103,7 @@ function serializeObject(obj, passToClient, getObj) {
124
103
  obj[(0, propKeys_js_1.getPropKeys)(prop)[0]] = NOT_SERIALIZABLE_js_1.NOT_SERIALIZABLE;
125
104
  });
126
105
  try {
127
- serialized = serializeValue(obj);
106
+ serialized = serializeValue(obj, isHtmlJsonScript);
128
107
  }
129
108
  catch (err) {
130
109
  (0, utils_js_1.assert)(false);
@@ -132,20 +111,20 @@ function serializeObject(obj, passToClient, getObj) {
132
111
  }
133
112
  return serialized;
134
113
  }
135
- function serializeValue(value, varName) {
114
+ function serializeValue(value, isHtmlJsonScript, varName) {
136
115
  return (0, stringify_1.stringify)(value, {
137
116
  forbidReactElements: true,
138
117
  valueName: varName,
139
118
  // Prevent Google from crawling URLs in JSON:
140
- // - https://github.com/vikejs/vike/discussions/2541#discussioncomment-13660198
141
- // - https://github.com/vikejs/vike/discussions/2277
142
- // - https://github.com/vikejs/vike/pull/2542
143
- replacer(_key, value) {
144
- if (typeof value === 'string' && value.startsWith('/')) {
145
- // No need to use a reviver: https://github.com/brillout/json-serializer/blob/70fc8ed3741306391b51655b05df24e6963d1fdb/test/main.spec.ts#L74-L80
146
- return { replacement: (value = '!' + value) };
147
- }
148
- },
119
+ // - https://github.com/vikejs/vike/pull/2603
120
+ // - https://github.com/brillout/json-serializer/blob/38edbb9945de4938da1e65d6285ce1dd123a45ef/test/main.spec.ts#L44-L95
121
+ replacer: !isHtmlJsonScript
122
+ ? undefined
123
+ : (_key, value) => {
124
+ if (typeof value === 'string') {
125
+ return { replacement: value.replaceAll('/', '\\/'), resolved: false };
126
+ }
127
+ },
149
128
  });
150
129
  }
151
130
  function getPassToClientPageContext(pageContext) {
@@ -158,7 +137,7 @@ function getPassToClientPageContext(pageContext) {
158
137
  passToClient = (0, utils_js_1.unique)(passToClient);
159
138
  return passToClient;
160
139
  }
161
- function getPageContextClientSerializedAbort(pageContext) {
140
+ function getPageContextClientSerializedAbort(pageContext, isHtmlJsonScript) {
162
141
  (0, utils_js_1.assert)(pageContext._urlRedirect || pageContext._urlRewrite || pageContext.abortStatusCode);
163
142
  (0, utils_js_1.assert)(pageContext._abortCall);
164
143
  (0, utils_js_1.assert)(pageContext._abortCaller);
@@ -191,17 +170,12 @@ function getPageContextClientSerializedAbort(pageContext) {
191
170
  onlyOnce: false,
192
171
  });
193
172
  }
194
- return serializeValue(pageContext);
173
+ return serializeValue(pageContext, isHtmlJsonScript);
195
174
  }
196
- function applyPassToClient(passToClient, getObj) {
175
+ function applyPassToClient(passToClient, obj) {
197
176
  const objClient = {};
198
177
  const objClientProps = [];
199
- passToClient.forEach((entry) => {
200
- const entryNormalized = normalizePassToClientEntry(entry);
201
- const { prop } = entryNormalized;
202
- const { obj } = getObj(entryNormalized) ?? {};
203
- if (!obj)
204
- return;
178
+ passToClient.forEach((prop) => {
205
179
  // Get value from pageContext
206
180
  const res = (0, propKeys_js_1.getPropVal)(obj, prop);
207
181
  if (!res)
@@ -213,16 +187,3 @@ function applyPassToClient(passToClient, getObj) {
213
187
  });
214
188
  return { objClient, objClientProps };
215
189
  }
216
- function normalizePassToClientEntry(entry) {
217
- let once;
218
- let prop;
219
- if (typeof entry === 'string') {
220
- prop = entry;
221
- once = false;
222
- }
223
- else {
224
- prop = entry.prop;
225
- once = entry.once ?? false;
226
- }
227
- return { prop, once };
228
- }
@@ -527,8 +527,8 @@ async function createStreamWrapper({ streamOriginal, onError, onData, onEnd, onF
527
527
  const closeStream = async () => {
528
528
  if (isClosed)
529
529
  return;
530
- isClosed = true;
531
530
  await onEnd(isCancel);
531
+ isClosed = true;
532
532
  controllerProxy.close();
533
533
  };
534
534
  let controllerProxy;
@@ -5,12 +5,9 @@ exports.createPageContextServerSideWithoutGlobalContext = createPageContextServe
5
5
  const utils_js_1 = require("../utils.js");
6
6
  const getPageContextUrlComputed_js_1 = require("../../../shared/getPageContextUrlComputed.js");
7
7
  const createPageContextShared_js_1 = require("../../../shared/createPageContextShared.js");
8
- function createPageContextServerSide(pageContextInit, globalContext, { isPrerendering, ssr: { urlHandler, isClientSideNavigation } = {
9
- urlHandler: null,
10
- isClientSideNavigation: false,
11
- }, }) {
8
+ function createPageContextServerSide(pageContextInit, globalContext, args) {
12
9
  (0, utils_js_1.assert)(pageContextInit.urlOriginal);
13
- const pageContextCreated = createPageContext(pageContextInit, isPrerendering);
10
+ const pageContextCreated = createPageContext(pageContextInit, args.isPrerendering);
14
11
  (0, utils_js_1.objectAssign)(pageContextCreated, {
15
12
  _globalContext: globalContext,
16
13
  _pageFilesAll: globalContext._pageFilesAll, // TO-DO/next-major-release: remove
@@ -19,8 +16,8 @@ function createPageContextServerSide(pageContextInit, globalContext, { isPrerend
19
16
  _baseAssets: globalContext.baseAssets,
20
17
  _pageContextInit: pageContextInit,
21
18
  _urlRewrite: null,
22
- _urlHandler: urlHandler,
23
- isClientSideNavigation,
19
+ _urlHandler: args.ssr?.urlHandler ?? null,
20
+ isClientSideNavigation: args.ssr?.isClientSideNavigation ?? false,
24
21
  });
25
22
  (0, utils_js_1.objectAssign)(pageContextCreated, globalContext._vikeConfigPublicGlobal);
26
23
  // pageContext.urlParsed
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.retrieveAssetsDev = retrieveAssetsDev;
4
4
  const utils_js_1 = require("../../utils.js");
5
+ const virtualFileEntry_js_1 = require("../../../shared/virtualFiles/virtualFileEntry.js");
5
6
  async function retrieveAssetsDev(clientDependencies, viteDevServer) {
6
7
  const assetUrls = new Set();
7
8
  await Promise.all(clientDependencies.map(async ({ id }) => {
8
9
  if (id.startsWith('@@vike'))
9
10
  return; // vike doesn't have any CSS
10
11
  (0, utils_js_1.assert)(id);
12
+ (0, utils_js_1.assert)(!(0, virtualFileEntry_js_1.isVirtualFileIdEntry)(id));
11
13
  const { moduleGraph } = viteDevServer;
12
14
  const [_, graphId] = await moduleGraph.resolveUrl(id);
13
15
  (0, utils_js_1.assert)(graphId, { id });
@@ -34,6 +36,8 @@ function collectCss(mod, styleUrls, visitedModules, importer) {
34
36
  if (visitedModules.has(mod.url))
35
37
  return;
36
38
  visitedModules.add(mod.url);
39
+ if ((0, virtualFileEntry_js_1.isVirtualFileIdEntry)(mod.id || mod.url))
40
+ return; // virtual:vike:entry:server dependency list includes all pages
37
41
  if (isStyle(mod) && (!importer || !isStyle(importer))) {
38
42
  if (mod.url.startsWith('/')) {
39
43
  styleUrls.add(mod.url);