vike 0.4.160 → 0.4.161-commit-0e9c635

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/node/cli/bin.js +5 -0
  2. package/dist/cjs/node/client/router.js +4 -2
  3. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -2
  4. package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +148 -0
  5. package/dist/cjs/node/plugin/plugins/buildConfig.js +61 -35
  6. package/dist/cjs/node/plugin/plugins/commonConfig.js +5 -13
  7. package/dist/cjs/node/plugin/plugins/config/stemUtils.js +1 -1
  8. package/dist/cjs/node/plugin/plugins/distFileNames.js +9 -1
  9. package/dist/cjs/node/plugin/plugins/envVars.js +6 -2
  10. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +16 -4
  11. package/dist/cjs/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
  12. package/dist/cjs/node/plugin/plugins/importBuild/getVikeManifest.js +1 -21
  13. package/dist/cjs/node/plugin/plugins/importBuild/index.js +5 -8
  14. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +11 -91
  15. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
  16. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +28 -46
  17. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +5 -5
  18. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +33 -0
  19. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +2 -2
  20. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +7 -7
  21. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +21 -27
  22. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +157 -111
  23. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
  24. package/dist/cjs/node/plugin/plugins/setGlobalContext.js +0 -14
  25. package/dist/cjs/node/plugin/shared/rollupSourceMap.js +20 -0
  26. package/dist/cjs/node/plugin/utils.js +3 -2
  27. package/dist/cjs/node/prerender/runPrerender.js +13 -5
  28. package/dist/cjs/node/runtime/globalContext.js +15 -23
  29. package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  30. package/dist/cjs/node/runtime/html/renderHtml.js +1 -1
  31. package/dist/cjs/node/runtime/html/stream.js +2 -2
  32. package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
  33. package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
  34. package/dist/cjs/node/runtime/renderPage/getHttpResponseBody.js +39 -39
  35. package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
  36. package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
  37. package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
  38. package/dist/cjs/node/runtime/renderPage/getPageAssets.js +23 -28
  39. package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  40. package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +81 -43
  41. package/dist/cjs/node/runtime/renderPage/loggerProd.js +3 -3
  42. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +2 -23
  43. package/dist/cjs/node/runtime/utils.js +1 -1
  44. package/dist/cjs/node/shared/assertPluginManifest.js +1 -4
  45. package/dist/cjs/node/shared/assertV1Design.js +26 -0
  46. package/dist/cjs/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +3 -3
  47. package/dist/cjs/node/shared/prependEntriesDir.js +13 -0
  48. package/dist/cjs/node/shared/utils.js +2 -0
  49. package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
  50. package/dist/cjs/shared/route/executeGuardHook.js +3 -2
  51. package/dist/cjs/shared/utils.js +0 -1
  52. package/dist/cjs/utils/assertNodeVersion.js +2 -2
  53. package/dist/cjs/utils/{findUserPackageJsonPath.js → findFile.js} +11 -8
  54. package/dist/cjs/utils/isVersionOrAbove.js +29 -0
  55. package/dist/cjs/utils/nodeEnv.js +23 -1
  56. package/dist/cjs/utils/objectKeys.js +19 -3
  57. package/dist/cjs/utils/projectInfo.js +1 -1
  58. package/dist/cjs/utils/sorter.js +62 -1
  59. package/dist/esm/client/client-routing-runtime/index.d.ts +1 -1
  60. package/dist/esm/client/client-routing-runtime/index.js +1 -1
  61. package/dist/esm/node/cli/bin.js +3 -1
  62. package/dist/esm/node/client/router.d.ts +2 -0
  63. package/dist/esm/node/client/router.js +3 -1
  64. package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -2
  65. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.d.ts +13 -0
  66. package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +142 -0
  67. package/dist/esm/node/plugin/plugins/buildConfig.d.ts +2 -0
  68. package/dist/esm/node/plugin/plugins/buildConfig.js +60 -34
  69. package/dist/esm/node/plugin/plugins/commonConfig.js +6 -14
  70. package/dist/esm/node/plugin/plugins/config/stemUtils.js +2 -2
  71. package/dist/esm/node/plugin/plugins/distFileNames.js +9 -1
  72. package/dist/esm/node/plugin/plugins/envVars.js +6 -2
  73. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +17 -5
  74. package/dist/esm/node/plugin/plugins/extractExportNamesPlugin.js +2 -2
  75. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.d.ts +1 -2
  76. package/dist/esm/node/plugin/plugins/importBuild/getVikeManifest.js +2 -19
  77. package/dist/esm/node/plugin/plugins/importBuild/index.d.ts +6 -1
  78. package/dist/esm/node/plugin/plugins/importBuild/index.js +5 -8
  79. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +13 -93
  80. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -0
  81. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +0 -1
  82. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +1 -5
  83. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +39 -12
  84. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +29 -47
  85. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.js → loadFileAtConfigTime.js} +4 -4
  86. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +5 -0
  87. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +27 -0
  88. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +1 -1
  89. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +1 -1
  90. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.d.ts → transformFileImports.d.ts} +2 -2
  91. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{transformImports.js → transformFileImports.js} +6 -6
  92. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
  93. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +20 -26
  94. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +5 -0
  95. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +155 -109
  96. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -1
  97. package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -15
  98. package/dist/esm/node/plugin/shared/rollupSourceMap.d.ts +14 -0
  99. package/dist/esm/node/plugin/shared/rollupSourceMap.js +17 -0
  100. package/dist/esm/node/plugin/utils.d.ts +3 -2
  101. package/dist/esm/node/plugin/utils.js +3 -2
  102. package/dist/esm/node/prerender/runPrerender.js +15 -7
  103. package/dist/esm/node/runtime/globalContext.d.ts +3 -10
  104. package/dist/esm/node/runtime/globalContext.js +15 -23
  105. package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
  106. package/dist/esm/node/runtime/html/renderHtml.js +1 -1
  107. package/dist/esm/node/runtime/html/stream.js +2 -2
  108. package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
  109. package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -2
  110. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.d.ts +6 -5
  111. package/dist/esm/node/runtime/renderPage/getHttpResponseBody.js +39 -39
  112. package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -5
  113. package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.d.ts +1 -1
  114. package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +6 -7
  115. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.d.ts +1 -1
  116. package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +2 -2
  117. package/dist/esm/node/runtime/renderPage/getPageAssets.js +24 -29
  118. package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
  119. package/dist/esm/node/runtime/renderPage/logErrorHint.d.ts +8 -0
  120. package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError.js → logErrorHint.js} +80 -42
  121. package/dist/esm/node/runtime/renderPage/loggerProd.js +3 -3
  122. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -24
  123. package/dist/esm/node/runtime/utils.d.ts +1 -1
  124. package/dist/esm/node/runtime/utils.js +1 -1
  125. package/dist/esm/node/shared/ViteManifest.d.ts +1 -0
  126. package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
  127. package/dist/esm/node/shared/assertPluginManifest.js +2 -5
  128. package/dist/esm/node/shared/assertV1Design.d.ts +4 -0
  129. package/dist/esm/node/shared/assertV1Design.js +23 -0
  130. package/dist/esm/node/shared/getClientEntry.d.ts +3 -0
  131. package/dist/esm/node/shared/{getClientEntryFilePath.js → getClientEntry.js} +2 -2
  132. package/dist/esm/node/shared/prependEntriesDir.d.ts +2 -0
  133. package/dist/esm/node/shared/prependEntriesDir.js +10 -0
  134. package/dist/esm/node/shared/utils.d.ts +2 -0
  135. package/dist/esm/node/shared/utils.js +2 -0
  136. package/dist/esm/shared/page-configs/Config.d.ts +1 -1
  137. package/dist/esm/shared/page-configs/PageConfig.d.ts +3 -3
  138. package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +53 -26
  139. package/dist/esm/shared/route/executeGuardHook.js +3 -2
  140. package/dist/esm/shared/utils.d.ts +0 -1
  141. package/dist/esm/shared/utils.js +0 -1
  142. package/dist/esm/utils/assertNodeVersion.js +2 -2
  143. package/dist/esm/utils/findFile.d.ts +3 -0
  144. package/dist/esm/utils/findFile.js +21 -0
  145. package/dist/esm/utils/getOutDirs.d.ts +1 -0
  146. package/dist/esm/utils/isVersionOrAbove.d.ts +2 -0
  147. package/dist/esm/utils/isVersionOrAbove.js +26 -0
  148. package/dist/esm/utils/nodeEnv.d.ts +4 -0
  149. package/dist/esm/utils/nodeEnv.js +19 -0
  150. package/dist/esm/utils/objectKeys.d.ts +10 -1
  151. package/dist/esm/utils/objectKeys.js +20 -3
  152. package/dist/esm/utils/projectInfo.d.ts +2 -2
  153. package/dist/esm/utils/projectInfo.js +1 -1
  154. package/dist/esm/utils/sorter.d.ts +59 -0
  155. package/dist/esm/utils/sorter.js +61 -0
  156. package/package.json +2 -2
  157. package/dist/cjs/node/plugin/shared/removeSourceMap.js +0 -12
  158. package/dist/cjs/utils/objectEntries.js +0 -8
  159. package/dist/esm/node/plugin/shared/removeSourceMap.d.ts +0 -7
  160. package/dist/esm/node/plugin/shared/removeSourceMap.js +0 -9
  161. package/dist/esm/node/runtime/renderPage/logHintForCjsEsmError.d.ts +0 -13
  162. package/dist/esm/node/shared/getClientEntryFilePath.d.ts +0 -3
  163. package/dist/esm/utils/findUserPackageJsonPath.d.ts +0 -2
  164. package/dist/esm/utils/findUserPackageJsonPath.js +0 -18
  165. package/dist/esm/utils/objectEntries.d.ts +0 -4
  166. package/dist/esm/utils/objectEntries.js +0 -5
  167. /package/dist/cjs/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
  168. /package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{loadFileConfigEnv.d.ts → loadFileAtConfigTime.d.ts} +0 -0
  169. /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.d.ts +0 -0
  170. /package/dist/esm/node/runtime/renderPage/{logHintForCjsEsmError → logErrorHint}/errors.js +0 -0
@@ -3,6 +3,7 @@ export { envVarsPlugin };
3
3
  export { applyEnvVar };
4
4
  import { loadEnv } from 'vite';
5
5
  import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, getFilePathRelativeToUserRootDir, lowerFirst } from '../utils.js';
6
+ import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
6
7
  function envVarsPlugin() {
7
8
  let envsAll;
8
9
  let config;
@@ -62,8 +63,11 @@ function envVarsPlugin() {
62
63
  // Apply
63
64
  code = applyEnvVar(envName, envVal, code);
64
65
  });
65
- // No need for low-resolution source map since line numbers didn't change. (Does Vite do high-resolution column numbers source mapping?)
66
- return code;
66
+ // Line numbers didn't change.
67
+ // - We only break the column number of a couple of lines, wich is acceptable.
68
+ // - Anyways, I'm not even sure Vite supports high-resolution column number source mapping.
69
+ const ret = sourceMapPassthrough(code);
70
+ return ret;
67
71
  }
68
72
  };
69
73
  }
@@ -1,6 +1,6 @@
1
- // Alternative: use `ssrEmitAssets: true`
2
- // - See https://github.com/vitejs/vite/pull/11430
3
- // This plugin makes client-side bundles include the CSS imports living in server-side-only code.
1
+ // Remove this workaround if the other workaround config.build.ssrEmitAssets turns out to be reliable.
2
+ // - Remove this file then revert this commit: https://github.com/vikejs/vike/commit/805a18974f13420a78fcc30fdd676696e405c3ca
3
+ // Workaround to make client-side bundles include the CSS imports living in server-side-only code.
4
4
  // - This is needed for HTML-only pages, and React Server Components.
5
5
  // - We recommend using the debug flag to get an idea of how this plugin works: `$ DEBUG=vike:extractAssets pnpm exec vite build`. Then have a look at `dist/client/manifest.json` and see how `.page.server.js` entries have zero JavaScript but only CSS.
6
6
  // - This appraoch supports import path aliases `vite.config.js#resolve.alias` https://vitejs.dev/config/#resolve-alias
@@ -11,8 +11,11 @@ import { extractAssetsAddQuery } from '../../shared/extractAssetsQuery.js';
11
11
  import { getConfigVike } from '../../shared/getConfigVike.js';
12
12
  import { isAsset } from '../shared/isAsset.js';
13
13
  import { getImportStatements } from '../shared/parseEsModule.js';
14
- import { removeSourceMap } from '../shared/removeSourceMap.js';
14
+ import { sourceMapRemove } from '../shared/rollupSourceMap.js';
15
15
  import pc from '@brillout/picocolors';
16
+ import { fixServerAssets_isEnabled } from './buildConfig/fixServerAssets.js';
17
+ import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
18
+ import { assertV1Design } from '../../shared/assertV1Design.js';
16
19
  const extractAssetsRE = /(\?|&)extractAssets(?:&|$)/;
17
20
  const rawRE = /(\?|&)raw(?:&|$)/;
18
21
  const urlRE = /(\?|&)url(?:&|$)/;
@@ -23,6 +26,8 @@ const debugEnabled = isDebugEnabled(debugNamespace);
23
26
  function extractAssetsPlugin() {
24
27
  let config;
25
28
  let configVike;
29
+ let vikeConfig;
30
+ let isServerAssetsFixEnabled;
26
31
  return [
27
32
  // This plugin removes all JavaScript from server-side only code, so that only CSS imports remains. (And also satic files imports e.g. `import logoURL from './logo.svg.js'`).
28
33
  {
@@ -34,13 +39,18 @@ function extractAssetsPlugin() {
34
39
  if (!extractAssetsRE.test(id)) {
35
40
  return;
36
41
  }
42
+ if (isServerAssetsFixEnabled) {
43
+ // I'm guessing isServerAssetsFixEnabled can only be true when mixing both designs: https://github.com/vikejs/vike/issues/1480
44
+ assertV1Design(true, vikeConfig.pageConfigs);
45
+ assert(false);
46
+ }
37
47
  assert(configVike.includeAssetsImportedByServer);
38
48
  assert(!viteIsSSR_options(options));
39
49
  const importStatements = await getImportStatements(src);
40
50
  const moduleNames = getImportedModules(importStatements);
41
51
  const code = moduleNames.map((moduleName) => `import '${moduleName}';`).join('\n');
42
52
  debugTransformResult(id, code, importStatements);
43
- return removeSourceMap(code);
53
+ return sourceMapRemove(code);
44
54
  }
45
55
  },
46
56
  // This plugin appends `?extractAssets` to module IDs
@@ -131,6 +141,8 @@ function extractAssetsPlugin() {
131
141
  async configResolved(config_) {
132
142
  configVike = await getConfigVike(config_);
133
143
  config = config_;
144
+ vikeConfig = await getVikeConfig(config, false);
145
+ isServerAssetsFixEnabled = fixServerAssets_isEnabled() && (await isV1Design(config, false));
134
146
  },
135
147
  load(id) {
136
148
  if (!isVirtualFileId(id))
@@ -3,7 +3,7 @@ export { isUsingClientRouter };
3
3
  export { extractExportNamesRE };
4
4
  import { assert, getFileExtension, viteIsSSR_options, createDebugger, isDebugEnabled, getGlobalObject, assertUsage } from '../utils.js';
5
5
  import { getExportNames } from '../shared/parseEsModule.js';
6
- import { removeSourceMap } from '../shared/removeSourceMap.js';
6
+ import { sourceMapRemove } from '../shared/rollupSourceMap.js';
7
7
  const extractExportNamesRE = /(\?|&)extractExportNames(?:&|$)/;
8
8
  const debugNamespace = 'vike:extractExportNames';
9
9
  const debug = createDebugger(debugNamespace);
@@ -38,7 +38,7 @@ async function getExtractExportNamesCode(src, isClientSide, isProduction, id) {
38
38
  globalObject.usesClientRouter = true;
39
39
  }
40
40
  const code = getCode(exportNames, wildcardReExports, isClientSide, isProduction, id);
41
- return removeSourceMap(code);
41
+ return sourceMapRemove(code);
42
42
  }
43
43
  function getCode(exportNames, wildcardReExports, isClientSide, isProduction, id) {
44
44
  let code = '';
@@ -1,5 +1,4 @@
1
1
  export { getVikeManifest };
2
- import { ResolvedConfig } from 'vite';
3
2
  import { type PluginManifest } from '../../../shared/assertPluginManifest.js';
4
3
  import type { ConfigVikeResolved } from '../../../../shared/ConfigVike.js';
5
- declare function getVikeManifest(config: ResolvedConfig, configVike: ConfigVikeResolved): PluginManifest;
4
+ declare function getVikeManifest(configVike: ConfigVikeResolved): PluginManifest;
@@ -1,32 +1,15 @@
1
1
  export { getVikeManifest };
2
- import { projectInfo, toPosixPath, assertPosixPath, isNotNullish } from '../../utils.js';
2
+ import { projectInfo } from '../../utils.js';
3
3
  import { assertPluginManifest } from '../../../shared/assertPluginManifest.js';
4
4
  import { isUsingClientRouter } from '../extractExportNamesPlugin.js';
5
- import path from 'path';
6
5
  import { getRuntimeManifest } from '../../../runtime/globalContext.js';
7
- function getVikeManifest(config, configVike) {
6
+ function getVikeManifest(configVike) {
8
7
  const runtimeManifest = getRuntimeManifest(configVike);
9
8
  const manifest = {
10
9
  version: projectInfo.projectVersion,
11
10
  usesClientRouter: isUsingClientRouter(), // TODO/v1-release: remove
12
- manifestKeyMap: getManifestKeyMap(configVike, config),
13
11
  ...runtimeManifest
14
12
  };
15
13
  assertPluginManifest(manifest);
16
14
  return manifest;
17
15
  }
18
- function getManifestKeyMap(configVike, config) {
19
- const manifestKeyMap = {};
20
- configVike.extensions
21
- .map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
22
- .flat()
23
- .filter(isNotNullish)
24
- .forEach(({ importPath, filePath }) => {
25
- // Recreating https://github.com/vitejs/vite/blob/8158ece72b66307e7b607b98496891610ca70ea2/packages/vite/src/node/plugins/manifest.ts#L38
26
- const filePathRelative = path.posix.relative(config.root, toPosixPath(filePath));
27
- assertPosixPath(filePathRelative);
28
- assertPosixPath(importPath);
29
- manifestKeyMap[importPath] = filePathRelative;
30
- });
31
- return manifestKeyMap;
32
- }
@@ -1,3 +1,8 @@
1
1
  export { importBuild };
2
- import type { Plugin } from 'vite';
2
+ export { set_constant_ASSETS_MAP };
3
+ import type { Plugin, Rollup } from 'vite';
4
+ type Bundle = Rollup.OutputBundle;
5
+ type Options = Rollup.NormalizedOutputOptions;
3
6
  declare function importBuild(): Plugin[];
7
+ /** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
8
+ declare function set_constant_ASSETS_MAP(options: Options, bundle: Bundle): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  export { importBuild };
2
+ export { set_constant_ASSETS_MAP };
2
3
  import { serverEntryPlugin, findServerEntry } from '@brillout/vite-plugin-server-entry/plugin.js';
3
- import { assert, getOutDirs, toPosixPath, viteIsSSR } from '../../utils.js';
4
+ import { assert, getOutDirs, toPosixPath } from '../../utils.js';
4
5
  import path from 'path';
5
6
  import { createRequire } from 'module';
6
7
  import { getConfigVike } from '../../../shared/getConfigVike.js';
@@ -21,11 +22,6 @@ function importBuild() {
21
22
  async configResolved(config_) {
22
23
  config = config_;
23
24
  configVike = await getConfigVike(config);
24
- },
25
- async writeBundle(options, bundle) {
26
- if (!viteIsSSR(config))
27
- return;
28
- await replace_ASSETS_MAP(options, bundle);
29
25
  }
30
26
  },
31
27
  ...serverEntryPlugin({
@@ -38,7 +34,7 @@ function importBuild() {
38
34
  }
39
35
  function getEntryCode(config, configVike) {
40
36
  const importPath = getImportPath(config);
41
- const vikeManifest = getVikeManifest(config, configVike);
37
+ const vikeManifest = getVikeManifest(configVike);
42
38
  const importerCode = [
43
39
  ` import { setImportBuildGetters } from '${importPath}';`,
44
40
  ` import * as pageFiles from '${virtualFileIdImportUserCodeServer}';`,
@@ -58,7 +54,8 @@ function getEntryCode(config, configVike) {
58
54
  ].join('\n');
59
55
  return importerCode;
60
56
  }
61
- async function replace_ASSETS_MAP(options, bundle) {
57
+ /** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
58
+ async function set_constant_ASSETS_MAP(options, bundle) {
62
59
  const { dir } = options;
63
60
  assert(dir);
64
61
  // This will probably fail with @vitejs/plugin-legacy
@@ -1,10 +1,10 @@
1
1
  export { getVirtualFileImportUserCode };
2
- import { assert, assertPosixPath, viteIsSSR_options, isNotNullish, scriptFileExtensions, debugGlob, getOutDirs } from '../../utils.js';
2
+ import { assert, assertPosixPath, viteIsSSR_options, scriptFileExtensions, debugGlob, getOutDirs, isVersionOrAbove } from '../../utils.js';
3
3
  import { isVirtualFileIdImportUserCode } from '../../../shared/virtual-files/virtualFileImportUserCode.js';
4
- import { fileTypes, determineFileType } from '../../../../shared/getPageFiles/fileTypes.js';
4
+ import { version as viteVersion } from 'vite';
5
+ import { fileTypes } from '../../../../shared/getPageFiles/fileTypes.js';
5
6
  import path from 'path';
6
7
  import { getVirtualFilePageConfigs } from './v1-design/getVirtualFilePageConfigs.js';
7
- import { generateEagerImport } from './generateEagerImport.js';
8
8
  async function getVirtualFileImportUserCode(id, options, configVike, config, isDev) {
9
9
  const idParsed = isVirtualFileIdImportUserCode(id);
10
10
  assert(idParsed);
@@ -21,53 +21,13 @@ async function getCode(config, configVike, isForClientSide, isClientRouting, isP
21
21
  assert(isDev === !isBuild);
22
22
  let content = '';
23
23
  {
24
- const globRoots = getGlobRoots(config, configVike);
24
+ const globRoots = getGlobRoots(config);
25
25
  debugGlob('Glob roots: ', globRoots);
26
26
  content += await generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id);
27
27
  }
28
- {
29
- const extensionsImportPaths = configVike.extensions
30
- .map(({ pageConfigsDistFiles }) => pageConfigsDistFiles)
31
- .flat()
32
- .filter(isNotNullish)
33
- .map(({ importPath }) => importPath);
34
- content += generateExtensionImports(extensionsImportPaths, isForClientSide, isBuild, isClientRouting, isPrerendering);
35
- }
36
28
  debugGlob(`Glob imports for ${isForClientSide ? 'client' : 'server'}:\n`, content);
37
29
  return content;
38
30
  }
39
- function generateExtensionImports(extensionsImportPaths, isForClientSide, isBuild, isClientRouting, isPrerendering) {
40
- let fileContent = '\n\n';
41
- extensionsImportPaths
42
- .filter((importPath) => {
43
- assert(
44
- // V1 design
45
- importPath.includes('+') ||
46
- // V0.4 design
47
- importPath.includes('.page.'));
48
- return !importPath.includes('+');
49
- })
50
- .forEach((importPath) => {
51
- const fileType = determineFileType(importPath);
52
- const { includeImport, includeExportNames } = determineInjection({
53
- fileType,
54
- isForClientSide,
55
- isClientRouting,
56
- isPrerendering,
57
- isBuild
58
- });
59
- if (includeImport) {
60
- fileContent += addImport(importPath, fileType, false, isBuild);
61
- }
62
- if (includeExportNames) {
63
- fileContent += addImport(importPath, fileType, true, isBuild);
64
- }
65
- if (!includeImport && !includeExportNames && !isForClientSide) {
66
- fileContent += `pageFilesList.push("${importPath}");` + '\n';
67
- }
68
- });
69
- return fileContent;
70
- }
71
31
  function determineInjection({ fileType, isForClientSide, isClientRouting, isPrerendering, isBuild }) {
72
32
  if (!isForClientSide) {
73
33
  return {
@@ -93,42 +53,6 @@ function determineInjection({ fileType, isForClientSide, isClientRouting, isPrer
93
53
  }
94
54
  }
95
55
  }
96
- function addImport(importPath, fileType, exportNames, isBuild) {
97
- const pageFilesVar = (() => {
98
- if (exportNames) {
99
- if (isBuild) {
100
- return 'pageFilesExportNamesEager';
101
- }
102
- else {
103
- return 'pageFilesExportNamesLazy';
104
- }
105
- }
106
- else {
107
- if (fileType === '.page.route') {
108
- return 'pageFilesEager';
109
- }
110
- else {
111
- return 'pageFilesLazy';
112
- }
113
- }
114
- })();
115
- const query = !exportNames ? '' : '?extractExportNames';
116
- let fileContent = '';
117
- const mapVar = `${pageFilesVar}['${fileType}']`;
118
- fileContent += `${mapVar} = ${mapVar} ?? {};\n`;
119
- const value = (() => {
120
- if (!pageFilesVar.endsWith('Eager')) {
121
- return `() => import('${importPath}${query}')`;
122
- }
123
- else {
124
- const { importName, importStatement } = generateEagerImport(`${importPath}${query}`);
125
- fileContent += importStatement + '\n';
126
- return importName;
127
- }
128
- })();
129
- fileContent += `${mapVar}['${importPath}'] = ${value};\n`;
130
- return fileContent;
131
- }
132
56
  async function generateGlobImports(globRoots, isBuild, isForClientSide, isClientRouting, configVike, isPrerendering, config, isDev, id) {
133
57
  let fileContent = `// Generatead by node/plugin/plugins/virtualFiles/index.ts
134
58
 
@@ -206,10 +130,15 @@ function getGlobs(globRoots, isBuild, fileType, query) {
206
130
  varNameLocals.push(varNameLocal);
207
131
  const globIncludePath = `'${getGlobPath(globRoot.includeDir, fileType)}'`;
208
132
  const globExcludePath = globRoot.excludeDir ? `'!${getGlobPath(globRoot.excludeDir, fileType)}'` : null;
209
- const globOptions = JSON.stringify({ eager: isEager, as: query });
210
- assert(globOptions.startsWith('{"eager":true') || globOptions.startsWith('{"eager":false'));
133
+ const globOptions = { eager: isEager };
134
+ if (isVersionOrAbove(viteVersion, '5.1.0')) {
135
+ globOptions.as = query;
136
+ }
137
+ else {
138
+ globOptions.query = `?${query}`;
139
+ }
211
140
  const globPaths = globExcludePath ? `[${globIncludePath}, ${globExcludePath}]` : `[${globIncludePath}]`;
212
- const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${globOptions});`;
141
+ const globLine = `const ${varNameLocal} = import.meta.glob(${globPaths}, ${JSON.stringify(globOptions)});`;
213
142
  return globLine;
214
143
  }),
215
144
  `const ${varName} = {${varNameLocals.map((varNameLocal) => `...${varNameLocal}`).join(',')}};`,
@@ -217,22 +146,13 @@ function getGlobs(globRoots, isBuild, fileType, query) {
217
146
  ''
218
147
  ].join('\n');
219
148
  }
220
- function getGlobRoots(config, configVike) {
149
+ function getGlobRoots(config) {
221
150
  const globRoots = [
222
151
  {
223
152
  includeDir: '/',
224
153
  excludeDir: path.posix.relative(config.root, getOutDirs(config).outDirRoot)
225
154
  }
226
155
  ];
227
- configVike.extensions
228
- .map(({ pageConfigsSrcDir }) => pageConfigsSrcDir)
229
- .filter(isNotNullish)
230
- .forEach((pageConfigsSrcDir) => {
231
- const globRoot = {
232
- includeDir: path.posix.relative(config.root, pageConfigsSrcDir)
233
- };
234
- globRoots.push(globRoot);
235
- });
236
156
  return globRoots;
237
157
  }
238
158
  function getGlobPath(globRootDir, fileType) {
@@ -1,6 +1,7 @@
1
1
  export { configDefinitionsBuiltIn };
2
2
  export { configDefinitionsBuiltInGlobal };
3
3
  export type { ConfigDefinition };
4
+ export type { ConfigDefinitions };
4
5
  export type { ConfigDefinitionInternal };
5
6
  export type { ConfigNameGlobal };
6
7
  export type { ConfigEffect };
@@ -54,6 +55,7 @@ type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
54
55
  _userEffectDefinedAt?: DefinedAtFileFullInfo;
55
56
  env: ConfigEnvInternal;
56
57
  };
58
+ type ConfigDefinitions = Record<string, ConfigDefinitionInternal>;
57
59
  type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn, ConfigDefinitionInternal>;
58
60
  declare const configDefinitionsBuiltIn: ConfigDefinitionsBuiltIn;
59
61
  type ConfigNameGlobal = 'onPrerenderStart' | 'onBeforeRoute' | 'prerender' | 'extensions' | 'disableAutoFullBuild' | 'includeAssetsImportedByServer' | 'baseAssets' | 'baseServer' | 'redirects' | 'trailingSlash' | 'disableUrlNormalization';
@@ -1,5 +1,4 @@
1
1
  export { crawlPlusFiles };
2
2
  declare function crawlPlusFiles(userRootDir: string, outDirAbsoluteFilesystem: string, isDev: boolean): Promise<{
3
3
  filePathRelativeToUserRootDir: string;
4
- filePathAbsoluteFilesystem: string;
5
4
  }[]>;
@@ -44,11 +44,7 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
44
44
  p = toPosixPath(p);
45
45
  assert(!p.startsWith(userRootDir));
46
46
  const filePathRelativeToUserRootDir = path.posix.join('/', p);
47
- const filePathAbsoluteFilesystem = path.posix.join(userRootDir, p);
48
- return {
49
- filePathRelativeToUserRootDir,
50
- filePathAbsoluteFilesystem
51
- };
47
+ return { filePathRelativeToUserRootDir };
52
48
  });
53
49
  return plusFiles;
54
50
  }
@@ -5,26 +5,53 @@ export { getLocationId };
5
5
  export { sortAfterInheritanceOrder };
6
6
  export { isGlobalLocation };
7
7
  export { applyFilesystemRoutingRootEffect };
8
+ export type { LocationId };
8
9
  export { getLogicalPath };
9
10
  /**
10
- * getLocationId('/pages/some-page/+Page.js') => '/pages/some-page'
11
- * getLocationId('/pages/some-page') => '/pages/some-page'
12
- * getLocationId('/renderer/+config.js') => '/renderer'
11
+ * The `locationId` value is used for filesystem inheritance.
12
+ *
13
+ * Each config value is assigned with a `locationId` value. That's the source-of-truth for determining inheritance between config values.
14
+ *
15
+ * For Vike extensions, `locationId` is different than the config value's `definedAt`, for example the `onRenderHtml()` hook of `vike-react`:
16
+ * - `locationId === '/pages'` (the directory of `/pages/+config.h.js` which extends `vike-react`)
17
+ * - `definedAt.filePathAbsoluteFilesystem === '/home/rom/code/my-vike-app/node_modules/vike-react/dist/renderer/onRenderHtml.js'` (the file where the value is defined)
18
+ *
19
+ * This is an important distinction because the Vike extension's config should only apply to where it's being extended from, for example:
20
+ * ```js
21
+ * // /pages/admin/+config.h.js
22
+ * import vikeVue from 'vike-vue/config'
23
+ * // Should only apply to /pages/admin/**
24
+ * export default { extends: [vikeVue] }
25
+ * ```
26
+ * ```js
27
+ * // /pages/marketing/+config.h.js
28
+ * import vikeReact from 'vike-react/config'
29
+ * // Should only apply to /pages/marketing/**
30
+ * export default { extends: [vikeReact] }
31
+ * ```
13
32
  */
14
- declare function getLocationId(filePathAbsoluteVite: string): string;
15
- /** Get URL determined by filesystem path */
16
- declare function getFilesystemRouteString(locationId: string): string;
33
+ type LocationId = string & {
34
+ __brand: 'LocationId';
35
+ };
36
+ /**
37
+ * `getLocationId('/pages/some-page/+Page.js')` => `'/pages/some-page'`
38
+ * `getLocationId('/renderer/+config.js')` => `'/renderer'`
39
+ *
40
+ * The value `locationId` is always a user-land path, because Filesystem Routing/Inheritance only applies to the user-land (Vike never uses Filesystem Routing/Inheritance for `node_modules/**`).
41
+ */
42
+ declare function getLocationId(filePathRelativeToUserRootDir: string): LocationId;
43
+ /** Filesystem Routing: get the URL */
44
+ declare function getFilesystemRouteString(locationId: LocationId): string;
17
45
  /**
18
46
  * getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
19
- * getLogicalPath('some-npm-pkg/renderer', ['renderer']) => '/'
20
47
  */
21
- declare function getLogicalPath(someDir: string, removeDirs: string[]): string;
48
+ declare function getLogicalPath(locationId: LocationId, removeDirs: string[]): string;
22
49
  /** Whether configs defined in `locationId` apply in every `locationIds` */
23
- declare function isGlobalLocation(locationId: string, locationIds: string[]): boolean;
24
- declare function sortAfterInheritanceOrder(locationId1: string, locationId2: string, locationIdPage: string): -1 | 1 | 0;
50
+ declare function isGlobalLocation(locationId: LocationId, locationIds: LocationId[]): boolean;
51
+ declare function sortAfterInheritanceOrder(locationId1: LocationId, locationId2: LocationId, locationIdPage: LocationId): -1 | 1 | 0;
25
52
  /** Whether configs defined at `locationId1` also apply at `locationId2` */
26
- declare function isInherited(locationId1: string, locationId2: string): boolean;
27
- declare function getFilesystemRouteDefinedBy(locationId: string): string;
53
+ declare function isInherited(locationId1: LocationId, locationId2: LocationId): boolean;
54
+ declare function getFilesystemRouteDefinedBy(locationId: LocationId): string;
28
55
  declare function applyFilesystemRoutingRootEffect(routeFilesystem: string, filesystemRoutingRootEffect: {
29
56
  before: string;
30
57
  after: string;
@@ -7,40 +7,47 @@ export { isGlobalLocation };
7
7
  export { applyFilesystemRoutingRootEffect };
8
8
  // For ./filesystemRouting.spec.ts
9
9
  export { getLogicalPath };
10
- import { assert, assertPosixPath, getNpmPackageImportPath, isNpmPackageImport, higherFirst } from '../../../../utils.js';
10
+ import { assert, assertPosixPath, higherFirst } from '../../../../utils.js';
11
11
  /**
12
- * getLocationId('/pages/some-page/+Page.js') => '/pages/some-page'
13
- * getLocationId('/pages/some-page') => '/pages/some-page'
14
- * getLocationId('/renderer/+config.js') => '/renderer'
12
+ * `getLocationId('/pages/some-page/+Page.js')` => `'/pages/some-page'`
13
+ * `getLocationId('/renderer/+config.js')` => `'/renderer'`
14
+ *
15
+ * The value `locationId` is always a user-land path, because Filesystem Routing/Inheritance only applies to the user-land (Vike never uses Filesystem Routing/Inheritance for `node_modules/**`).
15
16
  */
16
- function getLocationId(filePathAbsoluteVite) {
17
- const locationId = removeFilename(filePathAbsoluteVite, true);
17
+ function getLocationId(
18
+ // We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.h.js` that extends the Vike extension.
19
+ filePathRelativeToUserRootDir) {
20
+ assertPosixPath(filePathRelativeToUserRootDir);
21
+ assert(filePathRelativeToUserRootDir.startsWith('/'));
22
+ const locationId = removeFilename(filePathRelativeToUserRootDir);
18
23
  assertLocationId(locationId);
19
24
  return locationId;
20
25
  }
21
- /** Get URL determined by filesystem path */
26
+ /** Filesystem Routing: get the URL */
22
27
  function getFilesystemRouteString(locationId) {
23
28
  return getLogicalPath(locationId, ['renderer', 'pages', 'src', 'index']);
24
29
  }
25
- /** Get apply root for config inheritance */
26
- function getInheritanceRoot(someDir) {
27
- return getLogicalPath(someDir, ['renderer']);
30
+ /** Filesystem Inheritance: get the apply root */
31
+ function getInheritanceRoot(locationId) {
32
+ return getLogicalPath(locationId, ['renderer']);
28
33
  }
29
34
  /**
30
35
  * getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
31
- * getLogicalPath('some-npm-pkg/renderer', ['renderer']) => '/'
32
36
  */
33
- function getLogicalPath(someDir, removeDirs) {
34
- someDir = removeNpmPackageName(someDir);
35
- someDir = removeDirectories(someDir, removeDirs);
36
- assertIsPath(someDir);
37
- return someDir;
37
+ function getLogicalPath(locationId, removeDirs) {
38
+ let logicalPath = removeDirectories(locationId, removeDirs);
39
+ assertIsPath(logicalPath);
40
+ return logicalPath;
38
41
  }
39
42
  /** Whether configs defined in `locationId` apply in every `locationIds` */
40
43
  function isGlobalLocation(locationId, locationIds) {
41
44
  return locationIds.every((locId) => isInherited(locationId, locId) || locationIsRendererDir(locId));
42
45
  }
43
46
  function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
47
+ assertLocationId(locationId1);
48
+ assertLocationId(locationId2);
49
+ if (locationId1 === locationId2)
50
+ return 0;
44
51
  const inheritanceRoot1 = getInheritanceRoot(locationId1);
45
52
  const inheritanceRoot2 = getInheritanceRoot(locationId2);
46
53
  const inheritanceRootPage = getInheritanceRoot(locationIdPage);
@@ -56,15 +63,10 @@ function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
56
63
  assert(inheritanceRoot1.length !== inheritanceRoot2.length);
57
64
  return higherFirst((inheritanceRoot) => inheritanceRoot.length)(inheritanceRoot1, inheritanceRoot2);
58
65
  }
59
- // Should be true since we aggregate interface files by locationId
60
- assert(locationId1 !== locationId2);
61
66
  // locationId1 first, i.e. `indexOf(locationId1) < indexOf(locationId2)`
62
67
  const locationId1First = -1;
63
68
  // locationId2 first, i.e. `indexOf(locationId2) < indexOf(locationId1)`
64
69
  const locationId2First = 1;
65
- if (locationIsNpmPackage(locationId1) !== locationIsNpmPackage(locationId2)) {
66
- return locationIsNpmPackage(locationId1) ? locationId2First : locationId1First;
67
- }
68
70
  if (locationIsRendererDir(locationId1) !== locationIsRendererDir(locationId2)) {
69
71
  return locationIsRendererDir(locationId1) ? locationId2First : locationId1First;
70
72
  }
@@ -75,9 +77,6 @@ function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
75
77
  }
76
78
  return locationId1 > locationId2 ? locationId1First : locationId2First;
77
79
  }
78
- function locationIsNpmPackage(locationId) {
79
- return !locationId.startsWith('/');
80
- }
81
80
  function locationIsRendererDir(locationId) {
82
81
  return locationId.split('/').includes('renderer');
83
82
  }
@@ -87,19 +86,6 @@ function isInherited(locationId1, locationId2) {
87
86
  const inheritanceRoot2 = getInheritanceRoot(locationId2);
88
87
  return startsWith(inheritanceRoot2, inheritanceRoot1);
89
88
  }
90
- function removeNpmPackageName(somePath) {
91
- if (!isNpmPackageImport(somePath)) {
92
- assert(somePath.startsWith('/'));
93
- return somePath;
94
- }
95
- const importPath = getNpmPackageImportPath(somePath);
96
- if (!importPath)
97
- return '/';
98
- assertPosixPath(importPath);
99
- assert(!importPath.startsWith('/'));
100
- somePath = '/' + importPath;
101
- return somePath;
102
- }
103
89
  function removeDirectories(somePath, removeDirs) {
104
90
  assertPosixPath(somePath);
105
91
  somePath = somePath
@@ -110,17 +96,13 @@ function removeDirectories(somePath, removeDirs) {
110
96
  somePath = '/';
111
97
  return somePath;
112
98
  }
113
- function removeFilename(filePathAbsoluteVite, optional) {
114
- assertPosixPath(filePathAbsoluteVite);
115
- assert(filePathAbsoluteVite.startsWith('/') || isNpmPackageImport(filePathAbsoluteVite));
99
+ function removeFilename(filePathRelativeToUserRootDir) {
100
+ const filePathParts = filePathRelativeToUserRootDir.split('/');
116
101
  {
117
- const filename = filePathAbsoluteVite.split('/').slice(-1)[0];
118
- if (!filename.includes('.')) {
119
- assert(optional);
120
- return filePathAbsoluteVite;
121
- }
102
+ const filename = filePathParts.slice(-1)[0];
103
+ assert(filename.includes('.'));
122
104
  }
123
- let locationId = filePathAbsoluteVite.split('/').slice(0, -1).join('/');
105
+ let locationId = filePathParts.slice(0, -1).join('/');
124
106
  if (locationId === '')
125
107
  locationId = '/';
126
108
  assertLocationId(locationId);
@@ -142,7 +124,7 @@ function applyFilesystemRoutingRootEffect(routeFilesystem, filesystemRoutingRoot
142
124
  return routeFilesystem;
143
125
  }
144
126
  function assertLocationId(locationId) {
145
- assert(locationId.startsWith('/') || isNpmPackageImport(locationId));
127
+ assert(locationId.startsWith('/'));
146
128
  assert(!locationId.endsWith('/') || locationId === '/');
147
129
  }
148
130
  function assertIsPath(logicalPath) {
@@ -6,7 +6,7 @@ import { assertPosixPath, assert, assertUsage, assertWarning, hasProp, assertIsN
6
6
  import { transpileAndExecuteFile } from './transpileAndExecuteFile.js';
7
7
  import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
8
8
  import pc from '@brillout/picocolors';
9
- import { parseImportData } from './transformImports.js';
9
+ import { parseImportData } from './transformFileImports.js';
10
10
  import { getConfigFileExport } from '../getConfigFileExport.js';
11
11
  import { assertImportPath, resolveImportPath } from './resolveImportPath.js';
12
12
  assertIsNotProductionRuntime();
@@ -14,7 +14,7 @@ assertIsNotProductionRuntime();
14
14
  async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
15
15
  const f = import_.filePathAbsoluteFilesystem;
16
16
  if (!importedFilesLoaded[f]) {
17
- importedFilesLoaded[f] = transpileAndExecuteFile(import_, true, userRootDir).then((r) => r.fileExports);
17
+ importedFilesLoaded[f] = transpileAndExecuteFile(import_, false, userRootDir).then((r) => r.fileExports);
18
18
  }
19
19
  const fileExports = await importedFilesLoaded[f];
20
20
  const fileExport = fileExports[import_.fileExportName];
@@ -22,7 +22,7 @@ async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
22
22
  }
23
23
  // Load +{configName}.js
24
24
  async function loadValueFile(interfaceValueFile, configName, userRootDir) {
25
- const { fileExports } = await transpileAndExecuteFile(interfaceValueFile.filePath, true, userRootDir);
25
+ const { fileExports } = await transpileAndExecuteFile(interfaceValueFile.filePath, false, userRootDir);
26
26
  const { filePathToShowToUser } = interfaceValueFile.filePath;
27
27
  assertPlusFileExport(fileExports, filePathToShowToUser, configName);
28
28
  Object.entries(fileExports).forEach(([exportName, configValue]) => {
@@ -34,7 +34,7 @@ async function loadValueFile(interfaceValueFile, configName, userRootDir) {
34
34
  async function loadConfigFile(configFilePath, userRootDir, visited, isConfigOfExtension) {
35
35
  const { filePathAbsoluteFilesystem } = configFilePath;
36
36
  assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
37
- const { fileExports } = await transpileAndExecuteFile(configFilePath, false, userRootDir, isConfigOfExtension);
37
+ const { fileExports } = await transpileAndExecuteFile(configFilePath, !isConfigOfExtension, userRootDir, isConfigOfExtension);
38
38
  const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
39
39
  ...visited,
40
40
  filePathAbsoluteFilesystem
@@ -0,0 +1,5 @@
1
+ export { resolveFilePathRelativeToUserRootDir };
2
+ export { resolveFilePathAbsoluteFilesystem };
3
+ import type { FilePathResolved } from '../../../../../../shared/page-configs/PageConfig.js';
4
+ declare function resolveFilePathRelativeToUserRootDir(filePathRelativeToUserRootDir: string, userRootDir: string): FilePathResolved;
5
+ declare function resolveFilePathAbsoluteFilesystem(filePathAbsoluteFilesystem: string, userRootDir: string): FilePathResolved;