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.
- package/dist/cjs/node/runtime/globalContext.js +7 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +5 -6
- package/dist/cjs/shared/createGlobalContextShared.js +9 -5
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/runtime/globalContext.js +7 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +5 -6
- package/dist/esm/shared/createGlobalContextShared.d.ts +1 -0
- package/dist/esm/shared/createGlobalContextShared.js +10 -6
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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,
|
|
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 } =
|
|
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
|
-
|
|
27
|
-
|
|
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) {
|
|
@@ -416,13 +416,18 @@ async function updateUserFiles() {
|
|
|
416
416
|
async function createGlobalContext(virtualFileExportsGlobalEntry) {
|
|
417
417
|
debug('createGlobalContext()');
|
|
418
418
|
assert(!getVikeConfigErrorBuild());
|
|
419
|
-
const
|
|
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,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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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,
|
|
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,
|
|
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 } =
|
|
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
|
-
|
|
24
|
-
|
|
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-
|
|
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-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.237-commit-cc7f0f6';
|