vike 0.4.237-commit-2c1db32 → 0.4.237-commit-cc7f0f6

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.
@@ -420,13 +420,18 @@ async function updateUserFiles() {
420
420
  async function createGlobalContext(virtualFileExportsGlobalEntry) {
421
421
  debug('createGlobalContext()');
422
422
  (0, utils_js_1.assert)(!(0, getVikeConfigError_js_1.getVikeConfigErrorBuild)());
423
- const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExportsGlobalEntry, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
423
+ const globalContextPromise = (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExportsGlobalEntry, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
424
+ debug('createGlobalContext() - done [sync]');
425
+ // We define an early globalContext version synchronously, so that getGlobalContextSync() can be called early.
426
+ // - Required by vike-vercel
427
+ (0, utils_js_1.assert)(globalObject.globalContext);
428
+ const globalContext = await globalContextPromise;
424
429
  (0, assertV1Design_js_1.assertV1Design)(
425
430
  // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
426
431
  globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
427
432
  assertGlobalContextIsDefined();
428
433
  (0, utils_js_1.onSetupRuntime)();
429
- debug('createGlobalContext() - done');
434
+ debug('createGlobalContext() - done [async]');
430
435
  // Never actually used, only used for TypeScript `ReturnType<typeof createGlobalContext>`
431
436
  return globalContext;
432
437
  }
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.pluginBuildApp = pluginBuildApp;
7
- exports.isPrerenderForceExit = isPrerenderForceExit;
8
7
  const runPrerenderEntry_js_1 = require("../../../prerender/runPrerenderEntry.js");
9
8
  const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
10
9
  const utils_js_1 = require("../../utils.js");
@@ -135,12 +134,12 @@ async function triggerPrerendering(config, viteEnv, bundle) {
135
134
  // - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
136
135
  if (!bundle[(0, getManifestFilePathRelative_js_1.getManifestFilePathRelative)(config.build.manifest)])
137
136
  return;
137
+ if (!(0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfig))
138
+ return;
138
139
  const configInline = getFullBuildInlineConfig(config);
139
- if ((0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfig)) {
140
- const res = await (0, runPrerenderEntry_js_2.runPrerenderFromAutoRun)(configInline);
141
- globalObject.forceExit = res.forceExit;
142
- (0, utils_js_1.assert)((0, context_js_1.wasPrerenderRun)());
143
- }
140
+ const res = await (0, runPrerenderEntry_js_2.runPrerenderFromAutoRun)(configInline);
141
+ globalObject.forceExit = res.forceExit;
142
+ (0, utils_js_1.assert)((0, context_js_1.wasPrerenderRun)());
144
143
  }
145
144
  async function abortViteBuildSsr() {
146
145
  const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
@@ -10,12 +10,13 @@ const prepareGlobalContextForPublicUsage_js_1 = require("./prepareGlobalContextF
10
10
  const getHook_js_1 = require("./hooks/getHook.js");
11
11
  const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
12
12
  exports.getGlobalContextSyncErrMsg = getGlobalContextSyncErrMsg;
13
- const globalObject_ = (0, utils_js_1.getGlobalObject)('shared/createGlobalContextShared.ts', {});
14
13
  // TO-DO/eventually use flat globalContext — like flat pageContext
15
- async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
14
+ async function createGlobalContextShared(virtualFileExportsGlobalEntry,
15
+ // TODO/now rename previousCallPromise to previousCreateGlobalContextPromise
16
+ globalObject, addGlobalContext,
16
17
  // TO-DO/next-major-release: we'll be able to remove addGlobalContextTmp after loadPageRoutes() is sync (it will be sync after we remove the old design)
17
18
  addGlobalContextTmp, addGlobalContextAsync) {
18
- const { previousCallPromise } = globalObject_;
19
+ const { previousCallPromise } = globalObject;
19
20
  const { promise, resolve } = (0, utils_js_1.genPromise)({
20
21
  // Avoid this Cloudflare Worker error:
21
22
  // ```console
@@ -23,8 +24,11 @@ addGlobalContextTmp, addGlobalContextAsync) {
23
24
  // ```
24
25
  timeout: null,
25
26
  });
26
- globalObject_.previousCallPromise = promise;
27
- await previousCallPromise;
27
+ globalObject.previousCallPromise = promise;
28
+ if (previousCallPromise) {
29
+ (0, utils_js_1.assert)(globalObject.globalContext);
30
+ await previousCallPromise;
31
+ }
28
32
  const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
29
33
  let isNewGlobalContext;
30
34
  if (!globalObject.globalContext) {
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PROJECT_VERSION = void 0;
4
4
  // Automatically updated by @brillout/release-me
5
- exports.PROJECT_VERSION = '0.4.237-commit-2c1db32';
5
+ exports.PROJECT_VERSION = '0.4.237-commit-cc7f0f6';
@@ -416,13 +416,18 @@ async function updateUserFiles() {
416
416
  async function createGlobalContext(virtualFileExportsGlobalEntry) {
417
417
  debug('createGlobalContext()');
418
418
  assert(!getVikeConfigErrorBuild());
419
- const globalContext = await createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
419
+ const globalContextPromise = createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
420
+ debug('createGlobalContext() - done [sync]');
421
+ // We define an early globalContext version synchronously, so that getGlobalContextSync() can be called early.
422
+ // - Required by vike-vercel
423
+ assert(globalObject.globalContext);
424
+ const globalContext = await globalContextPromise;
420
425
  assertV1Design(
421
426
  // pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
422
427
  globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
423
428
  assertGlobalContextIsDefined();
424
429
  onSetupRuntime();
425
- debug('createGlobalContext() - done');
430
+ debug('createGlobalContext() - done [async]');
426
431
  // Never actually used, only used for TypeScript `ReturnType<typeof createGlobalContext>`
427
432
  return globalContext;
428
433
  }
@@ -1,5 +1,3 @@
1
1
  export { pluginBuildApp };
2
- export { isPrerenderForceExit };
3
2
  import type { Plugin } from 'vite';
4
3
  declare function pluginBuildApp(): Plugin[];
5
- declare function isPrerenderForceExit(): boolean;
@@ -1,5 +1,4 @@
1
1
  export { pluginBuildApp };
2
- export { isPrerenderForceExit };
3
2
  import { runPrerender_forceExit } from '../../../prerender/runPrerenderEntry.js';
4
3
  import { resolveOutDir } from '../../shared/getOutDirs.js';
5
4
  import { assert, assertWarning, getGlobalObject, onSetupBuild } from '../../utils.js';
@@ -130,12 +129,12 @@ async function triggerPrerendering(config, viteEnv, bundle) {
130
129
  // - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
131
130
  if (!bundle[getManifestFilePathRelative(config.build.manifest)])
132
131
  return;
132
+ if (!isPrerenderAutoRunEnabled(vikeConfig))
133
+ return;
133
134
  const configInline = getFullBuildInlineConfig(config);
134
- if (isPrerenderAutoRunEnabled(vikeConfig)) {
135
- const res = await runPrerenderFromAutoRun(configInline);
136
- globalObject.forceExit = res.forceExit;
137
- assert(wasPrerenderRun());
138
- }
135
+ const res = await runPrerenderFromAutoRun(configInline);
136
+ globalObject.forceExit = res.forceExit;
137
+ assert(wasPrerenderRun());
139
138
  }
140
139
  async function abortViteBuildSsr() {
141
140
  const vikeConfig = await getVikeConfigInternal();
@@ -12,6 +12,7 @@ declare const getGlobalContextSyncErrMsg = "The global context isn't set yet, ca
12
12
  declare function createGlobalContextShared<GlobalContextAdded extends Record<string, any>, GlobalContextAddedAsync extends Record<string, any>>(virtualFileExportsGlobalEntry: unknown, globalObject: {
13
13
  globalContext?: Record<string, unknown>;
14
14
  onCreateGlobalContextHooks?: Hook[];
15
+ previousCallPromise?: Promise<void>;
15
16
  }, addGlobalContext?: (globalContext: GlobalContextBase) => GlobalContextAdded, addGlobalContextTmp?: (globalContext: GlobalContextBase) => Promise<GlobalContextAdded>, addGlobalContextAsync?: (globalContext: GlobalContextBase) => Promise<GlobalContextAddedAsync>): Promise<{
16
17
  /**
17
18
  * Useful for distinguishing `globalContext` from other objects and narrowing down TypeScript unions.
@@ -1,18 +1,19 @@
1
1
  export { createGlobalContextShared };
2
2
  export { getGlobalContextSyncErrMsg };
3
- import { changeEnumerable, genPromise, getGlobalObject, objectAssign, objectReplace, unique } from './utils.js';
3
+ import { assert, changeEnumerable, genPromise, objectAssign, objectReplace, unique } from './utils.js';
4
4
  import { parseVirtualFileExportsGlobalEntry } from './getPageFiles/parseVirtualFileExportsGlobalEntry.js';
5
5
  import { resolveVikeConfigPublicGlobal, resolveVikeConfigPublicPageEagerLoaded, } from './page-configs/resolveVikeConfigPublic.js';
6
6
  import { execHookGlobal } from './hooks/execHook.js';
7
7
  import { prepareGlobalContextForPublicUsage } from './prepareGlobalContextForPublicUsage.js';
8
8
  import { getHookFromPageConfigGlobalCumulative } from './hooks/getHook.js';
9
9
  const getGlobalContextSyncErrMsg = "The global context isn't set yet, call getGlobalContextSync() later or use getGlobalContext() instead.";
10
- const globalObject_ = getGlobalObject('shared/createGlobalContextShared.ts', {});
11
10
  // TO-DO/eventually use flat globalContext — like flat pageContext
12
- async function createGlobalContextShared(virtualFileExportsGlobalEntry, globalObject, addGlobalContext,
11
+ async function createGlobalContextShared(virtualFileExportsGlobalEntry,
12
+ // TODO/now rename previousCallPromise to previousCreateGlobalContextPromise
13
+ globalObject, addGlobalContext,
13
14
  // TO-DO/next-major-release: we'll be able to remove addGlobalContextTmp after loadPageRoutes() is sync (it will be sync after we remove the old design)
14
15
  addGlobalContextTmp, addGlobalContextAsync) {
15
- const { previousCallPromise } = globalObject_;
16
+ const { previousCallPromise } = globalObject;
16
17
  const { promise, resolve } = genPromise({
17
18
  // Avoid this Cloudflare Worker error:
18
19
  // ```console
@@ -20,8 +21,11 @@ addGlobalContextTmp, addGlobalContextAsync) {
20
21
  // ```
21
22
  timeout: null,
22
23
  });
23
- globalObject_.previousCallPromise = promise;
24
- await previousCallPromise;
24
+ globalObject.previousCallPromise = promise;
25
+ if (previousCallPromise) {
26
+ assert(globalObject.globalContext);
27
+ await previousCallPromise;
28
+ }
25
29
  const globalContext = createGlobalContextBase(virtualFileExportsGlobalEntry);
26
30
  let isNewGlobalContext;
27
31
  if (!globalObject.globalContext) {
@@ -1 +1 @@
1
- export declare const PROJECT_VERSION: "0.4.237-commit-2c1db32";
1
+ export declare const PROJECT_VERSION: "0.4.237-commit-cc7f0f6";
@@ -1,2 +1,2 @@
1
1
  // Automatically updated by @brillout/release-me
2
- export const PROJECT_VERSION = '0.4.237-commit-2c1db32';
2
+ export const PROJECT_VERSION = '0.4.237-commit-cc7f0f6';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike",
3
- "version": "0.4.237-commit-2c1db32",
3
+ "version": "0.4.237-commit-cc7f0f6",
4
4
  "repository": "https://github.com/vikejs/vike",
5
5
  "exports": {
6
6
  "./server": {