vike 0.4.218 → 0.4.220-commit-a9f46b8

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 (211) hide show
  1. package/dist/cjs/__internal/index.js +11 -11
  2. package/dist/cjs/node/api/build.js +22 -48
  3. package/dist/cjs/node/api/context.js +8 -6
  4. package/dist/cjs/node/api/index.js +17 -7
  5. package/dist/cjs/node/api/prepareViteApiCall.js +40 -13
  6. package/dist/cjs/node/cli/context.js +16 -0
  7. package/dist/cjs/node/cli/entry.js +21 -7
  8. package/dist/cjs/node/cli/utils.js +1 -0
  9. package/dist/cjs/node/plugin/index.js +5 -5
  10. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +32 -20
  11. package/dist/cjs/node/plugin/plugins/baseUrls.js +3 -10
  12. package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
  13. package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
  14. package/dist/cjs/node/plugin/plugins/commonConfig.js +41 -4
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +26 -23
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +171 -68
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  18. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -5
  19. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
  20. package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
  21. package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
  22. package/dist/cjs/node/prerender/context.js +24 -0
  23. package/dist/cjs/node/prerender/runPrerender.js +146 -96
  24. package/dist/cjs/node/prerender/utils.js +2 -0
  25. package/dist/cjs/node/runtime/globalContext.js +109 -55
  26. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  27. package/dist/cjs/node/runtime/index-common.js +0 -15
  28. package/dist/cjs/node/runtime/onLoad.js +17 -3
  29. package/dist/cjs/node/runtime/page-files/setup.js +2 -4
  30. package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
  31. package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
  32. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  33. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
  34. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +9 -1
  35. package/dist/cjs/node/runtime/renderPage.js +21 -22
  36. package/dist/cjs/node/runtime/utils.js +2 -0
  37. package/dist/cjs/node/runtime-dev/index.js +17 -7
  38. package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -2
  39. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
  40. package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
  41. package/dist/cjs/shared/getPageFiles.js +3 -9
  42. package/dist/cjs/shared/hooks/getHook.js +3 -3
  43. package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
  44. package/dist/cjs/shared/page-configs/loadConfigValues.js +5 -1
  45. package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +80 -55
  46. package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
  47. package/dist/cjs/shared/utils.js +1 -0
  48. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  49. package/dist/cjs/utils/assert.js +4 -3
  50. package/dist/cjs/utils/assertSetup.js +47 -16
  51. package/dist/cjs/utils/catchInfiniteLoop.js +34 -0
  52. package/dist/cjs/utils/debug.js +11 -6
  53. package/dist/cjs/utils/getGlobalObject.js +1 -2
  54. package/dist/cjs/utils/isDev.js +2 -0
  55. package/dist/cjs/utils/makePublicCopy.js +32 -0
  56. package/dist/cjs/utils/objectReplace.js +9 -0
  57. package/dist/esm/__internal/index.d.ts +3 -5
  58. package/dist/esm/__internal/index.js +6 -8
  59. package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -1
  60. package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
  61. package/dist/esm/client/client-routing-runtime/entry.js +0 -1
  62. package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
  63. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
  64. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
  65. package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
  66. package/dist/esm/client/client-routing-runtime/history.js +23 -18
  67. package/dist/esm/client/client-routing-runtime/index.d.ts +0 -1
  68. package/dist/esm/client/client-routing-runtime/index.js +0 -1
  69. package/dist/esm/client/client-routing-runtime/initClientRouter.js +2 -2
  70. package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +3 -4
  71. package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +0 -10
  72. package/dist/esm/client/client-routing-runtime/initOnPopState.js +50 -62
  73. package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
  74. package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
  75. package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
  76. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +15 -15
  77. package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +4 -6
  78. package/dist/esm/client/client-routing-runtime/scrollRestoration.js +17 -12
  79. package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +1 -1
  80. package/dist/esm/client/client-routing-runtime/setScrollPosition.js +29 -5
  81. package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
  82. package/dist/esm/client/client-routing-runtime/utils.js +1 -0
  83. package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
  84. package/dist/esm/client/server-routing-runtime/entry.js +0 -1
  85. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
  86. package/dist/esm/client/server-routing-runtime/getPageContext.js +5 -2
  87. package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
  88. package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
  89. package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
  90. package/dist/esm/client/shared/normalizeClientSideUrl.js +2 -3
  91. package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
  92. package/dist/esm/node/api/build.d.ts +1 -6
  93. package/dist/esm/node/api/build.js +20 -26
  94. package/dist/esm/node/api/context.d.ts +4 -2
  95. package/dist/esm/node/api/context.js +8 -7
  96. package/dist/esm/node/api/prepareViteApiCall.d.ts +0 -1
  97. package/dist/esm/node/api/prepareViteApiCall.js +26 -9
  98. package/dist/esm/node/cli/context.d.ts +5 -0
  99. package/dist/esm/node/cli/context.js +14 -0
  100. package/dist/esm/node/cli/entry.js +4 -0
  101. package/dist/esm/node/cli/parseCli.d.ts +3 -1
  102. package/dist/esm/node/cli/utils.d.ts +1 -0
  103. package/dist/esm/node/cli/utils.js +1 -0
  104. package/dist/esm/node/plugin/index.d.ts +1 -1
  105. package/dist/esm/node/plugin/index.js +5 -5
  106. package/dist/esm/node/plugin/plugins/autoFullBuild.js +32 -20
  107. package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -1
  108. package/dist/esm/node/plugin/plugins/baseUrls.js +4 -11
  109. package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
  110. package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
  111. package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
  112. package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
  113. package/dist/esm/node/plugin/plugins/commonConfig.d.ts +10 -1
  114. package/dist/esm/node/plugin/plugins/commonConfig.js +42 -5
  115. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
  116. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +6 -9
  117. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +25 -22
  118. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +96 -1
  119. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +167 -64
  120. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  121. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -5
  122. package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
  123. package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
  124. package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
  125. package/dist/esm/node/prerender/context.d.ts +9 -0
  126. package/dist/esm/node/prerender/context.js +22 -0
  127. package/dist/esm/node/prerender/runPrerender.d.ts +42 -2
  128. package/dist/esm/node/prerender/runPrerender.js +130 -90
  129. package/dist/esm/node/prerender/utils.d.ts +2 -0
  130. package/dist/esm/node/prerender/utils.js +2 -0
  131. package/dist/esm/node/runtime/globalContext.d.ts +23 -7
  132. package/dist/esm/node/runtime/globalContext.js +109 -55
  133. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
  134. package/dist/esm/node/runtime/index-common.d.ts +0 -1
  135. package/dist/esm/node/runtime/index-common.js +0 -15
  136. package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
  137. package/dist/esm/node/runtime/onLoad.js +16 -2
  138. package/dist/esm/node/runtime/page-files/setup.js +3 -3
  139. package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
  140. package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
  141. package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
  142. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
  143. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
  144. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
  145. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +31 -46
  146. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
  147. package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +1 -1
  148. package/dist/esm/node/runtime/renderPage/resolveRedirects.js +9 -1
  149. package/dist/esm/node/runtime/renderPage.js +22 -23
  150. package/dist/esm/node/runtime/utils.d.ts +2 -0
  151. package/dist/esm/node/runtime/utils.js +2 -0
  152. package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
  153. package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -1
  154. package/dist/esm/node/shared/assertRuntimeManifest.js +1 -3
  155. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
  156. package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +3 -1
  157. package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
  158. package/dist/esm/shared/getPageFiles.d.ts +2 -5
  159. package/dist/esm/shared/getPageFiles.js +1 -4
  160. package/dist/esm/shared/hooks/getHook.d.ts +3 -3
  161. package/dist/esm/shared/hooks/getHook.js +1 -1
  162. package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +9 -5
  163. package/dist/esm/shared/page-configs/Config.d.ts +20 -2
  164. package/dist/esm/shared/page-configs/PageConfig.d.ts +13 -6
  165. package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +26 -12
  166. package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
  167. package/dist/esm/shared/page-configs/loadConfigValues.js +6 -2
  168. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +26 -6
  169. package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +80 -55
  170. package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
  171. package/dist/esm/shared/route/loadPageRoutes.js +1 -1
  172. package/dist/esm/shared/types.d.ts +1 -1
  173. package/dist/esm/shared/utils.d.ts +1 -0
  174. package/dist/esm/shared/utils.js +1 -0
  175. package/dist/esm/types/index.d.ts +1 -1
  176. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  177. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  178. package/dist/esm/utils/assert.js +4 -3
  179. package/dist/esm/utils/assertSetup.js +47 -16
  180. package/dist/esm/utils/catchInfiniteLoop.d.ts +2 -0
  181. package/dist/esm/utils/catchInfiniteLoop.js +32 -0
  182. package/dist/esm/utils/debug.d.ts +1 -1
  183. package/dist/esm/utils/debug.js +11 -6
  184. package/dist/esm/utils/getGlobalObject.js +1 -2
  185. package/dist/esm/utils/isDev.js +2 -0
  186. package/dist/esm/utils/makePublicCopy.d.ts +3 -0
  187. package/dist/esm/utils/makePublicCopy.js +30 -0
  188. package/dist/esm/utils/objectReplace.d.ts +1 -0
  189. package/dist/esm/utils/objectReplace.js +6 -0
  190. package/dist/esm/utils/projectInfo.d.ts +1 -1
  191. package/package.json +4 -13
  192. package/__internal/loadImportBuild.js +0 -3
  193. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
  194. package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
  195. package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
  196. package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
  197. package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
  198. package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
  199. package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
  200. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
  201. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
  202. package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
  203. package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
  204. package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
  205. package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
  206. package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
  207. /package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
  208. /package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
  209. /package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
  210. /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
  211. /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
@@ -17,23 +17,26 @@ exports.setGlobalContext_viteConfig = setGlobalContext_viteConfig;
17
17
  exports.setGlobalContext_vikeConfig = setGlobalContext_vikeConfig;
18
18
  exports.setGlobalContext_isViteDev = setGlobalContext_isViteDev;
19
19
  exports.setGlobalContext_isPrerendering = setGlobalContext_isPrerendering;
20
+ exports.setGlobalContext_buildEntry = setGlobalContext_buildEntry;
21
+ exports.clearGlobalContext = clearGlobalContext;
20
22
  const utils_js_1 = require("./utils.js");
21
- const loadImportBuild_js_1 = require("./globalContext/loadImportBuild.js");
22
- const getPageFiles_js_1 = require("../../shared/getPageFiles.js");
23
+ const runtime_1 = require("@brillout/vite-plugin-server-entry/runtime");
24
+ const virtualFileImportUserCode_js_1 = require("../shared/virtual-files/virtualFileImportUserCode.js");
25
+ const getPageFiles_js_1 = require("../../shared/getPageFiles/getPageFiles.js");
23
26
  const assertPluginManifest_js_1 = require("../shared/assertPluginManifest.js");
24
27
  const assertRuntimeManifest_js_1 = require("../shared/assertRuntimeManifest.js");
25
28
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
26
- const getPageFilesExports_js_1 = require("./page-files/getPageFilesExports.js");
27
29
  const resolveBase_js_1 = require("../shared/resolveBase.js");
28
- const globalObject = (0, utils_js_1.getGlobalObject)('globalContext.ts', (() => {
29
- const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
30
- return {
31
- viteDevServerPromise,
32
- viteDevServerPromiseResolve
33
- };
34
- })());
30
+ const loadPageRoutes_js_1 = require("../../shared/route/loadPageRoutes.js");
31
+ const assertV1Design_js_1 = require("../shared/assertV1Design.js");
32
+ const debug = (0, utils_js_1.createDebugger)('vike:globalContext');
33
+ const globalObject = (0, utils_js_1.getGlobalObject)('globalContext.ts', getInitialGlobalContext());
34
+ initDevEntry();
35
35
  function getGlobalContext() {
36
- (0, utils_js_1.assert)(globalObject.globalContext);
36
+ if (!globalObject.globalContext) {
37
+ debug('getGlobalContext()', new Error().stack);
38
+ (0, utils_js_1.assert)(false);
39
+ }
37
40
  return globalObject.globalContext;
38
41
  }
39
42
  /** @experimental https://vike.dev/getGlobalContext */
@@ -50,27 +53,8 @@ async function getGlobalContextAsync(isProduction) {
50
53
  return makePublic(globalContext);
51
54
  }
52
55
  function makePublic(globalContext) {
53
- const globalContextPublic = {
54
- assetsManifest: globalContext.assetsManifest
55
- };
56
- // Add internals (and prepended _ prefix to their keys)
57
- {
58
- const publicKeys = Object.keys(globalContextPublic);
59
- (0, utils_js_1.objectKeys)(globalContext)
60
- .filter((key) => !publicKeys.includes(key))
61
- .forEach((key) => {
62
- const keyPublic = `_${key}`;
63
- Object.defineProperty(globalContextPublic, keyPublic, {
64
- enumerable: true,
65
- get() {
66
- (0, utils_js_1.assertWarning)(false, `Using internal globalContext.${keyPublic} which is discouraged: it may break in any minor version update. Instead, reach out on GitHub and elaborate your use case.`, {
67
- onlyOnce: true
68
- });
69
- return globalContext[key];
70
- }
71
- });
72
- });
73
- }
56
+ // TODO/now: add viteConfig and vikeConfig
57
+ const globalContextPublic = (0, utils_js_1.makePublicCopy)(globalContext, 'globalContext', ['assetsManifest']);
74
58
  return globalContextPublic;
75
59
  }
76
60
  function setGlobalContext_viteDevServer(viteDevServer) {
@@ -112,9 +96,11 @@ function getViteConfig() {
112
96
  return globalObject.viteConfig ?? null;
113
97
  }
114
98
  async function initGlobalContext_renderPage() {
99
+ debug('initGlobalContext_renderPage()');
115
100
  await initGlobalContext(!globalObject.isViteDev);
116
101
  }
117
102
  async function initGlobalContext_runPrerender() {
103
+ debug('initGlobalContext_runPrerender()');
118
104
  if (globalObject.initGlobalContext_runPrerender_alreadyCalled)
119
105
  return;
120
106
  globalObject.initGlobalContext_runPrerender_alreadyCalled = true;
@@ -128,6 +114,7 @@ async function initGlobalContext_runPrerender() {
128
114
  await initGlobalContext(true);
129
115
  }
130
116
  async function initGlobalContext_getGlobalContextAsync(isProduction) {
117
+ debug('initGlobalContext_getGlobalContextAsync()');
131
118
  if (!isProduction) {
132
119
  const waitFor = 20;
133
120
  const timeout = setTimeout(() => {
@@ -141,6 +128,7 @@ async function initGlobalContext_getGlobalContextAsync(isProduction) {
141
128
  }
142
129
  await initGlobalContext(isProduction);
143
130
  }
131
+ // TODO/now: refactor: move this to the top of the file
144
132
  async function initGlobalContext(isProduction) {
145
133
  if (globalObject.globalContext) {
146
134
  (0, utils_js_1.assert)(globalObject.globalContext.isProduction === isProduction);
@@ -155,41 +143,45 @@ async function initGlobalContext(isProduction) {
155
143
  (0, utils_js_1.assert)(vikeConfig);
156
144
  (0, utils_js_1.assert)(viteDevServer);
157
145
  (0, utils_js_1.assert)(!isPrerendering);
158
- const vikeConfigGlobal = vikeConfig.vikeConfigGlobal;
159
- const pluginManifest = getRuntimeManifest(vikeConfigGlobal, viteConfig);
146
+ const { globalConfig, userFiles } = await getPageRuntimeInfo(isProduction);
147
+ const pluginManifest = getRuntimeManifest(vikeConfig.vikeConfigGlobal, viteConfig);
160
148
  globalObject.globalContext = {
161
149
  isProduction: false,
162
150
  isPrerendering: false,
163
151
  assetsManifest: null,
164
- pluginManifest: null,
165
152
  viteDevServer,
166
153
  viteConfig,
167
- vikeConfig,
154
+ vikeConfig: {
155
+ global: globalConfig
156
+ },
157
+ ...userFiles,
168
158
  baseServer: pluginManifest.baseServer,
169
159
  baseAssets: pluginManifest.baseAssets,
170
160
  includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
171
- redirects: pluginManifest.redirects,
172
161
  trailingSlash: pluginManifest.trailingSlash,
173
162
  disableUrlNormalization: pluginManifest.disableUrlNormalization
174
163
  };
175
164
  }
176
165
  else {
177
- const buildEntries = await (0, loadImportBuild_js_1.loadImportBuild)(globalObject.outDirRoot);
178
- assertBuildEntries(buildEntries, isPrerendering ?? false);
179
- const { pageFiles, assetsManifest, pluginManifest } = buildEntries;
180
- (0, getPageFiles_js_1.setPageFiles)(pageFiles);
166
+ const buildEntry = await getBuildEntry(globalObject.outDirRoot, isPrerendering);
167
+ const { assetsManifest, pluginManifest } = buildEntry;
168
+ (0, getPageFiles_js_1.setPageFiles)(buildEntry.pageFiles);
169
+ const { globalConfig, userFiles } = await getPageRuntimeInfo(isProduction);
181
170
  assertViteManifest(assetsManifest);
182
171
  (0, assertPluginManifest_js_1.assertPluginManifest)(pluginManifest);
183
172
  const globalContext = {
184
173
  isProduction: true,
185
174
  assetsManifest,
186
- pluginManifest,
175
+ vikeConfig: {
176
+ global: globalConfig
177
+ },
178
+ ...userFiles,
187
179
  viteDevServer: null,
188
180
  baseServer: pluginManifest.baseServer,
189
181
  baseAssets: pluginManifest.baseAssets,
190
182
  includeAssetsImportedByServer: pluginManifest.includeAssetsImportedByServer,
191
- redirects: pluginManifest.redirects,
192
183
  trailingSlash: pluginManifest.trailingSlash,
184
+ usesClientRouter: pluginManifest.usesClientRouter,
193
185
  disableUrlNormalization: pluginManifest.disableUrlNormalization
194
186
  };
195
187
  if (isPrerendering) {
@@ -209,29 +201,35 @@ async function initGlobalContext(isProduction) {
209
201
  }
210
202
  }
211
203
  }
204
+ async function getPageRuntimeInfo(isProduction) {
205
+ const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig } = await (0, getPageFiles_js_1.getPageFilesAll)(false, isProduction);
206
+ const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
207
+ const userFiles = {
208
+ pageFilesAll,
209
+ pageConfigs,
210
+ pageConfigGlobal,
211
+ allPageIds,
212
+ pageRoutes,
213
+ onBeforeRouteHook
214
+ };
215
+ (0, assertV1Design_js_1.assertV1Design)(
216
+ // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
217
+ pageConfigs.length > 0, pageFilesAll);
218
+ return { userFiles, globalConfig };
219
+ }
212
220
  function getRuntimeManifest(vikeConfigGlobal, viteConfig) {
213
- const { includeAssetsImportedByServer, redirects, trailingSlash, disableUrlNormalization } = vikeConfigGlobal;
221
+ const { includeAssetsImportedByServer, trailingSlash, disableUrlNormalization } = vikeConfigGlobal;
214
222
  const { baseServer, baseAssets } = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfigGlobal.baseServer, vikeConfigGlobal.baseAssets, viteConfig);
215
223
  const manifest = {
216
224
  baseServer,
217
225
  baseAssets,
218
226
  includeAssetsImportedByServer,
219
- redirects,
220
227
  trailingSlash,
221
228
  disableUrlNormalization
222
229
  };
223
230
  (0, assertRuntimeManifest_js_1.assertRuntimeManifest)(manifest);
224
231
  return manifest;
225
232
  }
226
- function assertBuildEntries(buildEntries, isPreRendering) {
227
- const errMsg = [
228
- `You are tyring to run`,
229
- isPreRendering ? 'pre-rendering' : 'the server for production',
230
- `but your app isn't built yet. Run ${picocolors_1.default.cyan('$ vike build')} before `,
231
- isPreRendering ? 'pre-rendering.' : 'running the server.'
232
- ].join(' ');
233
- (0, utils_js_1.assertUsage)(buildEntries, errMsg);
234
- }
235
233
  function assertViteManifest(manifest) {
236
234
  (0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(manifest));
237
235
  /* We should include these assertions but we don't as a workaround for PWA manifests: https://github.com/vikejs/vike/issues/769
@@ -248,5 +246,61 @@ function assertViteManifest(manifest) {
248
246
  function eagerlyLoadUserFiles() {
249
247
  // Other than here, the getPageFilesExports() function is only called only upon calling the renderPage() function.
250
248
  // We call it as early as possible here for better performance.
251
- (0, getPageFilesExports_js_1.getPageFilesExports)();
249
+ getPageFilesExports();
250
+ }
251
+ async function getBuildEntry(outDir, isPrerendering) {
252
+ debug('getBuildEntry()');
253
+ if (!globalObject.buildEntry) {
254
+ debug('importServerProductionEntry()');
255
+ // importServerProductionEntry() loads dist/server/entry.mjs which calls setGlobalContext_buildEntry()
256
+ await (0, runtime_1.importServerProductionEntry)({ outDir, doNotLoadServer: isPrerendering });
257
+ if (!globalObject.buildEntry) {
258
+ debug('globalObject.buildEntryPrevious');
259
+ // Needed, for example, when calling the API prerender() then preview() because both trigger a importServerProductionEntry() call but only the first only is applied because of the import() cache. (A proper implementation would be to clear the import() cache, but it probably isn't possible on platforms such as Cloudflare Workers.)
260
+ globalObject.buildEntry = globalObject.buildEntryPrevious;
261
+ }
262
+ (0, utils_js_1.assert)(globalObject.buildEntry);
263
+ }
264
+ const { buildEntry } = globalObject;
265
+ (0, utils_js_1.assert)((0, utils_js_1.isObject)(buildEntry));
266
+ (0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'pageFiles', 'object'));
267
+ (0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'assetsManifest', 'object'));
268
+ (0, utils_js_1.assert)((0, utils_js_1.hasProp)(buildEntry, 'pluginManifest', 'object'));
269
+ return buildEntry;
270
+ }
271
+ function setGlobalContext_buildEntry(buildEntry) {
272
+ debug('setGlobalContext_buildEntry()');
273
+ globalObject.buildEntry = buildEntry;
274
+ globalObject.buildEntryPrevious = buildEntry;
275
+ }
276
+ function initDevEntry() {
277
+ (0, getPageFiles_js_1.setPageFilesAsync)(getPageFilesExports);
278
+ }
279
+ async function getPageFilesExports() {
280
+ const viteDevServer = getViteDevServer();
281
+ (0, utils_js_1.assert)(viteDevServer);
282
+ let moduleExports;
283
+ try {
284
+ moduleExports = await viteDevServer.ssrLoadModule(virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeServer);
285
+ }
286
+ catch (err) {
287
+ (0, utils_js_1.debugGlob)(`Glob error: ${virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeServer} transpile error: `, err);
288
+ throw err;
289
+ }
290
+ moduleExports = moduleExports.default || moduleExports;
291
+ (0, utils_js_1.debugGlob)('Glob result: ', moduleExports);
292
+ (0, utils_js_1.assert)((0, utils_js_1.isObject)(moduleExports));
293
+ return moduleExports;
294
+ }
295
+ function clearGlobalContext() {
296
+ debug('clearGlobalContext()');
297
+ (0, utils_js_1.objectReplace)(globalObject, getInitialGlobalContext(), ['buildEntryPrevious']);
298
+ }
299
+ function getInitialGlobalContext() {
300
+ debug('getInitialGlobalContext()');
301
+ const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
302
+ return {
303
+ viteDevServerPromise,
304
+ viteDevServerPromiseResolve
305
+ };
252
306
  }
@@ -10,7 +10,7 @@ const sanitizeJson_js_1 = require("./sanitizeJson.js");
10
10
  const inferHtmlTags_js_1 = require("./inferHtmlTags.js");
11
11
  const mergeScriptTags_js_1 = require("./mergeScriptTags.js");
12
12
  const helpers_js_1 = require("../../../../shared/page-configs/helpers.js");
13
- const getConfigValue_js_1 = require("../../../../shared/page-configs/getConfigValue.js");
13
+ const getConfigValueRuntime_js_1 = require("../../../../shared/page-configs/getConfigValueRuntime.js");
14
14
  const globalContext_js_1 = require("../../globalContext.js");
15
15
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
16
16
  const getConfigDefinedAt_js_1 = require("../../../../shared/page-configs/getConfigDefinedAt.js");
@@ -218,7 +218,7 @@ function getInjectScriptsAt(pageId, pageConfigs) {
218
218
  if (pageConfigs.length === 0)
219
219
  return null; // only support V1 design
220
220
  const pageConfig = (0, helpers_js_1.getPageConfig)(pageId, pageConfigs);
221
- const configValue = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'injectScriptsAt');
221
+ const configValue = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'injectScriptsAt');
222
222
  if (!configValue)
223
223
  return null;
224
224
  const injectScriptsAt = configValue.value;
@@ -24,18 +24,3 @@ Object.defineProperty(exports, "_injectAssets", { enumerable: true, get: functio
24
24
  // TODO/v1-release: remove
25
25
  var createPageRenderer_js_1 = require("../createPageRenderer.js");
26
26
  Object.defineProperty(exports, "createPageRenderer", { enumerable: true, get: function () { return createPageRenderer_js_1.createPageRenderer; } });
27
- addEcosystemStamp();
28
- require("./page-files/setup.js");
29
- // Used by:
30
- // - Telefunc (to detect the user's stack https://github.com/brillout/telefunc/blob/8288310e88e06a42b710d39c39fb502364ca6d30/telefunc/utils/isVikeApp.ts#L4)
31
- function addEcosystemStamp() {
32
- const g = globalThis;
33
- g._isVikeApp =
34
- /* Don't set to true so that consumers do `!!globalThis._isVikeApp` instead of `globalThis._isVikeApp === true`.
35
- true
36
- */
37
- // We use an object so that we can eventually, in the future, add helpful information as needed. (E.g. the Vike version, or global settings.)
38
- {};
39
- // We keep the old stamp for older Telefunc versions
40
- g._isVitePluginSsr = true;
41
- }
@@ -3,13 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onLoad = onLoad;
4
4
  const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
5
5
  const assertNodeVersion_js_1 = require("../../utils/assertNodeVersion.js");
6
+ const assert_js_1 = require("../../utils/assert.js");
6
7
  const require_shim_1 = require("@brillout/require-shim");
7
- const utils_js_1 = require("./utils.js");
8
8
  const isErrorDebug_js_1 = require("../shared/isErrorDebug.js");
9
9
  function onLoad() {
10
10
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
11
11
  (0, assertNodeVersion_js_1.assertNodeVersion)();
12
- (0, require_shim_1.installRequireShim)();
13
12
  if ((0, isErrorDebug_js_1.isErrorDebug)())
14
- (0, utils_js_1.setAlwaysShowStackTrace)();
13
+ (0, assert_js_1.setAlwaysShowStackTrace)();
14
+ addEcosystemStamp();
15
+ (0, require_shim_1.installRequireShim)();
16
+ }
17
+ // Used by:
18
+ // - Telefunc (to detect the user's stack https://github.com/brillout/telefunc/blob/8288310e88e06a42b710d39c39fb502364ca6d30/telefunc/utils/isVikeApp.ts#L4)
19
+ function addEcosystemStamp() {
20
+ const g = globalThis;
21
+ g._isVikeApp =
22
+ /* Don't set to true so that consumers do `!!globalThis._isVikeApp` instead of `globalThis._isVikeApp === true`.
23
+ true
24
+ */
25
+ // We use an object so that we can eventually, in the future, add helpful information as needed. (E.g. the Vike version, or global settings.)
26
+ {};
27
+ // We keep the old stamp for older Telefunc versions
28
+ g._isVitePluginSsr = true;
15
29
  }
@@ -1,5 +1,3 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getPageFiles_js_1 = require("../../../shared/getPageFiles.js");
4
- const getPageFilesExports_js_1 = require("./getPageFilesExports.js");
5
- (0, getPageFiles_js_1.setPageFilesAsync)(getPageFilesExports_js_1.getPageFilesExports);
2
+ // TODO/v1-release: remove https://github.com/vikejs/vike/issues/2122
3
+ // This doesn't do anything anymore. (It's kept to avoid introducing a breaking change.)
@@ -6,12 +6,12 @@ const analyzePageClientSide_js_1 = require("../../../shared/getPageFiles/analyze
6
6
  const virtualFilePageConfigValuesAll_js_1 = require("../../shared/virtual-files/virtualFilePageConfigValuesAll.js");
7
7
  const analyzeClientSide_js_1 = require("../../../shared/getPageFiles/analyzeClientSide.js");
8
8
  const globalContext_js_1 = require("../globalContext.js");
9
- const getConfigValue_js_1 = require("../../../shared/page-configs/getConfigValue.js");
9
+ const getConfigValueRuntime_js_1 = require("../../../shared/page-configs/getConfigValueRuntime.js");
10
10
  function analyzePage(pageFilesAll, pageConfig, pageId) {
11
11
  if (pageConfig) {
12
12
  const { isClientRuntimeLoaded, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
13
13
  const clientEntries = [];
14
- const clientFilePath = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'client', 'string')?.value ?? null;
14
+ const clientFilePath = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'client', 'string')?.value ?? null;
15
15
  if (clientFilePath)
16
16
  clientEntries.push(clientFilePath);
17
17
  if (isClientRuntimeLoaded)
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCacheControl = getCacheControl;
4
4
  const helpers_js_1 = require("../../../../shared/page-configs/helpers.js");
5
- const getConfigValue_js_1 = require("../../../../shared/page-configs/getConfigValue.js");
5
+ const getConfigValueRuntime_js_1 = require("../../../../shared/page-configs/getConfigValueRuntime.js");
6
6
  const defaultValue = 'no-store, max-age=0';
7
7
  function getCacheControl(pageId, pageConfigs, statusCode) {
8
8
  // TODO/v1-release: remove
@@ -11,7 +11,7 @@ function getCacheControl(pageId, pageConfigs, statusCode) {
11
11
  if (statusCode > 499)
12
12
  return defaultValue;
13
13
  const pageConfig = (0, helpers_js_1.getPageConfig)(pageId, pageConfigs);
14
- const configValue = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'cacheControl', 'string');
14
+ const configValue = (0, getConfigValueRuntime_js_1.getConfigValueRuntime)(pageConfig, 'cacheControl', 'string');
15
15
  const value = configValue?.value;
16
16
  if (value)
17
17
  return value;
@@ -101,7 +101,7 @@ async function loadPageUserFiles(pageFilesAll, pageConfig, pageId, isDev) {
101
101
  const pageFilesServerSide = (0, getPageFiles_js_1.getPageFilesServerSide)(pageFilesAll, pageId);
102
102
  const pageConfigLoaded = !pageConfig ? null : await (0, loadConfigValues_js_1.loadConfigValues)(pageConfig, isDev);
103
103
  await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
104
- const pageContextExports = (0, getPageFiles_js_1.getPageContextExports)(pageFilesServerSide, pageConfigLoaded);
104
+ const pageContextExports = (0, getPageFiles_js_1.getPageConfigUserFriendly)(pageFilesServerSide, pageConfigLoaded);
105
105
  return {
106
106
  pageContextExports,
107
107
  pageFilesLoaded: pageFilesServerSide
@@ -7,10 +7,8 @@ exports.renderPageAlreadyRouted = renderPageAlreadyRouted;
7
7
  exports.prerenderPage = prerenderPage;
8
8
  exports.prerender404Page = prerender404Page;
9
9
  exports.getPageContextInitEnhanced = getPageContextInitEnhanced;
10
- exports.getRenderContext = getRenderContext;
11
10
  const error_page_js_1 = require("../../../shared/error-page.js");
12
11
  const renderHtml_js_1 = require("../html/renderHtml.js");
13
- const getPageFiles_js_1 = require("../../../shared/getPageFiles.js");
14
12
  const utils_js_1 = require("../utils.js");
15
13
  const serializePageContextClientSide_js_1 = require("../html/serializePageContextClientSide.js");
16
14
  const getPageContextUrlComputed_js_1 = require("../../../shared/getPageContextUrlComputed.js");
@@ -23,10 +21,8 @@ const loggerRuntime_js_1 = require("./loggerRuntime.js");
23
21
  const isNewError_js_1 = require("./isNewError.js");
24
22
  const preparePageContextForUserConsumptionServerSide_js_1 = require("./preparePageContextForUserConsumptionServerSide.js");
25
23
  const executeGuardHook_js_1 = require("../../../shared/route/executeGuardHook.js");
26
- const loadPageRoutes_js_1 = require("../../../shared/route/loadPageRoutes.js");
27
24
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
28
25
  const isServerSideError_js_1 = require("../../../shared/misc/isServerSideError.js");
29
- const assertV1Design_js_1 = require("../../shared/assertV1Design.js");
30
26
  async function renderPageAlreadyRouted(pageContext) {
31
27
  // pageContext.pageId can either be the:
32
28
  // - ID of the page matching the routing, or the
@@ -89,8 +85,9 @@ async function prerenderPage(pageContext) {
89
85
  return { documentHtml, pageContextSerialized, pageContext };
90
86
  }
91
87
  }
92
- async function prerender404Page(renderContext, pageContextInit_) {
93
- const errorPageId = (0, error_page_js_1.getErrorPageId)(renderContext.pageFilesAll, renderContext.pageConfigs);
88
+ async function prerender404Page(pageContextInit_) {
89
+ const globalContext = (0, globalContext_js_1.getGlobalContext)();
90
+ const errorPageId = (0, error_page_js_1.getErrorPageId)(globalContext.pageFilesAll, globalContext.pageConfigs);
94
91
  if (!errorPageId) {
95
92
  return null;
96
93
  }
@@ -109,13 +106,13 @@ async function prerender404Page(renderContext, pageContextInit_) {
109
106
  };
110
107
  (0, utils_js_1.objectAssign)(pageContextInit, pageContextInit_);
111
108
  {
112
- const pageContextInitEnhanced = getPageContextInitEnhanced(pageContextInit, renderContext);
109
+ const pageContextInitEnhanced = getPageContextInitEnhanced(pageContextInit);
113
110
  (0, utils_js_1.objectAssign)(pageContext, pageContextInitEnhanced);
114
111
  }
115
112
  (0, utils_js_1.objectAssign)(pageContext, await (0, loadUserFilesServerSide_js_1.loadUserFilesServerSide)(pageContext));
116
113
  return prerenderPage(pageContext);
117
114
  }
118
- function getPageContextInitEnhanced(pageContextInit, renderContext, { ssr: { urlRewrite, urlHandler, isClientSideNavigation } = {
115
+ function getPageContextInitEnhanced(pageContextInit, { ssr: { urlRewrite, urlHandler, isClientSideNavigation } = {
119
116
  urlRewrite: null,
120
117
  urlHandler: null,
121
118
  isClientSideNavigation: false
@@ -131,12 +128,12 @@ function getPageContextInitEnhanced(pageContextInit, renderContext, { ssr: { url
131
128
  _baseAssets: globalContext.baseAssets,
132
129
  _includeAssetsImportedByServer: globalContext.includeAssetsImportedByServer,
133
130
  // TODO: use GloablContext instead
134
- _pageFilesAll: renderContext.pageFilesAll,
135
- _pageConfigs: renderContext.pageConfigs,
136
- _pageConfigGlobal: renderContext.pageConfigGlobal,
137
- _allPageIds: renderContext.allPageIds,
138
- _pageRoutes: renderContext.pageRoutes,
139
- _onBeforeRouteHook: renderContext.onBeforeRouteHook,
131
+ _pageFilesAll: globalContext.pageFilesAll,
132
+ _pageConfigs: globalContext.pageConfigs,
133
+ _pageConfigGlobal: globalContext.pageConfigGlobal,
134
+ _allPageIds: globalContext.allPageIds,
135
+ _pageRoutes: globalContext.pageRoutes,
136
+ _onBeforeRouteHook: globalContext.onBeforeRouteHook,
140
137
  _pageContextInit: pageContextInit,
141
138
  _urlRewrite: urlRewrite,
142
139
  _urlHandler: urlHandler,
@@ -164,22 +161,3 @@ function getPageContextInitEnhanced(pageContextInit, renderContext, { ssr: { url
164
161
  }
165
162
  return pageContextInitEnhanced;
166
163
  }
167
- // TODO: remove getRenderContext() in favor of getGlobalObject() + reloadGlobalContext()
168
- // TODO: impl GlobalNodeContext + GlobalClientContext + GloablContext, and use GlobalContext instead of RenderContext
169
- async function getRenderContext() {
170
- const globalContext = (0, globalContext_js_1.getGlobalContext)();
171
- const { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal } = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
172
- const { pageRoutes, onBeforeRouteHook } = await (0, loadPageRoutes_js_1.loadPageRoutes)(pageFilesAll, pageConfigs, pageConfigGlobal, allPageIds);
173
- (0, assertV1Design_js_1.assertV1Design)(
174
- // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
175
- pageConfigs.length > 0, pageFilesAll);
176
- const renderContext = {
177
- pageFilesAll: pageFilesAll,
178
- pageConfigs,
179
- pageConfigGlobal,
180
- allPageIds: allPageIds,
181
- pageRoutes,
182
- onBeforeRouteHook
183
- };
184
- return renderContext;
185
- }
@@ -13,7 +13,8 @@ const picocolors_1 = __importDefault(require("@brillout/picocolors"));
13
13
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)(); // Don't bloat the client
14
14
  // TODO/next-major-release: update
15
15
  const configSrc = '[vite.config.js > vike({ redirects })]';
16
- function resolveRedirects(redirects, urlPathname) {
16
+ function resolveRedirects(redirectsAll, urlPathname) {
17
+ const redirects = merge(redirectsAll);
17
18
  for (const [urlSource, urlTarget] of Object.entries(redirects)) {
18
19
  const urlResolved = resolveRouteStringRedirect(urlSource, urlTarget, urlPathname);
19
20
  if (urlResolved)
@@ -44,3 +45,10 @@ function assertParams(urlSource, urlTarget) {
44
45
  }
45
46
  });
46
47
  }
48
+ function merge(objs) {
49
+ const obj = {};
50
+ objs.forEach((e) => {
51
+ Object.assign(obj, e);
52
+ });
53
+ return obj;
54
+ }