vike 0.4.168 → 0.4.169

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 (178) hide show
  1. package/dist/cjs/node/plugin/plugins/buildConfig.js +10 -2
  2. package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -1
  3. package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -16
  4. package/dist/cjs/node/plugin/plugins/distFileNames.js +7 -1
  5. package/dist/cjs/node/plugin/plugins/envVars.js +1 -5
  6. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +1 -1
  7. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +7 -7
  8. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
  9. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +7 -1
  10. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -14
  11. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +129 -0
  12. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +8 -8
  13. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +52 -12
  14. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
  16. package/dist/cjs/node/plugin/shared/getFilePath.js +50 -49
  17. package/dist/cjs/node/plugin/utils.js +2 -2
  18. package/dist/cjs/node/prerender/runPrerender.js +6 -5
  19. package/dist/cjs/node/prerender/utils.js +2 -1
  20. package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
  21. package/dist/cjs/node/runtime/index-common.js +14 -3
  22. package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
  23. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +25 -14
  24. package/dist/cjs/node/runtime/renderPage/log404/index.js +2 -2
  25. package/dist/cjs/node/runtime/renderPage/logErrorHint.js +1 -1
  26. package/dist/cjs/node/runtime/utils.js +2 -1
  27. package/dist/cjs/node/shared/assertV1Design.js +1 -1
  28. package/dist/cjs/node/shared/getClientEntry.js +2 -2
  29. package/dist/cjs/node/shared/prependEntriesDir.js +1 -0
  30. package/dist/cjs/node/shared/utils.js +0 -1
  31. package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
  32. package/dist/cjs/shared/getPageFiles/getExports.js +8 -15
  33. package/dist/cjs/shared/getPageFiles.js +3 -6
  34. package/dist/cjs/shared/hooks/getHook.js +7 -6
  35. package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +48 -0
  36. package/dist/cjs/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
  37. package/dist/cjs/shared/page-configs/helpers.js +6 -11
  38. package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -1
  39. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
  40. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +11 -6
  41. package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +4 -3
  42. package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +3 -3
  43. package/dist/cjs/shared/route/index.js +2 -2
  44. package/dist/cjs/shared/route/loadPageRoutes.js +12 -10
  45. package/dist/cjs/shared/route/resolveRouteFunction.js +8 -9
  46. package/dist/cjs/shared/route/resolveRouteString.js +5 -16
  47. package/dist/cjs/shared/route/utils.js +0 -1
  48. package/dist/cjs/shared/utils.js +1 -0
  49. package/dist/cjs/utils/assertPathFilesystemAbsolute.js +39 -0
  50. package/dist/cjs/utils/createErrorWithCleanStackTrace.js +1 -7
  51. package/dist/cjs/utils/debug.js +2 -1
  52. package/dist/cjs/utils/findFile.js +2 -1
  53. package/dist/cjs/utils/hasProp.js +9 -5
  54. package/dist/cjs/utils/injectRollupInputs.js +2 -1
  55. package/dist/cjs/utils/isArray.js +8 -0
  56. package/dist/cjs/utils/isArrayOfStrings.js +8 -0
  57. package/dist/cjs/utils/isDev.js +12 -4
  58. package/dist/cjs/utils/isNpmPackage.js +1 -1
  59. package/dist/cjs/utils/isObjectOfStrings.js +8 -0
  60. package/dist/cjs/utils/projectInfo.js +1 -1
  61. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +3 -1
  62. package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +2 -1
  63. package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
  64. package/dist/esm/client/shared/getPageContextSerializedInHtml.d.ts +1 -0
  65. package/dist/esm/client/shared/getPageContextSerializedInHtml.js +1 -0
  66. package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -7
  67. package/dist/esm/node/plugin/plugins/buildConfig.js +9 -1
  68. package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -2
  69. package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +20 -17
  70. package/dist/esm/node/plugin/plugins/distFileNames.js +8 -2
  71. package/dist/esm/node/plugin/plugins/envVars.js +2 -6
  72. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +1 -1
  73. package/dist/esm/node/plugin/plugins/importUserCode/index.js +9 -9
  74. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +2 -2
  75. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
  76. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +4 -3
  77. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +7 -1
  78. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +2 -2
  79. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +12 -15
  80. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +12 -0
  81. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +123 -0
  82. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +8 -8
  83. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +7 -7
  84. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +53 -13
  85. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
  86. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
  87. package/dist/esm/node/plugin/shared/getFilePath.d.ts +11 -5
  88. package/dist/esm/node/plugin/shared/getFilePath.js +49 -48
  89. package/dist/esm/node/plugin/utils.d.ts +2 -2
  90. package/dist/esm/node/plugin/utils.js +2 -2
  91. package/dist/esm/node/prerender/runPrerender.js +6 -5
  92. package/dist/esm/node/prerender/utils.d.ts +2 -1
  93. package/dist/esm/node/prerender/utils.js +2 -1
  94. package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +1 -0
  95. package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
  96. package/dist/esm/node/runtime/index-common.d.ts +0 -4
  97. package/dist/esm/node/runtime/index-common.js +14 -3
  98. package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
  99. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +4 -4
  100. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +27 -16
  101. package/dist/esm/node/runtime/renderPage/log404/index.js +2 -2
  102. package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -2
  103. package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -7
  104. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +16 -16
  105. package/dist/esm/node/runtime/utils.d.ts +2 -1
  106. package/dist/esm/node/runtime/utils.js +2 -1
  107. package/dist/esm/node/shared/assertV1Design.js +1 -1
  108. package/dist/esm/node/shared/getClientEntry.js +1 -1
  109. package/dist/esm/node/shared/prependEntriesDir.js +1 -0
  110. package/dist/esm/node/shared/utils.d.ts +0 -1
  111. package/dist/esm/node/shared/utils.js +0 -1
  112. package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
  113. package/dist/esm/shared/getPageFiles/getExports.d.ts +4 -5
  114. package/dist/esm/shared/getPageFiles/getExports.js +9 -16
  115. package/dist/esm/shared/getPageFiles.d.ts +1 -2
  116. package/dist/esm/shared/getPageFiles.js +1 -3
  117. package/dist/esm/shared/hooks/getHook.js +6 -5
  118. package/dist/esm/shared/page-configs/Config.d.ts +2 -2
  119. package/dist/esm/shared/page-configs/FilePath.d.ts +32 -22
  120. package/dist/esm/shared/page-configs/PageConfig.d.ts +27 -15
  121. package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +11 -0
  122. package/dist/esm/shared/page-configs/getConfigDefinedAt.js +42 -0
  123. package/dist/esm/shared/page-configs/{helpers/getConfigValue.d.ts → getConfigValue.d.ts} +2 -2
  124. package/dist/esm/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
  125. package/dist/esm/shared/page-configs/helpers.d.ts +3 -9
  126. package/dist/esm/shared/page-configs/helpers.js +6 -8
  127. package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +7 -4
  128. package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +2 -2
  129. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
  130. package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +12 -7
  131. package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +5 -4
  132. package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +3 -3
  133. package/dist/esm/shared/route/index.js +2 -2
  134. package/dist/esm/shared/route/loadPageRoutes.d.ts +3 -3
  135. package/dist/esm/shared/route/loadPageRoutes.js +10 -8
  136. package/dist/esm/shared/route/resolveRouteFunction.d.ts +1 -1
  137. package/dist/esm/shared/route/resolveRouteFunction.js +9 -10
  138. package/dist/esm/shared/route/resolveRouteString.d.ts +0 -2
  139. package/dist/esm/shared/route/resolveRouteString.js +5 -16
  140. package/dist/esm/shared/route/utils.d.ts +0 -1
  141. package/dist/esm/shared/route/utils.js +0 -1
  142. package/dist/esm/shared/utils.d.ts +1 -0
  143. package/dist/esm/shared/utils.js +1 -0
  144. package/dist/esm/utils/assertPathFilesystemAbsolute.d.ts +6 -0
  145. package/dist/esm/utils/assertPathFilesystemAbsolute.js +33 -0
  146. package/dist/esm/utils/createErrorWithCleanStackTrace.js +1 -7
  147. package/dist/esm/utils/debug.js +2 -1
  148. package/dist/esm/utils/findFile.js +2 -1
  149. package/dist/esm/utils/hasProp.d.ts +1 -0
  150. package/dist/esm/utils/hasProp.js +9 -5
  151. package/dist/esm/utils/injectRollupInputs.js +2 -1
  152. package/dist/esm/utils/isArray.d.ts +1 -0
  153. package/dist/esm/utils/isArray.js +4 -0
  154. package/dist/esm/utils/isArrayOfStrings.d.ts +2 -0
  155. package/dist/esm/utils/isArrayOfStrings.js +5 -0
  156. package/dist/esm/utils/isDev.d.ts +3 -0
  157. package/dist/esm/utils/isDev.js +11 -3
  158. package/dist/esm/utils/isNpmPackage.js +1 -1
  159. package/dist/esm/utils/isObjectOfStrings.d.ts +2 -0
  160. package/dist/esm/utils/isObjectOfStrings.js +5 -0
  161. package/dist/esm/utils/projectInfo.d.ts +2 -2
  162. package/dist/esm/utils/projectInfo.js +1 -1
  163. package/package.json +3 -2
  164. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +0 -136
  165. package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -43
  166. package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +0 -21
  167. package/dist/cjs/utils/isStringRecord.js +0 -7
  168. package/dist/cjs/utils/mergeCumulativeValues.js +0 -21
  169. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +0 -13
  170. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +0 -130
  171. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +0 -7
  172. package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -37
  173. package/dist/esm/utils/assertPathIsFilesystemAbsolute.d.ts +0 -3
  174. package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +0 -15
  175. package/dist/esm/utils/isStringRecord.d.ts +0 -1
  176. package/dist/esm/utils/isStringRecord.js +0 -3
  177. package/dist/esm/utils/mergeCumulativeValues.d.ts +0 -2
  178. package/dist/esm/utils/mergeCumulativeValues.js +0 -18
@@ -5,7 +5,8 @@ const error_page_js_1 = require("../error-page.js");
5
5
  const utils_js_1 = require("./utils.js");
6
6
  const deduceRouteStringFromFilesystemPath_js_1 = require("./deduceRouteStringFromFilesystemPath.js");
7
7
  const utils_js_2 = require("../utils.js");
8
- const helpers_js_1 = require("../page-configs/helpers.js");
8
+ const getConfigValue_js_1 = require("../page-configs/getConfigValue.js");
9
+ const getConfigDefinedAt_js_1 = require("../page-configs/getConfigDefinedAt.js");
9
10
  const resolveRouteFunction_js_1 = require("./resolveRouteFunction.js");
10
11
  const getHook_js_1 = require("../hooks/getHook.js");
11
12
  async function loadPageRoutes(
@@ -30,28 +31,29 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
30
31
  let pageRoute = null;
31
32
  {
32
33
  const configName = 'route';
33
- const configValue = (0, helpers_js_1.getConfigValue)(pageConfig, configName);
34
+ const configValue = (0, getConfigValue_js_1.getConfigValue)(pageConfig, configName);
34
35
  if (configValue) {
35
36
  const route = configValue.value;
36
- const definedAt = (0, helpers_js_1.getDefinedAtString)(configValue.definedAt, configName);
37
+ (0, utils_js_1.assert)(configValue.definedAtData);
38
+ const definedAtString = (0, getConfigDefinedAt_js_1.getDefinedAtString)(configValue.definedAtData, configName);
37
39
  if (typeof route === 'string') {
38
40
  pageRoute = {
39
41
  pageId,
40
42
  comesFromV1PageConfig,
41
43
  routeString: route,
42
- routeDefinedAt: definedAt,
44
+ routeDefinedAtString: definedAtString,
43
45
  routeType: 'STRING'
44
46
  };
45
47
  }
46
48
  else {
47
49
  (0, utils_js_1.assert)((0, utils_js_2.isCallable)(route));
48
- if ((0, helpers_js_1.getConfigValue)(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
50
+ if ((0, getConfigValue_js_1.getConfigValue)(pageConfig, 'iKnowThePerformanceRisksOfAsyncRouteFunctions', 'boolean'))
49
51
  (0, resolveRouteFunction_js_1.warnDeprecatedAllowKey)();
50
52
  pageRoute = {
51
53
  pageId,
52
54
  comesFromV1PageConfig,
53
55
  routeFunction: route,
54
- routeDefinedAt: definedAt,
56
+ routeDefinedAtString: definedAtString,
55
57
  routeType: 'FUNCTION'
56
58
  };
57
59
  }
@@ -67,7 +69,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
67
69
  routeFilesystemDefinedBy: definedBy,
68
70
  comesFromV1PageConfig,
69
71
  routeString,
70
- routeDefinedAt: null,
72
+ routeDefinedAtString: null,
71
73
  routeType: 'FILESYSTEM'
72
74
  };
73
75
  }
@@ -92,7 +94,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
92
94
  pageId,
93
95
  comesFromV1PageConfig,
94
96
  routeString,
95
- routeDefinedAt: null,
97
+ routeDefinedAtString: null,
96
98
  routeFilesystemDefinedBy: `${pageId}.page.*`,
97
99
  routeType: 'FILESYSTEM'
98
100
  });
@@ -107,7 +109,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
107
109
  pageId,
108
110
  comesFromV1PageConfig,
109
111
  routeString,
110
- routeDefinedAt: filePath,
112
+ routeDefinedAtString: filePath,
111
113
  routeType: 'STRING'
112
114
  });
113
115
  return;
@@ -124,7 +126,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
124
126
  pageId,
125
127
  comesFromV1PageConfig,
126
128
  routeFunction,
127
- routeDefinedAt: filePath,
129
+ routeDefinedAtString: filePath,
128
130
  routeType: 'FUNCTION'
129
131
  });
130
132
  return;
@@ -7,10 +7,10 @@ exports.warnDeprecatedAllowKey = exports.assertSyncRouting = exports.assertRoute
7
7
  const addUrlComputedProps_js_1 = require("../addUrlComputedProps.js");
8
8
  const utils_js_1 = require("./utils.js");
9
9
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
10
- async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt) {
10
+ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAtString) {
11
11
  (0, addUrlComputedProps_js_1.assertPageContextUrlComputedProps)(pageContext);
12
12
  let result = routeFunction(pageContext);
13
- assertSyncRouting(result, `The Route Function ${routeDefinedAt}`);
13
+ assertSyncRouting(result, `The Route Function ${routeDefinedAtString}`);
14
14
  // TODO/v1-release: make resolveRouteFunction() and route() sync
15
15
  //* We disallow asynchronous routing, because we need to check whether a link is a Vike link in a synchronous fashion before calling ev.preventDefault() in the 'click' event listener
16
16
  result = await result;
@@ -21,11 +21,11 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
21
21
  if (result === true) {
22
22
  result = {};
23
23
  }
24
- (0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result), `The Route Function ${routeDefinedAt} should return a boolean or a plain JavaScript object (but it's ${picocolors_1.default.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
24
+ (0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result), `The Route Function ${routeDefinedAtString} should return a boolean or a plain JavaScript object (but it's ${picocolors_1.default.cyan(`typeof result === ${JSON.stringify(typeof result)}`)} instead)`);
25
25
  // AFAICT this return interface is superfluous. Should we soft-deprecate it and remove it?
26
26
  if ('match' in result) {
27
27
  const { match } = result;
28
- (0, utils_js_1.assertUsage)(typeof match === 'boolean', `The ${picocolors_1.default.cyan('match')} value returned by the Route Function ${routeDefinedAt} should be a boolean.`);
28
+ (0, utils_js_1.assertUsage)(typeof match === 'boolean', `The ${picocolors_1.default.cyan('match')} value returned by the Route Function ${routeDefinedAtString} should be a boolean.`);
29
29
  if (!match) {
30
30
  return null;
31
31
  }
@@ -33,14 +33,14 @@ async function resolveRouteFunction(routeFunction, pageContext, routeDefinedAt)
33
33
  let precedence = null;
34
34
  if ('precedence' in result) {
35
35
  precedence = result.precedence;
36
- (0, utils_js_1.assertUsage)(typeof precedence === 'number', `The ${picocolors_1.default.cyan('precedence')} value returned by the Route Function ${routeDefinedAt} should be a number.`);
36
+ (0, utils_js_1.assertUsage)(typeof precedence === 'number', `The ${picocolors_1.default.cyan('precedence')} value returned by the Route Function ${routeDefinedAtString} should be a number.`);
37
37
  }
38
- assertRouteParams(result, `The ${picocolors_1.default.cyan('routeParams')} object returned by the Route Function ${routeDefinedAt} should`);
38
+ assertRouteParams(result, `The ${picocolors_1.default.cyan('routeParams')} object returned by the Route Function ${routeDefinedAtString} should`);
39
39
  const routeParams = result.routeParams || {};
40
40
  (0, utils_js_1.assertUsage)(!('pageContext' in result), `Providing ${picocolors_1.default.cyan('pageContext')} in Route Functions is prohibited, see https://vike.dev/route-function#cannot-provide-pagecontext`);
41
41
  (0, utils_js_1.assert)((0, utils_js_1.isPlainObject)(routeParams));
42
42
  Object.keys(result).forEach((key) => {
43
- (0, utils_js_1.assertUsage)(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${routeDefinedAt} returned an object with an unknown property ${picocolors_1.default.cyan(key)} (the known properties are ${picocolors_1.default.cyan('match')}, ${picocolors_1.default.cyan('routeParams')}, and ${picocolors_1.default.cyan('precedence')})`);
43
+ (0, utils_js_1.assertUsage)(key === 'match' || key === 'routeParams' || key === 'precedence', `The Route Function ${routeDefinedAtString} returned an object with an unknown property ${picocolors_1.default.cyan(key)} (the known properties are ${picocolors_1.default.cyan('match')}, ${picocolors_1.default.cyan('routeParams')}, and ${picocolors_1.default.cyan('precedence')})`);
44
44
  });
45
45
  return {
46
46
  precedence,
@@ -65,7 +65,6 @@ function assertRouteParams(result, errPrefix) {
65
65
  return;
66
66
  }
67
67
  (0, utils_js_1.assert)(errPrefix.endsWith(' should'));
68
- (0, utils_js_1.assertUsage)((0, utils_js_1.isPlainObject)(result.routeParams), `${errPrefix} be a plain JavaScript object.`);
69
- (0, utils_js_1.assertUsage)((0, utils_js_1.isStringRecord)(result.routeParams), `${errPrefix} only hold string values.`);
68
+ (0, utils_js_1.assertUsage)((0, utils_js_1.hasProp)(result, 'routeParams', 'string{}'), `${errPrefix} be an object holding string values.`);
70
69
  }
71
70
  exports.assertRouteParams = assertRouteParams;
@@ -26,12 +26,7 @@ function resolveRouteString(routeString, urlPathname) {
26
26
  return '[^/]+';
27
27
  }
28
28
  if (segment.glob) {
29
- if (segment.isLastDir) {
30
- return '|/.*';
31
- }
32
- else {
33
- return '.*';
34
- }
29
+ return '.*';
35
30
  }
36
31
  // segment.static
37
32
  return (0, utils_js_1.escapeRegex)(segment.static);
@@ -61,8 +56,6 @@ function resolveRouteString(routeString, urlPathname) {
61
56
  }
62
57
  if (segment.glob) {
63
58
  const param = `*${hasMultipleGlobs ? ++globIdx : ''}`;
64
- if (segment.isLastDir)
65
- val = val.slice(1);
66
59
  routeParams[param] = val;
67
60
  }
68
61
  });
@@ -82,21 +75,17 @@ function parseRouteString(routeString) {
82
75
  };
83
76
  const parts = routeString.split('/');
84
77
  parts.forEach((s, i) => {
85
- const isFirst = i === 0;
86
- const isLast = i === parts.length - 1;
78
+ if (i !== 0)
79
+ pushStatic('/');
87
80
  if (isParam(s)) {
88
81
  (0, utils_js_1.assertWarning)(!s.startsWith(PARAM_TOKEN_OLD), `Outdated Route String ${highlight(routeString)}, use ${highlight(routeString.split(PARAM_TOKEN_OLD).join(PARAM_TOKEN_NEW))} instead`, { onlyOnce: true });
89
- if (!isFirst)
90
- pushStatic('/');
91
82
  segments.push({ param: s.slice(1) });
92
83
  }
93
84
  else {
94
- if (s === '*' && isLast && routeString !== '*' && routeString !== '/*') {
95
- segments.push({ glob: true, isLastDir: true });
85
+ if (s === '*' && i === parts.length - 1 && routeString !== '*' && routeString !== '/*') {
86
+ segments.push({ glob: true });
96
87
  }
97
88
  else {
98
- if (!isFirst)
99
- pushStatic('/');
100
89
  s.split('*').forEach((s, i) => {
101
90
  if (i !== 0)
102
91
  segments.push({ glob: true });
@@ -31,7 +31,6 @@ __exportStar(require("../../utils/isPromise.js"), exports);
31
31
  __exportStar(require("../../utils/isPlainObject.js"), exports);
32
32
  __exportStar(require("../../utils/objectAssign.js"), exports);
33
33
  __exportStar(require("../../utils/slice.js"), exports);
34
- __exportStar(require("../../utils/isStringRecord.js"), exports);
35
34
  __exportStar(require("../../utils/unique.js"), exports);
36
35
  __exportStar(require("../../utils/isBrowser.js"), exports);
37
36
  __exportStar(require("../../utils/parseUrl.js"), exports);
@@ -40,3 +40,4 @@ __exportStar(require("../utils/isPromise.js"), exports);
40
40
  __exportStar(require("../utils/checkType.js"), exports);
41
41
  __exportStar(require("../utils/getValuePrintable.js"), exports);
42
42
  __exportStar(require("../utils/escapeRegex.js"), exports);
43
+ __exportStar(require("../utils/isArray.js"), exports);
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isPathFilesystemAbsolute = exports.assertPathFilesystemAbsolute = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const assert_js_1 = require("./assert.js");
9
+ const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
10
+ /** Assert path is absolute starting from the filesystem root. */
11
+ function assertPathFilesystemAbsolute(p) {
12
+ // The assert is "eventually reliable":
13
+ // - For Windows users, the assert is correct.
14
+ // - For Linux users assertPathFilesystemAbsolute() will erroneously succeed if `p` is a path absolute from the user root dir.
15
+ // - But that's okay because the assertion will eventually fail for Windows users.
16
+ (0, assert_js_1.assert)(isPathFilesystemAbsolute(p));
17
+ }
18
+ exports.assertPathFilesystemAbsolute = assertPathFilesystemAbsolute;
19
+ /** Whether path is absolute starting from the filesystem root. Isn't reliable for Linux users: isPathFilesystemAbsolute() returns `true` for paths absolute from the user root dir. */
20
+ function isPathFilesystemAbsolute(p) {
21
+ (0, filesystemPathHandling_js_1.assertPosixPath)(p);
22
+ (0, assert_js_1.assert)(!p.startsWith('/@fs/'));
23
+ if (process.platform !== 'win32') {
24
+ // - For linux users, there doesn't seem to be a reliable way to distinguish between:
25
+ // - File path absolute starting from filesystem root, e.g. /home/rom/code/my-app/pages/about/+Page.js
26
+ // - File path absolute starting from user root dir (Vite's `config.root`), e.g. /pages/about/+Page.js
27
+ // - Checking whether `p` starts with the first directory of process.cwd() (or `userRootDir`) can be erroneous, most notably when using docker: https://github.com/vikejs/vike/issues/703
28
+ // - Using require.resolve() would be a solution but probably too slow?
29
+ return p.startsWith('/');
30
+ }
31
+ else {
32
+ const yes = path_1.default.win32.isAbsolute(p);
33
+ // Ensure isPathFilesystemAbsolute() returns `false` if path is absolute starting from the user root dir (see comments above).
34
+ if (yes)
35
+ (0, assert_js_1.assert)(!p.startsWith('/'));
36
+ return yes;
37
+ }
38
+ }
39
+ exports.isPathFilesystemAbsolute = isPathFilesystemAbsolute;
@@ -3,13 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createErrorWithCleanStackTrace = void 0;
4
4
  const isNodeJS_js_1 = require("./isNodeJS.js");
5
5
  function createErrorWithCleanStackTrace(errorMessage, numberOfStackTraceLinesToRemove) {
6
- let err;
7
- {
8
- var stackTraceLimit__original = Error.stackTraceLimit;
9
- Error.stackTraceLimit = Infinity;
10
- err = new Error(errorMessage);
11
- Error.stackTraceLimit = stackTraceLimit__original;
12
- }
6
+ const err = new Error(errorMessage);
13
7
  if ((0, isNodeJS_js_1.isNodeJS)()) {
14
8
  err.stack = clean(err.stack, numberOfStackTraceLinesToRemove);
15
9
  }
@@ -11,6 +11,7 @@ const assert_js_1 = require("./assert.js");
11
11
  const checkType_js_1 = require("./checkType.js");
12
12
  const getTerminWidth_js_1 = require("./getTerminWidth.js");
13
13
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
14
+ const isArray_js_1 = require("./isArray.js");
14
15
  // Avoid this to be loaded in the browser. For isomorphic code: instead of `import { createDebugger } from './utils.js'`, use `globalThis.createDebugger()`.
15
16
  (0, assert_js_1.assert)(!(0, isBrowser_js_1.isBrowser)());
16
17
  globalThis.__brillout_debug_createDebugger = createDebugger;
@@ -87,7 +88,7 @@ function formatMsg(info, options, padding, position) {
87
88
  if (typeof info === 'string') {
88
89
  str += info;
89
90
  }
90
- else if (Array.isArray(info)) {
91
+ else if ((0, isArray_js_1.isArray)(info)) {
91
92
  if (info.length === 0) {
92
93
  str += options.serialization?.emptyArray ?? '[]';
93
94
  }
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.findFile = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
+ const isArray_js_1 = require("./isArray.js");
9
10
  function findFile(arg, cwd) {
10
- const filenames = Array.isArray(arg) ? arg : [arg];
11
+ const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
11
12
  let dir = cwd;
12
13
  while (true) {
13
14
  for (const filename of filenames) {
@@ -5,8 +5,9 @@ exports.hasProp = void 0;
5
5
  // - https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABDAzgFQJ4AcCmdgAUAbgIYA2IOAXIiWBgDSJTbWIDkARnHGTnewCUNUhRzIUibr35gA3AFgAUKEiwEEzLnzFylGnUbNWNdmBABbTjgBOQkXvGpE5q7cUrw0eElRa8hKL6tPRMLLimKFA2MGAA5vaIQU6SUTHxHqreGn6sOskGocYRHOAA1mBwAO5gickSiOWVNZle6r7oeYGOhUbhbGmxcYgAvKVgFdW1wlI8fHSIAN7KiMiExeIjW+OTNeyIgksrq4g2OFAgNkjRlMcAvsdnF1cb+EmOo9v9Hg9KyhAIKK0GhNKajRAAFgATMplCQUChbFACLltIQSEwzJZrHZBIJ-oCZAA6MhwOIEEj4v6eNQ+WgIpEEAFgAAmMHaIImzTAM3hiJsUEkzLZ7SOShOa0QTIQIp8hyelzAx1WUAAFjZqi4cFVEABRGwamwEdgAQQZArpADESDAyEJlHcgA
6
6
  const isCallable_js_1 = require("./isCallable.js");
7
7
  const isObject_js_1 = require("./isObject.js");
8
- // prettier-ignore
9
- // biome-ignore format:
8
+ const isArrayOfStrings_js_1 = require("./isArrayOfStrings.js");
9
+ const isObjectOfStrings_js_1 = require("./isObjectOfStrings.js");
10
+ const isArray_js_1 = require("./isArray.js");
10
11
  function hasProp(obj, prop, type = 'unknown') {
11
12
  if (!(0, isObject_js_1.isObject)(obj))
12
13
  return false;
@@ -18,18 +19,21 @@ function hasProp(obj, prop, type = 'unknown') {
18
19
  }
19
20
  const propValue = obj[prop];
20
21
  if (type === 'array') {
21
- return Array.isArray(propValue);
22
+ return (0, isArray_js_1.isArray)(propValue);
22
23
  }
23
24
  if (type === 'object') {
24
25
  return (0, isObject_js_1.isObject)(propValue);
25
26
  }
26
27
  if (type === 'string[]') {
27
- return Array.isArray(propValue) && propValue.every(el => typeof el === 'string');
28
+ return (0, isArrayOfStrings_js_1.isArrayOfStrings)(propValue);
29
+ }
30
+ if (type === 'string{}') {
31
+ return (0, isObjectOfStrings_js_1.isObjectOfStrings)(propValue);
28
32
  }
29
33
  if (type === 'function') {
30
34
  return (0, isCallable_js_1.isCallable)(propValue);
31
35
  }
32
- if (Array.isArray(type)) {
36
+ if ((0, isArray_js_1.isArray)(type)) {
33
37
  return typeof propValue === 'string' && type.includes(propValue);
34
38
  }
35
39
  if (type === 'null') {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeRollupInput = exports.injectRollupInputs = void 0;
4
4
  const assert_js_1 = require("./assert.js");
5
5
  const isObject_js_1 = require("./isObject.js");
6
+ const isArray_js_1 = require("./isArray.js");
6
7
  function injectRollupInputs(inputsNew, config) {
7
8
  const inputsCurrent = normalizeRollupInput(config.build.rollupOptions.input);
8
9
  const input = {
@@ -20,7 +21,7 @@ function normalizeRollupInput(input) {
20
21
  if (typeof input === 'string') {
21
22
  input = [input];
22
23
  }
23
- if (Array.isArray(input)) {
24
+ if ((0, isArray_js_1.isArray)(input)) {
24
25
  return Object.fromEntries(input.map((input) => [input, input]));
25
26
  }
26
27
  (0, assert_js_1.assert)((0, isObject_js_1.isObject)(input));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArray = void 0;
4
+ // Typesafe Array.isArray() — asserting unknown[] instead of any[]
5
+ function isArray(value) {
6
+ return Array.isArray(value);
7
+ }
8
+ exports.isArray = isArray;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isArrayOfStrings = void 0;
4
+ const isArray_js_1 = require("./isArray.js");
5
+ function isArrayOfStrings(val) {
6
+ return (0, isArray_js_1.isArray)(val) && val.every((v) => typeof v === 'string');
7
+ }
8
+ exports.isArrayOfStrings = isArrayOfStrings;
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDev2 = exports.isDev1_onConfigureServer = exports.isDev1 = void 0;
4
- // There isn't any reliable way to test whether Vite is ran as dev/build/preview/optimizeDep
5
- // - Failed attempt to make a PR: https://github.com/brillout/vite/tree/fix/config-operation
3
+ exports.isDev3 = exports.isDev2 = exports.isDev1_onConfigureServer = exports.isDev1 = void 0;
4
+ function isDev3(configEnv) {
5
+ const { isPreview, command } = configEnv;
6
+ if (command !== 'serve')
7
+ return false;
8
+ if (typeof isPreview === 'boolean')
9
+ return !isPreview;
10
+ // isPreview is undefined in older Vite versions, see https://github.com/vitejs/vite/commit/93fce55
11
+ return null;
12
+ }
13
+ exports.isDev3 = isDev3;
6
14
  // ********
7
- // Method 1 - most reliable
15
+ // Method 1 - reliable
8
16
  // ********
9
17
  const assert_js_1 = require("./assert.js");
10
18
  const getGlobalObject_js_1 = require("./getGlobalObject.js");
@@ -15,7 +15,7 @@ function assertIsNpmPackageImport(str) {
15
15
  (0, assert_js_1.assert)(isNpmPackageImport(str, {
16
16
  // If `str` is a path alias that looks like an npm package => assertIsNpmPackageImport() is erroneous but that's okay because the assertion will eventually fail for some other user using a disambiguated path alias.
17
17
  cannotBePathAlias: true
18
- }));
18
+ }), str);
19
19
  }
20
20
  exports.assertIsNpmPackageImport = assertIsNpmPackageImport;
21
21
  function isNpmPackageName(str) {
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isObjectOfStrings = void 0;
4
+ const isObject_js_1 = require("./isObject.js");
5
+ function isObjectOfStrings(val) {
6
+ return (0, isObject_js_1.isObject)(val) && Object.values(val).every((v) => typeof v === 'string');
7
+ }
8
+ exports.isObjectOfStrings = isObjectOfStrings;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = exports.projectInfo = void 0;
4
- const PROJECT_VERSION = '0.4.168';
4
+ const PROJECT_VERSION = '0.4.169';
5
5
  exports.PROJECT_VERSION = PROJECT_VERSION;
6
6
  const projectInfo = {
7
7
  projectName: 'Vike',
@@ -13,7 +13,9 @@ type PageContextSerialized = {
13
13
  _pageId: string;
14
14
  _hasPageContextFromServer: true;
15
15
  };
16
- declare function getPageContextFromHooks_serialized(): PageContextSerialized;
16
+ declare function getPageContextFromHooks_serialized(): PageContextSerialized & {
17
+ routeParams: Record<string, string>;
18
+ };
17
19
  declare function getPageContextFromHooks_isHydration(pageContext: PageContextSerialized & PageContext & PageContextExports): Promise<{
18
20
  isHydration: true;
19
21
  _hasPageContextFromClient: false;
@@ -9,7 +9,8 @@ import { getHook } from '../../shared/hooks/getHook.js';
9
9
  import { preparePageContextForUserConsumptionClientSide } from '../shared/preparePageContextForUserConsumptionClientSide.js';
10
10
  import { removeBuiltInOverrides } from './getPageContext/removeBuiltInOverrides.js';
11
11
  import { getPageContextRequestUrl } from '../../shared/getPageContextRequestUrl.js';
12
- import { getConfigValue, getPageConfig } from '../../shared/page-configs/helpers.js';
12
+ import { getPageConfig } from '../../shared/page-configs/helpers.js';
13
+ import { getConfigValue } from '../../shared/page-configs/getConfigValue.js';
13
14
  import { assertOnBeforeRenderHookReturn } from '../../shared/assertOnBeforeRenderHookReturn.js';
14
15
  import { executeGuardHook } from '../../shared/route/executeGuardHook.js';
15
16
  import { AbortRender, isAbortPageContext } from '../../shared/route/abort.js';
@@ -1,6 +1,7 @@
1
1
  export { getPageContext };
2
2
  declare function getPageContext(): Promise<{
3
3
  _pageId: string;
4
+ routeParams: Record<string, string>;
4
5
  } & {
5
6
  isHydration: true;
6
7
  isBackwardNavigation: null;
@@ -1,4 +1,5 @@
1
1
  export { getPageContextSerializedInHtml };
2
2
  declare function getPageContextSerializedInHtml(): {
3
3
  _pageId: string;
4
+ routeParams: Record<string, string>;
4
5
  };
@@ -15,5 +15,6 @@ function getPageContextSerializedInHtml() {
15
15
  assert(pageContextJson);
16
16
  const pageContextSerializedInHtml = parse(pageContextJson);
17
17
  assert(hasProp(pageContextSerializedInHtml, '_pageId', 'string'));
18
+ assert(hasProp(pageContextSerializedInHtml, 'routeParams', 'string{}'));
18
19
  return pageContextSerializedInHtml;
19
20
  }
@@ -1,6 +1,6 @@
1
1
  export { loadUserFilesClientSide };
2
2
  export { isErrorFetchingStaticAssets };
3
- import { getPageFilesClientSide, getExports } from '../../shared/getPageFiles.js';
3
+ import { getPageFilesClientSide, getPageContextExports } from '../../shared/getPageFiles.js';
4
4
  import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
5
5
  import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
6
6
  const stamp = '__whileFetchingAssets';
@@ -28,13 +28,9 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
28
28
  }
29
29
  throw err;
30
30
  }
31
- const { config, configEntries, exports, exportsAll, pageExports } = getExports(pageFilesClientSide, pageConfigLoaded);
31
+ const pageContextExports = getPageContextExports(pageFilesClientSide, pageConfigLoaded);
32
32
  const pageContextAddendum = {
33
- config,
34
- configEntries,
35
- exports,
36
- exportsAll,
37
- pageExports,
33
+ ...pageContextExports,
38
34
  _pageFilesLoaded: pageFilesClientSide
39
35
  };
40
36
  return pageContextAddendum;
@@ -4,7 +4,7 @@ export { analyzeClientEntries };
4
4
  export { manifestTempFile };
5
5
  import { assert, resolveOutDir, viteIsSSR, addOnBeforeLogHook, removeFileExtention, unique, assertUsage, injectRollupInputs, normalizeRollupInput, getOutDirs, assertNodeEnv_build, assertIsNpmPackageImport } from '../utils.js';
6
6
  import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
7
- import { getConfigValue } from '../../../shared/page-configs/helpers.js';
7
+ import { getConfigValue } from '../../../shared/page-configs/getConfigValue.js';
8
8
  import { findPageFiles } from '../shared/findPageFiles.js';
9
9
  import { getConfigVike } from '../../shared/getConfigVike.js';
10
10
  import { getVirtualFileIdPageConfigValuesAll } from '../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
@@ -227,7 +227,15 @@ function getEntryFromPageConfig(pageConfig, isForClientSide) {
227
227
  let { pageId } = pageConfig;
228
228
  const entryTarget = getVirtualFileIdPageConfigValuesAll(pageId, isForClientSide);
229
229
  let entryName = pageId;
230
+ // Avoid:
231
+ // ```
232
+ // dist/client/assets/entries/.Dp9wM6PK.js
233
+ // dist/server/entries/.mjs
234
+ // ```
235
+ if (entryName === '/')
236
+ entryName = 'root';
230
237
  entryName = prependEntriesDir(entryName);
238
+ assert(!entryName.endsWith('/'));
231
239
  return { entryName, entryTarget };
232
240
  }
233
241
  function resolve(filePath) {
@@ -1,5 +1,5 @@
1
1
  export { assertResolveAlias };
2
- import { assert, assertUsage, assertWarning, isValidPathAlias } from '../../utils.js';
2
+ import { assert, assertUsage, assertWarning, isArray, isValidPathAlias } from '../../utils.js';
3
3
  import pc from '@brillout/picocolors';
4
4
  // Recommend users to avoid un-distinguishable path aliases.
5
5
  // There are a lot of libraries that don't or cannot follow that recommendation, for example:
@@ -74,7 +74,7 @@ function assertResolveAlias(config) {
74
74
  }
75
75
  function getAliases(config) {
76
76
  const { alias } = config.resolve;
77
- if (!Array.isArray(alias)) {
77
+ if (!isArray(alias)) {
78
78
  return [alias];
79
79
  }
80
80
  else {
@@ -1,6 +1,6 @@
1
1
  export { determineOptimizeDeps };
2
2
  import { findPageFiles } from '../../shared/findPageFiles.js';
3
- import { assert, assertIsNpmPackageImport, createDebugger, unique } from '../../utils.js';
3
+ import { assert, assertIsNpmPackageImport, createDebugger, isArray, unique } from '../../utils.js';
4
4
  import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
5
5
  import { getConfigValueSourcesNotOverriden } from '../../shared/getConfigValueSourcesNotOverriden.js';
6
6
  import { analyzeClientEntries } from '../buildConfig.js';
@@ -32,28 +32,32 @@ async function determineOptimizeDeps(config, isDev) {
32
32
  async function getPageDeps(config, pageConfigs, isDev) {
33
33
  let entries = [];
34
34
  let include = [];
35
+ const addEntry = (e) => {
36
+ assert(e);
37
+ entries.push(e);
38
+ };
39
+ const addInclude = (e) => {
40
+ assert(e);
41
+ // Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
42
+ assertIsNpmPackageImport(e);
43
+ include.push(e);
44
+ };
35
45
  // V1 design
36
46
  {
37
47
  pageConfigs.forEach((pageConfig) => {
38
48
  getConfigValueSourcesNotOverriden(pageConfig).forEach((configValueSource) => {
39
49
  if (!configValueSource.valueIsImportedAtRuntime)
40
50
  return;
41
- const { definedAt, configEnv } = configValueSource;
51
+ const { definedAtFilePath, configEnv } = configValueSource;
42
52
  if (!configEnv.client)
43
53
  return;
44
- if (definedAt.filePathAbsoluteUserRootDir !== null) {
45
- const { filePathAbsoluteFilesystem } = definedAt;
46
- assert(filePathAbsoluteFilesystem);
47
- // Surprisingly Vite expects entries to be absolute paths
48
- entries.push(filePathAbsoluteFilesystem);
54
+ if (definedAtFilePath.filePathAbsoluteUserRootDir !== null) {
55
+ // Vite expects entries to be filesystem absolute paths (surprisingly so).
56
+ addEntry(definedAtFilePath.filePathAbsoluteFilesystem);
49
57
  }
50
58
  else {
51
- // Adding definedAt.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
52
- const { importPathAbsolute } = definedAt;
53
- assert(importPathAbsolute); // Help TS
54
- // Shouldn't be a path alias, as path aliases would need to be added to config.optimizeDeps.entries instead of config.optimizeDeps.include
55
- assertIsNpmPackageImport(importPathAbsolute);
56
- include.push(importPathAbsolute);
59
+ // Adding definedAtFilePath.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
60
+ addInclude(definedAtFilePath.importPathAbsolute);
57
61
  }
58
62
  });
59
63
  });
@@ -65,8 +69,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
65
69
  pageFiles.forEach((filePathAbsoluteUserRootDir) => {
66
70
  const entry = getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir });
67
71
  const { filePathAbsoluteFilesystem } = entry;
68
- assert(filePathAbsoluteFilesystem);
69
- entries.push(filePathAbsoluteFilesystem);
72
+ addEntry(filePathAbsoluteFilesystem);
70
73
  });
71
74
  }
72
75
  entries = unique(entries);
@@ -83,7 +86,7 @@ function getVirtualFiles(config, pageConfigs) {
83
86
  return entriesVirtualFiles;
84
87
  }
85
88
  function normalizeEntries(entries) {
86
- if (Array.isArray(entries))
89
+ if (isArray(entries))
87
90
  return entries;
88
91
  if (typeof entries === 'string')
89
92
  return [entries];
@@ -92,7 +95,7 @@ function normalizeEntries(entries) {
92
95
  assert(false);
93
96
  }
94
97
  function normalizeInclude(include) {
95
- if (Array.isArray(include))
98
+ if (isArray(include))
96
99
  return include;
97
100
  if (include === undefined)
98
101
  return [];