vike 0.4.219 → 0.4.220-commit-9a798ce

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 (157) hide show
  1. package/dist/cjs/node/api/build.js +23 -58
  2. package/dist/cjs/node/api/context.js +6 -8
  3. package/dist/cjs/node/api/prepareViteApiCall.js +6 -7
  4. package/dist/cjs/node/api/utils.js +1 -1
  5. package/dist/cjs/node/cli/context.js +16 -0
  6. package/dist/cjs/node/cli/entry.js +2 -0
  7. package/dist/cjs/node/cli/utils.js +1 -0
  8. package/dist/cjs/{utils → node/plugin}/getOutDirs.js +11 -11
  9. package/dist/cjs/node/plugin/index.js +1 -7
  10. package/dist/cjs/node/plugin/onLoad.js +6 -1
  11. package/dist/cjs/node/plugin/plugins/autoFullBuild.js +43 -31
  12. package/dist/cjs/node/plugin/plugins/baseUrls.js +2 -2
  13. package/dist/cjs/node/plugin/plugins/buildConfig.js +6 -3
  14. package/dist/cjs/node/plugin/plugins/buildEntry/index.js +24 -21
  15. package/dist/cjs/node/plugin/plugins/commonConfig.js +11 -8
  16. package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +4 -2
  17. package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
  18. package/dist/cjs/node/plugin/plugins/importUserCode/index.js +3 -4
  19. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
  20. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
  21. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +158 -176
  22. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
  23. package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +3 -2
  24. package/dist/cjs/node/plugin/plugins/previewConfig.js +3 -4
  25. package/dist/cjs/node/plugin/utils.js +1 -1
  26. package/dist/cjs/node/prerender/context.js +26 -0
  27. package/dist/cjs/node/prerender/resolvePrerenderConfig.js +25 -0
  28. package/dist/cjs/node/prerender/runPrerender.js +64 -37
  29. package/dist/cjs/node/prerender/utils.js +3 -2
  30. package/dist/cjs/node/runtime/globalContext.js +44 -58
  31. package/dist/cjs/node/runtime/page-files/setup.js +1 -1
  32. package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
  33. package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +6 -5
  34. package/dist/cjs/node/runtime/renderPage.js +10 -5
  35. package/dist/cjs/node/runtime/utils.js +3 -2
  36. package/dist/cjs/node/shared/resolveBase.js +9 -0
  37. package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +2 -2
  38. package/dist/cjs/shared/page-configs/loadConfigValues.js +5 -1
  39. package/dist/cjs/shared/utils.js +1 -1
  40. package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
  41. package/dist/cjs/utils/assertSetup.js +15 -1
  42. package/dist/cjs/utils/catchInfiniteLoop.js +34 -0
  43. package/dist/cjs/utils/findFile.js +3 -3
  44. package/dist/cjs/utils/isDev.js +4 -1
  45. package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +2 -2
  46. package/dist/cjs/utils/makePublicCopy.js +32 -0
  47. package/dist/cjs/utils/requireResolve.js +3 -3
  48. package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
  49. package/dist/esm/client/client-routing-runtime/history.js +23 -18
  50. package/dist/esm/client/client-routing-runtime/index.d.ts +0 -1
  51. package/dist/esm/client/client-routing-runtime/index.js +0 -1
  52. package/dist/esm/client/client-routing-runtime/initClientRouter.js +2 -2
  53. package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +3 -4
  54. package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +0 -10
  55. package/dist/esm/client/client-routing-runtime/initOnPopState.js +50 -62
  56. package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +15 -15
  57. package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +4 -6
  58. package/dist/esm/client/client-routing-runtime/scrollRestoration.js +17 -12
  59. package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +1 -1
  60. package/dist/esm/client/client-routing-runtime/setScrollPosition.js +29 -5
  61. package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
  62. package/dist/esm/client/client-routing-runtime/utils.js +1 -0
  63. package/dist/esm/client/shared/normalizeClientSideUrl.js +2 -3
  64. package/dist/esm/node/api/build.d.ts +1 -6
  65. package/dist/esm/node/api/build.js +20 -25
  66. package/dist/esm/node/api/context.d.ts +4 -4
  67. package/dist/esm/node/api/context.js +6 -9
  68. package/dist/esm/node/api/prepareViteApiCall.d.ts +0 -1
  69. package/dist/esm/node/api/prepareViteApiCall.js +7 -8
  70. package/dist/esm/node/api/utils.d.ts +1 -1
  71. package/dist/esm/node/api/utils.js +1 -1
  72. package/dist/esm/node/cli/context.d.ts +5 -0
  73. package/dist/esm/node/cli/context.js +14 -0
  74. package/dist/esm/node/cli/entry.js +2 -0
  75. package/dist/esm/node/cli/parseCli.d.ts +3 -1
  76. package/dist/esm/node/cli/utils.d.ts +1 -0
  77. package/dist/esm/node/cli/utils.js +1 -0
  78. package/dist/esm/{utils → node/plugin}/getOutDirs.js +5 -5
  79. package/dist/esm/node/plugin/index.d.ts +29 -1
  80. package/dist/esm/node/plugin/index.js +2 -8
  81. package/dist/esm/node/plugin/onLoad.js +7 -2
  82. package/dist/esm/node/plugin/plugins/autoFullBuild.js +43 -31
  83. package/dist/esm/node/plugin/plugins/baseUrls.js +2 -2
  84. package/dist/esm/node/plugin/plugins/buildConfig.js +7 -4
  85. package/dist/esm/node/plugin/plugins/buildEntry/index.d.ts +3 -3
  86. package/dist/esm/node/plugin/plugins/buildEntry/index.js +25 -22
  87. package/dist/esm/node/plugin/plugins/commonConfig.d.ts +8 -2
  88. package/dist/esm/node/plugin/plugins/commonConfig.js +9 -6
  89. package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +4 -2
  90. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +2 -2
  91. package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +10 -7
  92. package/dist/esm/node/plugin/plugins/importUserCode/index.js +3 -4
  93. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +3 -2
  94. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +10 -9
  95. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +8 -3
  96. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -95
  97. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +159 -177
  98. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +3 -1
  99. package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +3 -2
  100. package/dist/esm/node/plugin/plugins/previewConfig.js +3 -4
  101. package/dist/esm/node/plugin/utils.js +1 -1
  102. package/dist/esm/node/prerender/context.d.ts +9 -0
  103. package/dist/esm/node/prerender/context.js +24 -0
  104. package/dist/esm/node/prerender/resolvePrerenderConfig.d.ts +5 -0
  105. package/dist/esm/node/prerender/resolvePrerenderConfig.js +23 -0
  106. package/dist/esm/node/prerender/runPrerender.d.ts +42 -1
  107. package/dist/esm/node/prerender/runPrerender.js +65 -38
  108. package/dist/esm/node/prerender/utils.d.ts +3 -2
  109. package/dist/esm/node/prerender/utils.js +3 -2
  110. package/dist/esm/node/runtime/globalContext.d.ts +15 -9
  111. package/dist/esm/node/runtime/globalContext.js +45 -59
  112. package/dist/esm/node/runtime/page-files/setup.js +1 -1
  113. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +5 -5
  114. package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +6 -3
  115. package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +2 -0
  116. package/dist/esm/node/runtime/renderPage/resolveRedirects.js +5 -5
  117. package/dist/esm/node/runtime/renderPage.js +10 -5
  118. package/dist/esm/node/runtime/utils.d.ts +3 -2
  119. package/dist/esm/node/runtime/utils.js +3 -2
  120. package/dist/esm/node/shared/resolveBase.d.ts +4 -1
  121. package/dist/esm/node/shared/resolveBase.js +9 -0
  122. package/dist/esm/shared/page-configs/Config.d.ts +76 -3
  123. package/dist/esm/shared/page-configs/PageConfig.d.ts +25 -16
  124. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +1 -1
  125. package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +2 -2
  126. package/dist/esm/shared/page-configs/loadConfigValues.js +6 -2
  127. package/dist/esm/shared/utils.d.ts +1 -1
  128. package/dist/esm/shared/utils.js +1 -1
  129. package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
  130. package/dist/esm/utils/PROJECT_VERSION.js +1 -1
  131. package/dist/esm/utils/assertSetup.js +15 -1
  132. package/dist/esm/utils/catchInfiniteLoop.d.ts +2 -0
  133. package/dist/esm/utils/catchInfiniteLoop.js +32 -0
  134. package/dist/esm/utils/findFile.js +1 -1
  135. package/dist/esm/utils/isDev.js +4 -1
  136. package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -1
  137. package/dist/esm/utils/makePublicCopy.d.ts +3 -0
  138. package/dist/esm/utils/makePublicCopy.js +30 -0
  139. package/dist/esm/utils/projectInfo.d.ts +1 -1
  140. package/dist/esm/utils/requireResolve.js +1 -1
  141. package/package.json +1 -1
  142. package/dist/cjs/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -17
  143. package/dist/cjs/node/prerender/isPrerenderAutoRunEnabled.js +0 -16
  144. package/dist/cjs/node/shared/assertPluginManifest.js +0 -20
  145. package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -16
  146. package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.d.ts +0 -5
  147. package/dist/esm/node/plugin/plugins/buildEntry/getVikeManifest.js +0 -15
  148. package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.d.ts +0 -5
  149. package/dist/esm/node/prerender/isPrerenderAutoRunEnabled.js +0 -14
  150. package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -12
  151. package/dist/esm/node/shared/assertPluginManifest.js +0 -18
  152. package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -10
  153. package/dist/esm/node/shared/assertRuntimeManifest.js +0 -14
  154. /package/dist/cjs/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
  155. /package/dist/esm/{utils → node/plugin}/getOutDirs.d.ts +0 -0
  156. /package/dist/esm/utils/{filesystemPathHandling.d.ts → toPosixPath.d.ts} +0 -0
  157. /package/dist/esm/utils/{filesystemPathHandling.js → toPosixPath.js} +0 -0
@@ -1,72 +1,37 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
35
5
  Object.defineProperty(exports, "__esModule", { value: true });
36
6
  exports.build = build;
37
7
  const prepareViteApiCall_js_1 = require("./prepareViteApiCall.js");
38
8
  const vite_1 = require("vite");
39
- const isPrerenderAutoRunEnabled_js_1 = require("../prerender/isPrerenderAutoRunEnabled.js");
9
+ const assert_1 = __importDefault(require("assert"));
10
+ const context_js_1 = require("../cli/context.js");
11
+ const context_js_2 = require("../prerender/context.js");
40
12
  /**
41
13
  * Programmatically trigger `$ vike build`
42
14
  *
43
15
  * https://vike.dev/api#build
44
16
  */
45
17
  async function build(options = {}) {
46
- const { viteConfigEnhanced, vikeConfigGlobal } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options.viteConfig, 'build');
47
- // Build client-side
48
- const outputClient = await (0, vite_1.build)(viteConfigEnhanced);
49
- // Build server-side
50
- const outputServer = await (0, vite_1.build)(setSSR(viteConfigEnhanced));
51
- // Pre-render
52
- if ((0, isPrerenderAutoRunEnabled_js_1.isPrerenderAutoRunEnabled)(vikeConfigGlobal)) {
53
- const { runPrerenderFromAutoRun } = await Promise.resolve().then(() => __importStar(require('../prerender/runPrerender.js')));
54
- await runPrerenderFromAutoRun(viteConfigEnhanced);
55
- }
56
- return {
57
- /* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
58
- viteConfig: viteConfigEnhanced,
59
- */
60
- rollupOutputClient: outputClient,
61
- rollupOutputServer: outputServer
62
- };
63
- }
64
- function setSSR(viteConfig) {
18
+ const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options.viteConfig, 'build');
19
+ // Pass it to autoFullBuild()
20
+ if (viteConfigEnhanced)
21
+ viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
22
+ // 1. Build client-side
23
+ // 2. Build server-side
24
+ // > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L90
25
+ // 3. Pre-render (if enabled)
26
+ // > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L98
27
+ // > We purposely don't start the pre-rendering in this `build()` function but in a Rollup hook instead.
28
+ // > Rationale: https://github.com/vikejs/vike/issues/2123
29
+ await (0, vite_1.build)(viteConfigEnhanced);
30
+ // When using the Vike CLI with pre-rendering the process is forcefully exited at the end of the buildVite() call above
31
+ (0, assert_1.default)(!((0, context_js_1.isVikeCli)() && (0, context_js_2.isPrerendering)()));
65
32
  return {
66
- ...viteConfig,
67
- build: {
68
- ...viteConfig?.build,
69
- ssr: true
70
- }
33
+ /* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
34
+ viteConfig: viteConfigEnhanced,
35
+ */
71
36
  };
72
37
  }
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setOperation = setOperation;
4
- exports.clearOperation = clearOperation;
5
3
  exports.isVikeCliOrApi = isVikeCliOrApi;
4
+ exports.setContextApiOperation = setContextApiOperation;
5
+ exports.clearContextApiOperation = clearContextApiOperation;
6
6
  const utils_js_1 = require("./utils.js");
7
- const globalObject = (0, utils_js_1.getGlobalObject)('context.ts', {
8
- apiOperation: undefined
9
- });
10
- function getOperation() {
7
+ const globalObject = (0, utils_js_1.getGlobalObject)('api/context.ts', {});
8
+ function getApiOperation() {
11
9
  (0, utils_js_1.assert)(globalObject.apiOperation);
12
10
  return globalObject.apiOperation;
13
11
  }
@@ -15,10 +13,10 @@ function isVikeCliOrApi() {
15
13
  // The CLI uses the API
16
14
  return !!globalObject.apiOperation;
17
15
  }
18
- function setOperation(operation) {
16
+ function setContextApiOperation(operation) {
19
17
  (0, utils_js_1.assert)(!globalObject.apiOperation);
20
18
  globalObject.apiOperation = operation;
21
19
  }
22
- function clearOperation() {
20
+ function clearContextApiOperation() {
23
21
  globalObject.apiOperation = undefined;
24
22
  }
@@ -51,31 +51,30 @@ const globalContext_js_1 = require("../runtime/globalContext.js");
51
51
  const globalObject = (0, utils_js_1.getGlobalObject)('prepareViteApiCall.ts', {});
52
52
  async function prepareViteApiCall(viteConfig, operation) {
53
53
  clear();
54
- (0, context_js_1.setOperation)(operation);
54
+ (0, context_js_1.setContextApiOperation)(operation);
55
55
  return enhanceViteConfig(viteConfig, operation);
56
56
  }
57
57
  // For subsequent API calls, e.g. calling prerender() after build()
58
58
  function clear() {
59
- (0, context_js_1.clearOperation)();
59
+ (0, context_js_1.clearContextApiOperation)();
60
60
  (0, globalContext_js_1.clearGlobalContext)();
61
61
  }
62
62
  async function enhanceViteConfig(viteConfig, operation) {
63
63
  const viteInfo = await getInfoFromVite(viteConfig, operation);
64
64
  await assertViteRoot2(viteInfo.root, viteInfo.viteConfigEnhanced, operation);
65
65
  const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
66
- const viteConfigEnhanced = addViteSettingsSetByUser(viteInfo.viteConfigEnhanced, vikeConfig);
66
+ const viteConfigEnhanced = addViteSettingsSetByVikeConfig(viteInfo.viteConfigEnhanced, vikeConfig);
67
67
  return {
68
- viteConfigEnhanced,
69
- vikeConfigGlobal: vikeConfig.vikeConfigGlobal
68
+ viteConfigEnhanced
70
69
  };
71
70
  }
72
- function addViteSettingsSetByUser(viteConfigEnhanced, vikeConfig) {
71
+ function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
73
72
  const viteConfigs = vikeConfig.global.from.configsCumulative.vite;
74
73
  if (!viteConfigs)
75
74
  return viteConfigEnhanced;
76
75
  viteConfigs.values.forEach((v) => {
77
76
  (0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(v.value), `${v.definedAt} should be an object`);
78
- viteConfigEnhanced = (0, vite_1.mergeConfig)(v.value, viteConfigEnhanced ?? {});
77
+ viteConfigEnhanced = (0, vite_1.mergeConfig)(viteConfigEnhanced ?? {}, v.value);
79
78
  });
80
79
  return viteConfigEnhanced;
81
80
  }
@@ -20,5 +20,5 @@ const onLoad_js_1 = require("./onLoad.js");
20
20
  (0, onLoad_js_1.onLoad)();
21
21
  __exportStar(require("../../utils/assert.js"), exports);
22
22
  __exportStar(require("../../utils/getGlobalObject.js"), exports);
23
- __exportStar(require("../../utils/filesystemPathHandling.js"), exports);
23
+ __exportStar(require("../../utils/toPosixPath.js"), exports);
24
24
  __exportStar(require("../../utils/isObject.js"), exports);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isVikeCli = isVikeCli;
4
+ exports.setContextCliCommand = setContextCliCommand;
5
+ const utils_js_1 = require("./utils.js");
6
+ const globalObject = (0, utils_js_1.getGlobalObject)('cli/context.ts', {});
7
+ function getCliCommand() {
8
+ return globalObject.cliCommand;
9
+ }
10
+ function isVikeCli() {
11
+ return !!globalObject.cliCommand;
12
+ }
13
+ function setContextCliCommand(command) {
14
+ (0, utils_js_1.assert)(!globalObject.cliCommand);
15
+ globalObject.cliCommand = command;
16
+ }
@@ -40,9 +40,11 @@ const utils_js_1 = require("./utils.js");
40
40
  const index_js_1 = require("../api/index.js");
41
41
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
42
42
  const parseCli_js_1 = require("./parseCli.js");
43
+ const context_js_1 = require("./context.js");
43
44
  cli();
44
45
  async function cli() {
45
46
  const { command } = (0, parseCli_js_1.parseCli)();
47
+ (0, context_js_1.setContextCliCommand)(command);
46
48
  if (command === 'dev') {
47
49
  await cmdDev();
48
50
  }
@@ -21,3 +21,4 @@ const onLoad_js_1 = require("./onLoad.js");
21
21
  __exportStar(require("../../utils/assert.js"), exports);
22
22
  __exportStar(require("../../utils/projectInfo.js"), exports);
23
23
  __exportStar(require("../../utils/includes.js"), exports);
24
+ __exportStar(require("../../utils/getGlobalObject.js"), exports);
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getOutDirs = getOutDirs;
7
7
  exports.resolveOutDir = resolveOutDir;
8
- const viteIsSSR_js_1 = require("./viteIsSSR.js");
9
- const assert_js_1 = require("./assert.js");
10
- const path_shim_js_1 = require("./path-shim.js");
11
- const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
8
+ const viteIsSSR_js_1 = require("../../utils/viteIsSSR.js");
9
+ const assert_js_1 = require("../../utils/assert.js");
10
+ const path_shim_js_1 = require("../../utils/path-shim.js");
11
+ const toPosixPath_js_1 = require("../../utils/toPosixPath.js");
12
12
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
13
- const debug_js_1 = require("./debug.js");
13
+ const debug_js_1 = require("../../utils/debug.js");
14
14
  const debug = (0, debug_js_1.createDebugger)('vike:outDir');
15
15
  function getOutDirs(config) {
16
16
  debug('getOutDirs()', new Error().stack);
@@ -55,7 +55,7 @@ function resolveOutDir(config) {
55
55
  }
56
56
  }
57
57
  function determineOutDirs(outDirRoot) {
58
- (0, filesystemPathHandling_js_1.assertPosixPath)(outDirRoot);
58
+ (0, toPosixPath_js_1.assertPosixPath)(outDirRoot);
59
59
  (0, assert_js_1.assert)(!outDirRoot.endsWith('/'));
60
60
  (0, assert_js_1.assert)(isOutDirRoot(outDirRoot));
61
61
  const outDirClient = (0, path_shim_js_1.pathJoin)(outDirRoot, 'client');
@@ -66,8 +66,8 @@ function determineOutDirs(outDirRoot) {
66
66
  }
67
67
  function getOutDirsAll(outDirRoot, root) {
68
68
  if (!outDirIsAbsolutePath(outDirRoot)) {
69
- (0, filesystemPathHandling_js_1.assertPosixPath)(outDirRoot);
70
- (0, filesystemPathHandling_js_1.assertPosixPath)(root);
69
+ (0, toPosixPath_js_1.assertPosixPath)(outDirRoot);
70
+ (0, toPosixPath_js_1.assertPosixPath)(root);
71
71
  outDirRoot = (0, path_shim_js_1.pathJoin)(root, outDirRoot);
72
72
  }
73
73
  let { outDirClient, outDirServer } = determineOutDirs(outDirRoot);
@@ -80,7 +80,7 @@ function getOutDirsAll(outDirRoot, root) {
80
80
  return { outDirRoot, outDirClient, outDirServer };
81
81
  }
82
82
  function assertNormalization(outDirAny) {
83
- (0, filesystemPathHandling_js_1.assertPosixPath)(outDirAny);
83
+ (0, toPosixPath_js_1.assertPosixPath)(outDirAny);
84
84
  (0, assert_js_1.assert)(outDirIsAbsolutePath(outDirAny));
85
85
  (0, assert_js_1.assert)(outDirAny.endsWith('/'));
86
86
  (0, assert_js_1.assert)(!outDirAny.endsWith('//'));
@@ -95,7 +95,7 @@ function assertIsNotOutDirRoot(outDir) {
95
95
  }
96
96
  /** `outDir` ends with `/server` or `/client` */
97
97
  function assertOutDirResolved(outDir, config) {
98
- (0, filesystemPathHandling_js_1.assertPosixPath)(outDir);
98
+ (0, toPosixPath_js_1.assertPosixPath)(outDir);
99
99
  assertIsNotOutDirRoot(outDir);
100
100
  (0, assert_js_1.assert)('/client'.length === '/server'.length);
101
101
  const outDirCorrected = outDir.slice(0, -1 * '/client'.length);
@@ -121,7 +121,7 @@ function getOutDirFromViteResolvedConfig(config) {
121
121
  return outDir;
122
122
  }
123
123
  function normalize(outDir) {
124
- outDir = (0, filesystemPathHandling_js_1.toPosixPath)(outDir);
124
+ outDir = (0, toPosixPath_js_1.toPosixPath)(outDir);
125
125
  outDir = outDir.replace(/\/+$/, ''); // remove trailing slashes
126
126
  return outDir;
127
127
  }
@@ -9,7 +9,6 @@ exports.ssr = plugin;
9
9
  exports.default = plugin;
10
10
  var utils_js_1 = require("./utils.js");
11
11
  Object.defineProperty(exports, "version", { enumerable: true, get: function () { return utils_js_1.PROJECT_VERSION; } });
12
- const vite_1 = require("vite");
13
12
  const utils_js_2 = require("./utils.js");
14
13
  const buildConfig_js_1 = require("./plugins/buildConfig.js");
15
14
  const previewConfig_js_1 = require("./plugins/previewConfig.js");
@@ -33,8 +32,7 @@ const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
33
32
  const resolveClientEntriesDev_js_1 = require("./resolveClientEntriesDev.js");
34
33
  const workaroundCssModuleHmr_js_1 = require("./plugins/workaroundCssModuleHmr.js");
35
34
  const workaroundVite6HmrRegression_js_1 = require("./plugins/workaroundVite6HmrRegression.js");
36
- (0, utils_js_2.markSetup_vikeVitePlugin)();
37
- assertViteVersion();
35
+ // We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
38
36
  (0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
39
37
  // Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
40
38
  function plugin(vikeVitePluginOptions = {}) {
@@ -69,10 +67,6 @@ Object.defineProperty(plugin, 'apply', {
69
67
  (0, utils_js_2.assertUsage)(false, `Add ${picocolors_1.default.cyan('vike()')} instead of ${picocolors_1.default.cyan('vike')} to vite.config.js#plugins (i.e. call the function and add the return value instead of adding the function itself)`, { showStackTrace: true });
70
68
  }
71
69
  });
72
- // package.json#peerDependencies isn't enough as users can ignore it
73
- function assertViteVersion() {
74
- (0, utils_js_2.assertVersion)('Vite', vite_1.version, '5.1.0');
75
- }
76
70
  // Ensures following works: `const vike = require('vike/plugin')` / `import vike from 'vike/plugin'`
77
71
  // - It needs to live at the end of this file, in order to ensure we do it after all assignments to `exports`.
78
72
  try {
@@ -4,9 +4,14 @@ exports.onLoad = onLoad;
4
4
  const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
5
5
  const assertSetup_js_1 = require("../../utils/assertSetup.js");
6
6
  const assertNodeVersion_js_1 = require("../../utils/assertNodeVersion.js");
7
+ const assertVersion_js_1 = require("../../utils/assertVersion.js");
8
+ const vite_1 = require("vite");
7
9
  function onLoad() {
10
+ (0, assertSetup_js_1.markSetup_vikeVitePlugin)();
8
11
  (0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
9
12
  (0, assertNodeVersion_js_1.assertNodeVersion)();
10
- // Ensure we don't bloat the server runtime with heavy plugin dependencies such as esbuild
13
+ // package.json#peerDependencies isn't enough as users can ignore it
14
+ (0, assertVersion_js_1.assertVersion)('Vite', vite_1.version, '5.1.0');
15
+ // Ensure we don't bloat the server runtime with heavy dependencies such Vite and esbuild
11
16
  (0, assertSetup_js_1.assertIsNotProductionRuntime)();
12
17
  }
@@ -8,26 +8,27 @@ exports.autoFullBuild = autoFullBuild;
8
8
  const vite_1 = require("vite");
9
9
  const utils_js_1 = require("../utils.js");
10
10
  const runPrerender_js_1 = require("../../prerender/runPrerender.js");
11
- const isPrerenderAutoRunEnabled_js_1 = require("../../prerender/isPrerenderAutoRunEnabled.js");
11
+ const context_js_1 = require("../../prerender/context.js");
12
12
  const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
13
13
  const picocolors_1 = __importDefault(require("@brillout/picocolors"));
14
14
  const logErrorHint_js_1 = require("../../runtime/renderPage/logErrorHint.js");
15
15
  const buildConfig_js_1 = require("./buildConfig.js");
16
16
  const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
17
+ const context_js_2 = require("../../api/context.js");
18
+ const context_js_3 = require("../../cli/context.js");
17
19
  let forceExit = false;
18
20
  function autoFullBuild() {
19
21
  let config;
20
- let vikeConfigGlobal;
22
+ let vikeConfig;
21
23
  return [
22
24
  {
23
25
  name: 'vike:autoFullBuild',
24
26
  apply: 'build',
25
27
  enforce: 'pre',
26
28
  async configResolved(config_) {
27
- const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config_);
28
- vikeConfigGlobal = vikeConfig.vikeConfigGlobal;
29
+ vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config_);
29
30
  config = config_;
30
- abortViteBuildSsr(vikeConfigGlobal);
31
+ abortViteBuildSsr(vikeConfig);
31
32
  },
32
33
  writeBundle: {
33
34
  /* We can't use this because it breaks Vite's logging. TODO: try again with latest Vite version.
@@ -36,7 +37,7 @@ function autoFullBuild() {
36
37
  */
37
38
  async handler(_options, bundle) {
38
39
  try {
39
- await triggerFullBuild(config, vikeConfigGlobal, bundle);
40
+ await triggerFullBuild(config, vikeConfig, bundle);
40
41
  }
41
42
  catch (err) {
42
43
  // Avoid Rollup prefixing the error with [vike:autoFullBuild], for example see https://github.com/vikejs/vike/issues/472#issuecomment-1276274203
@@ -62,10 +63,10 @@ function autoFullBuild() {
62
63
  }
63
64
  ];
64
65
  }
65
- async function triggerFullBuild(config, vikeConfigGlobal, bundle) {
66
+ async function triggerFullBuild(config, vikeConfig, bundle) {
66
67
  if (config.build.ssr)
67
68
  return; // already triggered
68
- if (isDisabled(vikeConfigGlobal))
69
+ if (isDisabled(vikeConfig))
69
70
  return;
70
71
  // Workaround for @vitejs/plugin-legacy
71
72
  // - The legacy plugin triggers its own Rollup build for the client-side.
@@ -74,43 +75,54 @@ async function triggerFullBuild(config, vikeConfigGlobal, bundle) {
74
75
  if (!bundle[buildConfig_js_1.manifestTempFile])
75
76
  return;
76
77
  const configFromCli = !(0, isViteCliCall_js_1.isViteCliCall)() ? null : (0, isViteCliCall_js_1.getViteConfigFromCli)();
77
- const configInline = {
78
- ...configFromCli,
79
- configFile: configFromCli?.configFile || config.configFile,
80
- root: config.root,
81
- build: {
82
- ...configFromCli?.build
83
- }
84
- };
85
- try {
86
- await (0, vite_1.build)({
87
- ...configInline,
78
+ let configInline;
79
+ if (config._viteConfigEnhanced) {
80
+ configInline = config._viteConfigEnhanced;
81
+ }
82
+ else {
83
+ configInline = {
84
+ ...configFromCli,
85
+ configFile: configFromCli?.configFile || config.configFile,
86
+ root: config.root,
88
87
  build: {
89
- ...configInline.build,
90
- ssr: true
88
+ ...configFromCli?.build
91
89
  }
92
- });
90
+ };
91
+ }
92
+ try {
93
+ await (0, vite_1.build)(setSSR(configInline));
93
94
  }
94
95
  catch (err) {
95
96
  console.error(err);
96
97
  (0, logErrorHint_js_1.logErrorHint)(err);
97
98
  process.exit(1);
98
99
  }
99
- if ((0, isPrerenderAutoRunEnabled_js_1.isPrerenderAutoRunEnabled)(vikeConfigGlobal)) {
100
- await (0, runPrerender_js_1.runPrerenderFromAutoRun)(configInline);
101
- forceExit = true;
100
+ if ((0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfig)) {
101
+ const { prerenderContextPublic } = await (0, runPrerender_js_1.runPrerenderFromAutoRun)(configInline);
102
+ config.vike.prerenderContext = prerenderContextPublic;
103
+ forceExit = (0, context_js_3.isVikeCli)() || (0, isViteCliCall_js_1.isViteCliCall)();
102
104
  }
103
105
  }
104
- function abortViteBuildSsr(vikeConfigGlobal) {
105
- if (vikeConfigGlobal.disableAutoFullBuild !== true && (0, isViteCliCall_js_1.isViteCliCall)() && (0, isViteCliCall_js_1.getViteConfigFromCli)()?.build.ssr) {
106
+ function setSSR(configInline) {
107
+ return {
108
+ ...configInline,
109
+ build: {
110
+ ...configInline.build,
111
+ ssr: true
112
+ }
113
+ };
114
+ }
115
+ function abortViteBuildSsr(vikeConfig) {
116
+ if (vikeConfig.global.config.disableAutoFullBuild !== true && (0, isViteCliCall_js_1.isViteCliCall)() && (0, isViteCliCall_js_1.getViteConfigFromCli)()?.build.ssr) {
106
117
  (0, utils_js_1.assertWarning)(false, `The CLI call ${picocolors_1.default.cyan('$ vite build --ssr')} is superfluous since ${picocolors_1.default.cyan('$ vite build')} also builds the server-side. If you want two separate build steps then use https://vike.dev/disableAutoFullBuild or use Vite's ${picocolors_1.default.cyan('build()')} API.`, { onlyOnce: true });
107
118
  process.exit(0);
108
119
  }
109
120
  }
110
- function isDisabled(vikeConfigGlobal) {
111
- const { disableAutoFullBuild } = vikeConfigGlobal;
112
- if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
113
- return !(0, isViteCliCall_js_1.isViteCliCall)();
121
+ function isDisabled(vikeConfig) {
122
+ const { disableAutoFullBuild } = vikeConfig.global.config;
123
+ if (disableAutoFullBuild === undefined || disableAutoFullBuild === 'prerender') {
124
+ const isViteApi = !(0, isViteCliCall_js_1.isViteCliCall)() && !(0, context_js_2.isVikeCliOrApi)();
125
+ return isViteApi;
114
126
  }
115
127
  else {
116
128
  return disableAutoFullBuild;
@@ -13,7 +13,7 @@ function baseUrls() {
13
13
  const isDev = config._isDev;
14
14
  (0, utils_js_1.assert)(typeof isDev === 'boolean');
15
15
  const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
16
- basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, config.vike.vikeConfigGlobal.baseServer, config.vike.vikeConfigGlobal.baseAssets);
16
+ basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, config.vike.global.config.baseServer ?? null, config.vike.global.config.baseAssets ?? null);
17
17
  // We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
18
18
  process.env.BASE_SERVER = basesResolved.baseServer;
19
19
  process.env.BASE_ASSETS = basesResolved.baseAssets;
@@ -29,7 +29,7 @@ function baseUrls() {
29
29
  },
30
30
  async configResolved(config) {
31
31
  const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
32
- const basesResolved2 = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets, config);
32
+ const basesResolved2 = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfig.global.config.baseServer ?? null, vikeConfig.global.config.baseAssets ?? null, config);
33
33
  (0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
34
34
  (0, utils_js_1.assert)(basesResolved2.baseAssets === basesResolved.baseAssets);
35
35
  /* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
@@ -85,7 +85,7 @@ function buildConfig() {
85
85
  name: 'vike:buildConfig:pre',
86
86
  apply: 'build',
87
87
  // Make sure other writeBundle() hooks are called after this writeBundle() hook.
88
- // - set_ASSETS_MAP() needs to be called before dist/server/ code is executed.
88
+ // - set_ASSETS_MANIFEST() needs to be called before dist/server/ code is executed.
89
89
  // - For example, the writeBundle() hook of vite-plugin-vercel needs to be called after this writeBundle() hook, otherwise: https://github.com/vikejs/vike/issues/1527
90
90
  enforce: 'pre',
91
91
  writeBundle: {
@@ -108,7 +108,7 @@ function buildConfig() {
108
108
  }
109
109
  await promises_1.default.rm(clientManifestFilePath);
110
110
  await promises_1.default.rm(serverManifestFilePath);
111
- await (0, index_js_1.set_ASSETS_MAP)(options, bundle);
111
+ await (0, index_js_1.set_ASSETS_MANIFEST)(options, bundle);
112
112
  }
113
113
  }
114
114
  }
@@ -118,7 +118,10 @@ function buildConfig() {
118
118
  async function getEntries(config) {
119
119
  const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
120
120
  const { pageConfigs } = vikeConfig;
121
- const pageFileEntries = await getPageFileEntries(config, vikeConfig.vikeConfigGlobal.includeAssetsImportedByServer); // TODO/v1-release: remove
121
+ // TODO/v1-release: remove
122
+ const pageFileEntries = await getPageFileEntries(config,
123
+ // TODO/now: add meta.default
124
+ vikeConfig.global.config.includeAssetsImportedByServer ?? true);
122
125
  (0, utils_js_1.assertUsage)(Object.keys(pageFileEntries).length !== 0 || pageConfigs.length !== 0, 'At least one page should be defined, see https://vike.dev/add');
123
126
  if ((0, utils_js_1.viteIsSSR)(config)) {
124
127
  const pageEntries = getPageEntries(pageConfigs);
@@ -4,11 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildEntry = buildEntry;
7
- exports.set_ASSETS_MAP = set_ASSETS_MAP;
7
+ exports.set_ASSETS_MANIFEST = set_ASSETS_MANIFEST;
8
8
  const plugin_1 = require("@brillout/vite-plugin-server-entry/plugin");
9
9
  const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
10
- const getVikeManifest_js_1 = require("./getVikeManifest.js");
11
- const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
12
10
  const utils_js_1 = require("../../utils.js");
13
11
  const promises_1 = __importDefault(require("fs/promises"));
14
12
  const path_1 = __importDefault(require("path"));
@@ -16,69 +14,74 @@ const module_1 = require("module");
16
14
  // @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
17
15
  const importMetaUrl = `file://${__filename}`;
18
16
  const require_ = (0, module_1.createRequire)(importMetaUrl);
19
- const ASSETS_MAP = '__VITE_ASSETS_MAP__';
17
+ const extractExportNamesPlugin_js_1 = require("../extractExportNamesPlugin.js");
18
+ const globalContext_js_1 = require("../../../runtime/globalContext.js");
19
+ const ASSETS_MANIFEST = '__VITE_ASSETS_MANIFEST__';
20
20
  function buildEntry() {
21
21
  let config;
22
- let vikeConfigGlobal;
23
22
  return [
24
23
  {
25
24
  name: 'vike:buildEntry',
26
25
  enforce: 'post',
27
26
  async configResolved(config_) {
28
27
  config = config_;
29
- const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
30
- vikeConfigGlobal = vikeConfig.vikeConfigGlobal;
31
28
  }
32
29
  },
33
30
  ...(0, plugin_1.serverProductionEntryPlugin)({
34
31
  getServerProductionEntry: () => {
35
- return getServerProductionEntryCode(config, vikeConfigGlobal);
32
+ return getServerProductionEntryCode(config);
36
33
  },
37
34
  libraryName: 'Vike'
38
35
  })
39
36
  ];
40
37
  }
41
- function getServerProductionEntryCode(config, vikeConfigGlobal) {
38
+ function getServerProductionEntryCode(config) {
42
39
  const importPath = getImportPath(config);
43
- const vikeManifest = (0, getVikeManifest_js_1.getVikeManifest)(vikeConfigGlobal, config);
44
- // Let's eventually simplify and move everything to a single virtual module
40
+ const buildInfo = {
41
+ versionAtBuildTime: utils_js_1.projectInfo.projectVersion,
42
+ usesClientRouter: (0, extractExportNamesPlugin_js_1.isUsingClientRouter)(), // TODO/v1-release: remove
43
+ viteConfigRuntime: (0, globalContext_js_1.getViteConfigRuntime)(config)
44
+ };
45
+ (0, globalContext_js_1.assertBuildInfo)(buildInfo);
46
+ // After the old design is removed, let's maybe simplify and move everything into a single virtual module
45
47
  const importerCode = [
46
48
  ` import { setGlobalContext_buildEntry } from '${importPath}';`,
47
49
  ` import * as pageFiles from '${virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeServer}';`,
48
50
  ` {`,
49
- // We first set the values to a variable because of a Rollup bug, and this workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
50
- ` const assetsManifest = ${ASSETS_MAP};`,
51
- ` const pluginManifest = ${JSON.stringify(vikeManifest, null, 2)};`,
51
+ // Because of a Rollup bug, we have to assign ASSETS_MANIFEST to a variable before passing it to setGlobalContext_buildEntry()
52
+ // - This workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
53
+ ` const assetsManifest = ${ASSETS_MANIFEST};`,
54
+ ` const buildInfo = ${JSON.stringify(buildInfo, null, 2)};`,
52
55
  ' setGlobalContext_buildEntry({',
53
56
  ` pageFiles,`,
54
57
  ` assetsManifest,`,
55
- ` pluginManifest,`,
58
+ ` buildInfo,`,
56
59
  ' });',
57
60
  ` }`,
58
61
  ''
59
62
  ].join('\n');
60
63
  return importerCode;
61
64
  }
62
- /** Set the value of the ASSETS_MAP constant inside dist/server/entry.js (or dist/server/index.js) */
63
- async function set_ASSETS_MAP(options, bundle) {
65
+ /** Set the value of the ASSETS_MANIFEST constant inside dist/server/entry.js (or dist/server/index.js) */
66
+ async function set_ASSETS_MANIFEST(options, bundle) {
64
67
  const { dir } = options;
65
68
  (0, utils_js_1.assert)(dir);
66
- const chunkPath = find_ASSETS_MAP(bundle);
69
+ const chunkPath = find_ASSETS_MANIFEST(bundle);
67
70
  const chunkFilePath = path_1.default.join(dir, chunkPath);
68
71
  const assetsJsonFilePath = path_1.default.join(dir, '..', 'assets.json');
69
72
  const [assetsJsonString, chunkFileContent] = await Promise.all([
70
73
  await promises_1.default.readFile(assetsJsonFilePath, 'utf8'),
71
74
  await promises_1.default.readFile(chunkFilePath, 'utf8')
72
75
  ]);
73
- const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MAP, assetsJsonString);
76
+ const serverEntryFileContentPatched = chunkFileContent.replace(ASSETS_MANIFEST, assetsJsonString);
74
77
  (0, utils_js_1.assert)(serverEntryFileContentPatched !== chunkFileContent);
75
78
  await promises_1.default.writeFile(chunkFilePath, serverEntryFileContentPatched);
76
79
  }
77
- function find_ASSETS_MAP(bundle) {
80
+ function find_ASSETS_MANIFEST(bundle) {
78
81
  let chunkPath;
79
82
  for (const filePath in bundle) {
80
83
  const chunk = bundle[filePath];
81
- if ('code' in chunk && chunk.code.includes(ASSETS_MAP)) {
84
+ if ('code' in chunk && chunk.code.includes(ASSETS_MANIFEST)) {
82
85
  (0, utils_js_1.assert)(!chunkPath);
83
86
  chunkPath = filePath;
84
87
  }