vike 0.4.236-commit-e752d12 → 0.4.236-commit-79f1ef0
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/client/shared/createGetGlobalContextClient.js +20 -10
- package/dist/cjs/client/shared/utils.js +1 -0
- package/dist/cjs/node/runtime/globalContext.js +104 -20
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +3 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +3 -1
- package/dist/cjs/node/runtime/utils.js +4 -0
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/node/shared/virtualFiles/virtualFileEntry.js +16 -14
- package/dist/cjs/node/shared/virtualFiles/virtualFilePageConfigLazy.js +10 -4
- package/dist/cjs/node/vite/index.js +2 -0
- package/dist/cjs/node/vite/plugins/pluginBuild/handleAssetsManifest.js +19 -11
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -3
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +12 -7
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginCommon.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +102 -58
- package/dist/cjs/node/vite/plugins/pluginEnvVars.js +3 -3
- package/dist/cjs/node/vite/plugins/pluginExtractAssets.js +3 -4
- package/dist/cjs/node/vite/plugins/pluginExtractExportNames.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginNonRunnableDev.js +51 -0
- package/dist/cjs/node/vite/plugins/pluginReplaceConstants.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.js +4 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +4 -5
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +1 -0
- package/dist/cjs/node/vite/shared/getMagicString.js +18 -0
- package/dist/cjs/node/vite/shared/getManifestFilePathRelative.js +10 -0
- package/dist/cjs/node/vite/utils.js +1 -0
- package/dist/cjs/shared/createGlobalContextShared.js +5 -1
- package/dist/cjs/shared/getPageFiles/parseVirtualFileExports.js +6 -0
- package/dist/cjs/shared/getProxyForPublicUsage.js +2 -2
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assertSetup.js +2 -0
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/cjs/utils/getViteRPC.js +79 -0
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -0
- package/dist/cjs/utils/isRunnableDevEnvironment.js +9 -0
- package/dist/cjs/utils/virtualFileId.js +39 -0
- package/dist/esm/client/runtime-client-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/getPageContextFromHooks.d.ts +2 -2
- package/dist/esm/client/runtime-client-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/history.d.ts +4 -2
- package/dist/esm/client/runtime-client-routing/history.js +13 -35
- package/dist/esm/client/runtime-client-routing/initClientRouter.js +3 -2
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-client-routing/renderPageClientSide.js +43 -30
- package/dist/esm/client/runtime-server-routing/createPageContextClientSide.d.ts +1 -1
- package/dist/esm/client/runtime-server-routing/globalContext.d.ts +1 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.d.ts +1 -1
- package/dist/esm/client/shared/createGetGlobalContextClient.js +20 -10
- package/dist/esm/client/shared/utils.d.ts +1 -0
- package/dist/esm/client/shared/utils.js +1 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +40 -132
- package/dist/esm/node/runtime/globalContext.d.ts +32 -52
- package/dist/esm/node/runtime/globalContext.js +105 -21
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +4 -2
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +10 -33
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +4 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +20 -66
- package/dist/esm/node/runtime/renderPage.d.ts +10 -33
- package/dist/esm/node/runtime/utils.d.ts +4 -0
- package/dist/esm/node/runtime/utils.js +4 -0
- package/dist/esm/node/shared/utils.d.ts +1 -0
- package/dist/esm/node/shared/utils.js +1 -0
- package/dist/esm/node/shared/virtualFiles/virtualFileEntry.js +16 -14
- package/dist/esm/node/shared/virtualFiles/virtualFilePageConfigLazy.js +11 -5
- package/dist/esm/node/vite/index.js +2 -0
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.js +19 -11
- package/dist/esm/node/vite/plugins/pluginBuild/pluginAutoFullBuild.js +2 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +12 -7
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +3 -0
- package/dist/esm/node/vite/plugins/pluginCommon.js +1 -0
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +103 -59
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -4
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.d.ts +26 -0
- package/dist/esm/node/vite/plugins/pluginNonRunnableDev.js +49 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +1 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigsEager.js +4 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +3 -4
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +1 -0
- package/dist/esm/node/vite/shared/getMagicString.d.ts +9 -0
- package/dist/esm/node/vite/shared/getMagicString.js +13 -0
- package/dist/esm/node/vite/shared/getManifestFilePathRelative.d.ts +2 -0
- package/dist/esm/node/vite/shared/getManifestFilePathRelative.js +8 -0
- package/dist/esm/node/vite/utils.d.ts +1 -0
- package/dist/esm/node/vite/utils.js +1 -0
- package/dist/esm/shared/createGlobalContextShared.d.ts +3 -3
- package/dist/esm/shared/createGlobalContextShared.js +5 -1
- package/dist/esm/shared/getPageFiles/parseVirtualFileExports.js +6 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assertSetup.js +2 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +1 -0
- package/dist/esm/utils/getViteRPC.d.ts +6 -0
- package/dist/esm/utils/getViteRPC.js +77 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +7 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -0
- package/dist/esm/utils/isRunnableDevEnvironment.d.ts +3 -0
- package/dist/esm/utils/isRunnableDevEnvironment.js +7 -0
- package/dist/esm/utils/virtualFileId.d.ts +6 -0
- package/dist/esm/{node/shared/virtualFiles.js → utils/virtualFileId.js} +15 -17
- package/package.json +12 -3
- package/dist/cjs/node/shared/virtualFiles.js +0 -41
- package/dist/esm/node/shared/virtualFiles.d.ts +0 -8
|
@@ -7,10 +7,10 @@ const createGlobalContextShared_js_1 = require("../../shared/createGlobalContext
|
|
|
7
7
|
const getJsonSerializedInHtml_js_1 = require("./getJsonSerializedInHtml.js");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
9
|
const globalObject = (0, utils_js_1.getGlobalObject)('createGetGlobalContextClient.ts', (() => {
|
|
10
|
-
const { promise:
|
|
10
|
+
const { promise: globalContextInitialPromise, resolve: globalContextInitialPromiseResolve } = (0, utils_js_1.genPromise)();
|
|
11
11
|
return {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
globalContextInitialPromise,
|
|
13
|
+
globalContextInitialPromiseResolve,
|
|
14
14
|
};
|
|
15
15
|
})());
|
|
16
16
|
function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGlobalContext) {
|
|
@@ -21,18 +21,22 @@ function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGl
|
|
|
21
21
|
return getGlobalContext;
|
|
22
22
|
async function getGlobalContext() {
|
|
23
23
|
// Cache
|
|
24
|
-
if (globalObject.
|
|
24
|
+
if (globalObject.virtualFileExports &&
|
|
25
25
|
// Don't break HMR
|
|
26
|
-
globalObject.
|
|
27
|
-
|
|
26
|
+
globalObject.virtualFileExports === virtualFileExports) {
|
|
27
|
+
const globalContext = await globalObject.globalContextPromise;
|
|
28
|
+
return globalContext;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
globalObject.virtualFileExports = virtualFileExports;
|
|
28
32
|
}
|
|
29
33
|
// Create
|
|
30
|
-
const
|
|
34
|
+
const globalContextPromise = (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, undefined, async (globalContext) => {
|
|
31
35
|
const globalContextAddendum = {
|
|
32
36
|
/**
|
|
33
37
|
* Whether the environment is client-side or server-side / pre-rendering.
|
|
34
38
|
*
|
|
35
|
-
* We recommend using `
|
|
39
|
+
* We recommend using `({}).SSR` instead, see https://vike.dev/globalContext
|
|
36
40
|
*/
|
|
37
41
|
isClientSide: true,
|
|
38
42
|
};
|
|
@@ -40,18 +44,24 @@ function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGl
|
|
|
40
44
|
(0, utils_js_1.objectAssign)(globalContextAddendum, await addGlobalContext?.(globalContext));
|
|
41
45
|
return globalContextAddendum;
|
|
42
46
|
});
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
globalObject.globalContextPromise = globalContextPromise;
|
|
48
|
+
const globalContext = await globalContextPromise;
|
|
49
|
+
(0, utils_js_1.assert)(globalObject.globalContext === globalContext);
|
|
50
|
+
globalObject.globalContextInitialPromiseResolve();
|
|
45
51
|
// Return
|
|
46
52
|
return globalContext;
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
55
|
async function getGlobalContext() {
|
|
56
|
+
await globalObject.globalContextInitialPromise;
|
|
50
57
|
const globalContext = await globalObject.globalContextPromise;
|
|
58
|
+
(0, utils_js_1.assert)(globalContext);
|
|
59
|
+
(0, utils_js_1.checkType)(globalContext);
|
|
51
60
|
return globalContext;
|
|
52
61
|
}
|
|
53
62
|
function getGlobalContextSync() {
|
|
54
63
|
const { globalContext } = globalObject;
|
|
55
64
|
(0, utils_js_1.assertUsage)(globalContext, createGlobalContextShared_js_1.getGlobalContextSyncErrMsg);
|
|
65
|
+
(0, utils_js_1.checkType)(globalContext);
|
|
56
66
|
return globalContext;
|
|
57
67
|
}
|
|
@@ -20,3 +20,4 @@ __exportStar(require("../../utils/getGlobalObject.js"), exports);
|
|
|
20
20
|
__exportStar(require("../../utils/objectAssign.js"), exports);
|
|
21
21
|
__exportStar(require("../../utils/hasProp.js"), exports);
|
|
22
22
|
__exportStar(require("../../utils/genPromise.js"), exports);
|
|
23
|
+
__exportStar(require("../../utils/checkType.js"), exports);
|
|
@@ -21,6 +21,12 @@ exports.setGlobalContext_buildEntry = setGlobalContext_buildEntry;
|
|
|
21
21
|
exports.clearGlobalContext = clearGlobalContext;
|
|
22
22
|
exports.assertBuildInfo = assertBuildInfo;
|
|
23
23
|
exports.updateUserFiles = updateUserFiles;
|
|
24
|
+
// TODO/now: use isProductionEnvironment() instead of globalObject.isProduction
|
|
25
|
+
// TODO/now: rename:
|
|
26
|
+
// - isProduction => isProductionEnvironment
|
|
27
|
+
// - setIsProduction => setIsProductionEnvironment
|
|
28
|
+
// - setGlobalContext_isProduction => setGlobalContext_isProductionEnvironment
|
|
29
|
+
// - sProductionEnvironment => sDevEnv
|
|
24
30
|
// The core logic revolves around:
|
|
25
31
|
// - virtualFileExports is the main requirement
|
|
26
32
|
// - In production: globalObject.buildEntry which is the production entry set by @brillout/vite-plugin-server-entry
|
|
@@ -48,6 +54,7 @@ const globalObject = (0, utils_js_1.getGlobalObject)('runtime/globalContext.ts',
|
|
|
48
54
|
const globalObjectTyped = globalObject;
|
|
49
55
|
const vikeConfigErrorRecoverMsg = picocolors_1.default.bold(picocolors_1.default.green('Vike config loaded'));
|
|
50
56
|
exports.vikeConfigErrorRecoverMsg = vikeConfigErrorRecoverMsg;
|
|
57
|
+
(0, utils_js_1.assertIsNotBrowser)();
|
|
51
58
|
async function getGlobalContextServerInternal() {
|
|
52
59
|
// getGlobalContextServerInternal() should always be called after initGlobalContext()
|
|
53
60
|
(0, utils_js_1.assert)(globalObject.isInitialized);
|
|
@@ -134,10 +141,12 @@ async function setGlobalContext_viteDevServer(viteDevServer) {
|
|
|
134
141
|
(0, utils_js_1.assert)(globalObject.viteConfig);
|
|
135
142
|
globalObject.viteDevServer = viteDevServer;
|
|
136
143
|
globalObject.viteDevServerPromiseResolve(viteDevServer);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
144
|
+
if (isRunnable(viteDevServer)) {
|
|
145
|
+
const { success } = await updateUserFiles();
|
|
146
|
+
if (!success)
|
|
147
|
+
return;
|
|
148
|
+
assertGlobalContextIsDefined();
|
|
149
|
+
}
|
|
141
150
|
}
|
|
142
151
|
function setGlobalContext_viteConfig(viteConfig, viteConfigRuntime) {
|
|
143
152
|
if (globalObject.viteConfig)
|
|
@@ -154,6 +163,7 @@ function setGlobalContext_isPrerendering() {
|
|
|
154
163
|
globalObject.isPrerendering = true;
|
|
155
164
|
setIsProduction(true);
|
|
156
165
|
}
|
|
166
|
+
// TODO/now: `rename tolerateContraditction tolerateContradiction`
|
|
157
167
|
function setGlobalContext_isProduction(isProduction, tolerateContraditction = false) {
|
|
158
168
|
if (debug.isActivated)
|
|
159
169
|
debug('setGlobalContext_isProduction()', { isProduction, tolerateContraditction });
|
|
@@ -205,7 +215,13 @@ async function initGlobalContext() {
|
|
|
205
215
|
const { isProduction } = globalObject;
|
|
206
216
|
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
207
217
|
if (!isProduction) {
|
|
208
|
-
|
|
218
|
+
if (isProcessSharedWithVite()) {
|
|
219
|
+
await globalObject.viteDevServerPromise;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
(0, utils_js_1.assert)(isNonRunnableDev());
|
|
223
|
+
await updateUserFiles();
|
|
224
|
+
}
|
|
209
225
|
(0, utils_js_1.assert)(globalObject.waitForUserFilesUpdate);
|
|
210
226
|
await globalObject.waitForUserFilesUpdate;
|
|
211
227
|
}
|
|
@@ -339,16 +355,46 @@ async function updateUserFiles() {
|
|
|
339
355
|
// Avoid race condition: abort if there is a new globalObject.viteDevServer (happens when vite.config.js is modified => Vite's dev server is fully reloaded).
|
|
340
356
|
viteDevServer !== globalObject.viteDevServer;
|
|
341
357
|
const { viteDevServer } = globalObject;
|
|
342
|
-
(0, utils_js_1.assert)(viteDevServer);
|
|
343
358
|
let hasError = false;
|
|
344
359
|
let virtualFileExports;
|
|
345
360
|
let err;
|
|
346
|
-
|
|
347
|
-
|
|
361
|
+
if (viteDevServer) {
|
|
362
|
+
(0, utils_js_1.assert)(isRunnable(viteDevServer));
|
|
363
|
+
/* We don't use runner.import() yet, because as of vite@7.0.6 (July 2025) runner.import() unexpectedly invalidates the module graph, which is a unexpected behavior that doesn't happen with ssrLoadModule()
|
|
364
|
+
// Vite 6
|
|
365
|
+
try {
|
|
366
|
+
virtualFileExports = await (viteDevServer.environments.ssr as RunnableDevEnvironment).runner.import(
|
|
367
|
+
'virtual:vike:entry:server',
|
|
368
|
+
)
|
|
369
|
+
} catch (err_) {
|
|
370
|
+
hasError = true
|
|
371
|
+
err = err_
|
|
372
|
+
}
|
|
373
|
+
*/
|
|
374
|
+
// Vite 5
|
|
375
|
+
try {
|
|
376
|
+
virtualFileExports = await viteDevServer.ssrLoadModule(virtualFileEntry_js_1.virtualFileIdEntryServer);
|
|
377
|
+
}
|
|
378
|
+
catch (err_) {
|
|
379
|
+
hasError = true;
|
|
380
|
+
err = err_;
|
|
381
|
+
}
|
|
348
382
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
383
|
+
else {
|
|
384
|
+
try {
|
|
385
|
+
/* We use __VIKE__DYNAMIC_IMPORT instead of directly using import() to workaround what seems to be a Vite HMR bug:
|
|
386
|
+
```js
|
|
387
|
+
assert(false)
|
|
388
|
+
// This line breaks the HMR of regular (runnable) apps, even though (as per the assert() above) it's never run. It seems to be a Vite bug: handleHotUpdate() receives an empty `modules` list.
|
|
389
|
+
import('virtual:vike:entry:server')
|
|
390
|
+
```
|
|
391
|
+
*/
|
|
392
|
+
virtualFileExports = await __VIKE__DYNAMIC_IMPORT('virtual:vike:entry:server');
|
|
393
|
+
}
|
|
394
|
+
catch (err_) {
|
|
395
|
+
hasError = true;
|
|
396
|
+
err = err_;
|
|
397
|
+
}
|
|
352
398
|
}
|
|
353
399
|
if (isOutdated())
|
|
354
400
|
return { success: false };
|
|
@@ -374,7 +420,7 @@ async function updateUserFiles() {
|
|
|
374
420
|
async function setGlobalContext(virtualFileExports) {
|
|
375
421
|
debug('setGlobalContext()');
|
|
376
422
|
(0, utils_js_1.assert)(!(0, getVikeConfigError_js_1.getVikeConfigErrorBuild)());
|
|
377
|
-
const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContext, addGlobalContextTmp);
|
|
423
|
+
const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContext, addGlobalContextTmp, addGlobalContextAsync);
|
|
378
424
|
(0, assertV1Design_js_1.assertV1Design)(
|
|
379
425
|
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
380
426
|
globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
|
|
@@ -400,23 +446,18 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
400
446
|
_pageRoutes: pageRoutes,
|
|
401
447
|
_onBeforeRouteHook: onBeforeRouteHook,
|
|
402
448
|
};
|
|
403
|
-
const { viteDevServer, viteConfig,
|
|
449
|
+
const { viteDevServer, viteConfig, isPrerendering, isProduction } = globalObject;
|
|
404
450
|
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
405
451
|
if (!isProduction) {
|
|
406
|
-
(0, utils_js_1.assert)(viteDevServer);
|
|
407
452
|
(0, utils_js_1.assert)(globalContext); // main common requirement
|
|
408
|
-
(0, utils_js_1.assert)(viteConfig);
|
|
409
|
-
(0, utils_js_1.assert)(viteConfigRuntime);
|
|
410
453
|
(0, utils_js_1.assert)(!isPrerendering);
|
|
411
454
|
return {
|
|
412
455
|
...globalContextBase,
|
|
413
|
-
...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
|
|
414
456
|
_isProduction: false,
|
|
415
457
|
_isPrerendering: false,
|
|
416
458
|
assetsManifest: null,
|
|
417
459
|
_viteDevServer: viteDevServer,
|
|
418
460
|
viteConfig,
|
|
419
|
-
viteConfigRuntime,
|
|
420
461
|
};
|
|
421
462
|
}
|
|
422
463
|
else {
|
|
@@ -427,11 +468,9 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
427
468
|
(0, utils_js_1.assert)(assetsManifest);
|
|
428
469
|
const globalContextBase2 = {
|
|
429
470
|
...globalContextBase,
|
|
430
|
-
...resolveBaseRuntime(buildInfo.viteConfigRuntime, globalContext.config),
|
|
431
471
|
_isProduction: true,
|
|
432
472
|
assetsManifest,
|
|
433
473
|
_viteDevServer: null,
|
|
434
|
-
viteConfigRuntime: buildInfo.viteConfigRuntime,
|
|
435
474
|
_usesClientRouter: buildInfo.usesClientRouter,
|
|
436
475
|
};
|
|
437
476
|
if (isPrerendering) {
|
|
@@ -451,6 +490,27 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
451
490
|
}
|
|
452
491
|
}
|
|
453
492
|
}
|
|
493
|
+
async function addGlobalContextAsync(globalContext) {
|
|
494
|
+
debug('addGlobalContextAsync()');
|
|
495
|
+
let { viteConfigRuntime, buildInfo } = globalObject;
|
|
496
|
+
if (!viteConfigRuntime) {
|
|
497
|
+
if (buildInfo) {
|
|
498
|
+
viteConfigRuntime = buildInfo.viteConfigRuntime;
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
(0, utils_js_1.assert)(!isProcessSharedWithVite()); // process shared with Vite => globalObject.viteConfigRuntime should be set
|
|
502
|
+
(0, utils_js_1.assert)(!globalObject.isProduction); // production => globalObject.buildInfo.viteConfigRuntime should be set
|
|
503
|
+
(0, utils_js_1.assert)(isNonRunnableDev());
|
|
504
|
+
const rpc = (0, utils_js_1.getViteRPC)();
|
|
505
|
+
viteConfigRuntime = await rpc.getViteConfigRuntimeRPC();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
(0, utils_js_1.assert)(viteConfigRuntime);
|
|
509
|
+
return {
|
|
510
|
+
viteConfigRuntime,
|
|
511
|
+
...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
|
|
512
|
+
};
|
|
513
|
+
}
|
|
454
514
|
function clearGlobalContext() {
|
|
455
515
|
debug('clearGlobalContext()');
|
|
456
516
|
(0, utils_js_1.objectReplace)(globalObject, getInitialGlobalObject(), ['buildEntryPrevious']);
|
|
@@ -459,6 +519,7 @@ function getInitialGlobalObject() {
|
|
|
459
519
|
debug('getInitialGlobalObject()');
|
|
460
520
|
const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
|
|
461
521
|
return {
|
|
522
|
+
isProduction: isNonRunnableDev() ? false : undefined,
|
|
462
523
|
viteDevServerPromise,
|
|
463
524
|
viteDevServerPromiseResolve,
|
|
464
525
|
};
|
|
@@ -469,3 +530,26 @@ function resolveBaseRuntime(viteConfigRuntime, config) {
|
|
|
469
530
|
const baseAssetsUnresolved = config.baseAssets ?? null;
|
|
470
531
|
return (0, resolveBase_js_1.resolveBase)(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
|
|
471
532
|
}
|
|
533
|
+
function isProcessSharedWithVite() {
|
|
534
|
+
const yes = globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE ?? false;
|
|
535
|
+
if (yes)
|
|
536
|
+
(0, utils_js_1.assert)(!isNonRunnableDev());
|
|
537
|
+
return yes;
|
|
538
|
+
}
|
|
539
|
+
function isRunnable(viteDevServer) {
|
|
540
|
+
const yes =
|
|
541
|
+
// Vite 5
|
|
542
|
+
!viteDevServer.environments ||
|
|
543
|
+
// Vite 6 or above
|
|
544
|
+
(0, utils_js_1.isRunnableDevEnvironment)(viteDevServer.environments.ssr);
|
|
545
|
+
if (yes)
|
|
546
|
+
(0, utils_js_1.assert)(!isNonRunnableDev());
|
|
547
|
+
return yes;
|
|
548
|
+
}
|
|
549
|
+
function isNonRunnableDev() {
|
|
550
|
+
if (typeof __VIKE__IS_NON_RUNNABLE_DEV === 'undefined')
|
|
551
|
+
return null;
|
|
552
|
+
const yes = __VIKE__IS_NON_RUNNABLE_DEV;
|
|
553
|
+
(0, utils_js_1.assert)(typeof yes === 'boolean');
|
|
554
|
+
return yes;
|
|
555
|
+
}
|
|
@@ -16,7 +16,9 @@ async function getViteDevScript(pageContext) {
|
|
|
16
16
|
const fakeHtmlBegin = '<html> <head>'; // White space to test whether user is using a minifier
|
|
17
17
|
const fakeHtmlEnd = '</head><body></body></html>';
|
|
18
18
|
let fakeHtml = fakeHtmlBegin + fakeHtmlEnd;
|
|
19
|
-
fakeHtml =
|
|
19
|
+
fakeHtml = viteDevServer
|
|
20
|
+
? await viteDevServer.transformIndexHtml('/', fakeHtml)
|
|
21
|
+
: await (0, utils_js_1.getViteRPC)().transformIndexHtmlRPC(fakeHtml);
|
|
20
22
|
(0, utils_js_1.assertUsage)(!fakeHtml.includes('vite-plugin-pwa'), `The HTML transformer of ${picocolors_1.default.cyan('vite-plugin-pwa')} cannot be applied, see workaround at https://github.com/vikejs/vike/issues/388#issuecomment-1199280084`);
|
|
21
23
|
(0, utils_js_1.assertUsage)(!fakeHtml.startsWith(fakeHtmlBegin.replace(' ', '')), `Vite plugins that minify the HTML cannot be applied, see https://github.com/vikejs/vike/issues/224`);
|
|
22
24
|
(0, utils_js_1.assertUsage)(fakeHtml.startsWith(fakeHtmlBegin) && fakeHtml.endsWith(fakeHtmlEnd), `You are using a Vite Plugin that transforms the HTML in a way that conflicts with Vike. ${reachOutCTA}`);
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.retrieveAssetsDev = retrieveAssetsDev;
|
|
4
4
|
const utils_js_1 = require("../../utils.js");
|
|
5
|
+
const virtualFileEntry_js_1 = require("../../../shared/virtualFiles/virtualFileEntry.js");
|
|
5
6
|
async function retrieveAssetsDev(clientDependencies, viteDevServer) {
|
|
6
7
|
const assetUrls = new Set();
|
|
7
8
|
await Promise.all(clientDependencies.map(async ({ id }) => {
|
|
8
9
|
if (id.startsWith('@@vike'))
|
|
9
10
|
return; // vike doesn't have any CSS
|
|
10
11
|
(0, utils_js_1.assert)(id);
|
|
12
|
+
(0, utils_js_1.assert)(!(0, virtualFileEntry_js_1.isVirtualFileIdEntry)(id));
|
|
11
13
|
const { moduleGraph } = viteDevServer;
|
|
12
14
|
const [_, graphId] = await moduleGraph.resolveUrl(id);
|
|
13
15
|
(0, utils_js_1.assert)(graphId, { id });
|
|
@@ -34,6 +36,8 @@ function collectCss(mod, styleUrls, visitedModules, importer) {
|
|
|
34
36
|
if (visitedModules.has(mod.url))
|
|
35
37
|
return;
|
|
36
38
|
visitedModules.add(mod.url);
|
|
39
|
+
if ((0, virtualFileEntry_js_1.isVirtualFileIdEntry)(mod.id || mod.url))
|
|
40
|
+
return; // virtual:vike:entry:server dependency list includes all pages
|
|
37
41
|
if (isStyle(mod) && (!importer || !isStyle(importer))) {
|
|
38
42
|
if (mod.url.startsWith('/')) {
|
|
39
43
|
styleUrls.add(mod.url);
|
|
@@ -17,7 +17,9 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
17
17
|
const { _isProduction: isProduction } = globalContext;
|
|
18
18
|
const isDev = !isProduction;
|
|
19
19
|
const { assetUrls, clientEntriesSrc } = isDev
|
|
20
|
-
?
|
|
20
|
+
? !globalContext._viteDevServer
|
|
21
|
+
? await (0, utils_js_1.getViteRPC)().retrievePageAssetsDevRPC(clientDependencies, clientEntries)
|
|
22
|
+
: await retrievePageAssetsDev(globalContext._viteDevServer, clientDependencies, clientEntries)
|
|
21
23
|
: retrievePageAssetsProd(globalContext.assetsManifest, clientDependencies, clientEntries, resolveIncludeAssetsImportedByServer(globalContext.config));
|
|
22
24
|
let pageAssets = [];
|
|
23
25
|
(0, utils_js_1.unique)([...clientEntriesSrc, ...assetUrls]).forEach((src) => {
|
|
@@ -62,6 +62,7 @@ __exportStar(require("../../utils/assertSetup.js"), exports);
|
|
|
62
62
|
__exportStar(require("../../utils/path.js"), exports);
|
|
63
63
|
__exportStar(require("../../utils/isHtml.js"), exports);
|
|
64
64
|
__exportStar(require("../../utils/warnIfErrorIsNotObject.js"), exports);
|
|
65
|
+
__exportStar(require("../../utils/virtualFileId.js"), exports);
|
|
65
66
|
__exportStar(require("../../utils/stripAnsi.js"), exports);
|
|
66
67
|
__exportStar(require("../../utils/getTerminWidth.js"), exports);
|
|
67
68
|
__exportStar(require("../../utils/truncateString.js"), exports);
|
|
@@ -76,3 +77,6 @@ __exportStar(require("../../utils/PROJECT_VERSION.js"), exports);
|
|
|
76
77
|
__exportStar(require("../../utils/genPromise.js"), exports);
|
|
77
78
|
__exportStar(require("../../utils/augmentType.js"), exports);
|
|
78
79
|
__exportStar(require("../../utils/changeEnumerable.js"), exports);
|
|
80
|
+
__exportStar(require("../../utils/getViteRPC.js"), exports);
|
|
81
|
+
__exportStar(require("../../utils/isRunnableDevEnvironment.js"), exports);
|
|
82
|
+
__exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
@@ -32,3 +32,4 @@ __exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
|
32
32
|
__exportStar(require("../../utils/isNullish.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/unique.js"), exports);
|
|
34
34
|
__exportStar(require("../../utils/debug.js"), exports);
|
|
35
|
+
__exportStar(require("../../utils/virtualFileId.js"), exports);
|
|
@@ -2,27 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.virtualFileIdEntryClientCR = exports.virtualFileIdEntryClientSR = exports.virtualFileIdEntryServer = void 0;
|
|
4
4
|
exports.isVirtualFileIdEntry = isVirtualFileIdEntry;
|
|
5
|
+
// TODO/now: merge virtualFileEntry.ts and virtualFilePageConfigLazy.ts
|
|
6
|
+
// - One function parseVirtualFileIdEntry() to rule them all?
|
|
5
7
|
const utils_js_1 = require("../utils.js");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
(0, utils_js_1.assertIsNotBrowser)();
|
|
9
|
+
// TODO/now: rename:
|
|
10
|
+
// ```diff
|
|
11
|
+
// - virtual:vike:entry:server
|
|
12
|
+
// + virtual:vike:entry:global:server
|
|
13
|
+
// ```
|
|
14
|
+
const virtualFileIdEntryServer = 'virtual:vike:entry:server';
|
|
9
15
|
exports.virtualFileIdEntryServer = virtualFileIdEntryServer;
|
|
10
|
-
const virtualFileIdEntryClientSR =
|
|
16
|
+
const virtualFileIdEntryClientSR = 'virtual:vike:entry:client:server-routing';
|
|
11
17
|
exports.virtualFileIdEntryClientSR = virtualFileIdEntryClientSR;
|
|
12
|
-
const virtualFileIdEntryClientCR =
|
|
18
|
+
const virtualFileIdEntryClientCR = 'virtual:vike:entry:client:client-routing';
|
|
13
19
|
exports.virtualFileIdEntryClientCR = virtualFileIdEntryClientCR;
|
|
20
|
+
const virtualFileIdEntries = [virtualFileIdEntryServer, virtualFileIdEntryClientCR, virtualFileIdEntryClientSR];
|
|
21
|
+
const idBase = 'virtual:vike:entry';
|
|
22
|
+
(0, utils_js_1.assert)(virtualFileIdEntries.every((v) => v.startsWith(`${idBase}:`)));
|
|
14
23
|
function isVirtualFileIdEntry(id) {
|
|
15
|
-
id = (0,
|
|
24
|
+
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
16
25
|
if (!id.startsWith(idBase))
|
|
17
26
|
return false;
|
|
18
|
-
(0, utils_js_1.assert)(
|
|
19
|
-
// prettier-ignore
|
|
20
|
-
// biome-ignore format:
|
|
21
|
-
[
|
|
22
|
-
virtualFileIdEntryServer,
|
|
23
|
-
virtualFileIdEntryClientCR,
|
|
24
|
-
virtualFileIdEntryClientSR
|
|
25
|
-
].includes(id));
|
|
27
|
+
(0, utils_js_1.assert)(virtualFileIdEntries.includes(id));
|
|
26
28
|
const isForClientSide = id !== virtualFileIdEntryServer;
|
|
27
29
|
const isClientRouting = id === virtualFileIdEntryClientCR;
|
|
28
30
|
return { isForClientSide, isClientRouting };
|
|
@@ -4,16 +4,22 @@ exports.isVirtualFileIdPageConfigLazy = isVirtualFileIdPageConfigLazy;
|
|
|
4
4
|
exports.getVirtualFileIdPageConfigLazy = getVirtualFileIdPageConfigLazy;
|
|
5
5
|
const extractAssetsQuery_js_1 = require("../extractAssetsQuery.js");
|
|
6
6
|
const utils_js_1 = require("../utils.js");
|
|
7
|
-
|
|
7
|
+
(0, utils_js_1.assertIsNotBrowser)();
|
|
8
|
+
// TODO/now: rename:
|
|
9
|
+
// ```diff
|
|
10
|
+
// - virtual:vike:pageConfigLazy:server:
|
|
11
|
+
// + virtual:vike:entry:page:server:
|
|
12
|
+
// ```
|
|
13
|
+
const idBaseClient = 'virtual:vike:pageConfigLazy:client:';
|
|
14
|
+
const idBaseServer = 'virtual:vike:pageConfigLazy:server:';
|
|
8
15
|
const idBase = 'virtual:vike:pageConfigLazy:';
|
|
9
|
-
|
|
10
|
-
const idBaseServer = `${idBase}server:`;
|
|
16
|
+
// TODO/now: rename to generateVirtualFileIdEntry()
|
|
11
17
|
function getVirtualFileIdPageConfigLazy(pageId, isForClientSide) {
|
|
12
18
|
const id = `${isForClientSide ? idBaseClient : idBaseServer}${pageId}`;
|
|
13
19
|
return id;
|
|
14
20
|
}
|
|
15
21
|
function isVirtualFileIdPageConfigLazy(id) {
|
|
16
|
-
id = (0,
|
|
22
|
+
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
17
23
|
if (!id.includes(idBase))
|
|
18
24
|
return false;
|
|
19
25
|
(0, utils_js_1.assert)(id.startsWith(idBase));
|
|
@@ -29,6 +29,7 @@ const resolveClientEntriesDev_js_1 = require("./shared/resolveClientEntriesDev.j
|
|
|
29
29
|
const pluginWorkaroundCssModuleHmr_js_1 = require("./plugins/pluginWorkaroundCssModuleHmr.js");
|
|
30
30
|
const pluginWorkaroundVite6HmrRegression_js_1 = require("./plugins/pluginWorkaroundVite6HmrRegression.js");
|
|
31
31
|
const pluginReplaceConstants_js_1 = require("./plugins/pluginReplaceConstants.js");
|
|
32
|
+
const pluginNonRunnableDev_js_1 = require("./plugins/pluginNonRunnableDev.js");
|
|
32
33
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
33
34
|
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
34
35
|
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
@@ -48,6 +49,7 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
48
49
|
(0, pluginWorkaroundCssModuleHmr_js_1.pluginWorkaroundCssModuleHmr)(),
|
|
49
50
|
(0, pluginWorkaroundVite6HmrRegression_js_1.pluginWorkaroundVite6HmrRegression)(),
|
|
50
51
|
(0, pluginReplaceConstants_js_1.pluginReplaceConstants)(),
|
|
52
|
+
(0, pluginNonRunnableDev_js_1.pluginNonRunnableDev)(),
|
|
51
53
|
];
|
|
52
54
|
Object.assign(plugins, { _vikeVitePluginOptions: vikeVitePluginOptions });
|
|
53
55
|
return plugins;
|
|
@@ -14,13 +14,13 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
14
14
|
const node_fs_2 = require("node:fs");
|
|
15
15
|
const utils_js_1 = require("../../utils.js");
|
|
16
16
|
const virtualFilePageConfigLazy_js_1 = require("../../../shared/virtualFiles/virtualFilePageConfigLazy.js");
|
|
17
|
-
const pluginBuildConfig_js_1 = require("./pluginBuildConfig.js");
|
|
18
17
|
const getAssetsDir_js_1 = require("../../shared/getAssetsDir.js");
|
|
19
18
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
20
19
|
const resolveVikeConfigInternal_js_1 = require("../../shared/resolveVikeConfigInternal.js");
|
|
21
20
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
22
21
|
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
23
22
|
const pluginBuildEntry_js_1 = require("./pluginBuildEntry.js");
|
|
23
|
+
const getManifestFilePathRelative_js_1 = require("../../shared/getManifestFilePathRelative.js");
|
|
24
24
|
(0, utils_js_1.assertIsSingleModuleInstance)('build/handleAssetsManifest.ts');
|
|
25
25
|
let assetsJsonFilePath;
|
|
26
26
|
// true => use workaround config.build.ssrEmitAssets
|
|
@@ -31,9 +31,8 @@ function handleAssetsManifest_isFixEnabled(config) {
|
|
|
31
31
|
}
|
|
32
32
|
/** https://github.com/vikejs/vike/issues/1339 */
|
|
33
33
|
async function fixServerAssets(config) {
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const serverManifest = await readManifestFile(outDirs.outDirServer);
|
|
34
|
+
const clientManifest = await readManifestFile(config, true);
|
|
35
|
+
const serverManifest = await readManifestFile(config, false);
|
|
37
36
|
const { clientManifestMod, serverManifestMod, filesToMove, filesToRemove } = addServerAssets(clientManifest, serverManifest);
|
|
38
37
|
await copyAssets(filesToMove, filesToRemove, config);
|
|
39
38
|
return { clientManifestMod, serverManifestMod };
|
|
@@ -270,8 +269,8 @@ function removeEmptyDirectories(dirPath) {
|
|
|
270
269
|
node_fs_1.default.rmdirSync(dirPath);
|
|
271
270
|
}
|
|
272
271
|
}
|
|
273
|
-
async function readManifestFile(
|
|
274
|
-
const manifestFilePath =
|
|
272
|
+
async function readManifestFile(config, client) {
|
|
273
|
+
const manifestFilePath = getManifestFilePath(config, client);
|
|
275
274
|
const manifestFileContent = await promises_1.default.readFile(manifestFilePath, 'utf-8');
|
|
276
275
|
(0, utils_js_1.assert)(manifestFileContent);
|
|
277
276
|
const manifest = JSON.parse(manifestFileContent);
|
|
@@ -292,7 +291,7 @@ async function handleAssetsManifest_getBuildConfig(config) {
|
|
|
292
291
|
ssrEmitAssets: isFixEnabled ? true : undefined,
|
|
293
292
|
// Required if `ssrEmitAssets: true`, see https://github.com/vitejs/vite/pull/11430#issuecomment-1454800934
|
|
294
293
|
cssMinify: isFixEnabled ? 'esbuild' : undefined,
|
|
295
|
-
manifest:
|
|
294
|
+
manifest: true,
|
|
296
295
|
copyPublicDir: vikeConfig.config.vite6BuilderApp
|
|
297
296
|
? // Already set by vike:build:pluginBuildApp
|
|
298
297
|
undefined
|
|
@@ -305,7 +304,7 @@ async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
|
305
304
|
(0, utils_js_1.assert)(!assetsJsonFilePath);
|
|
306
305
|
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config, viteEnv);
|
|
307
306
|
assetsJsonFilePath = node_path_1.default.posix.join(outDirs.outDirRoot, 'assets.json');
|
|
308
|
-
await writeAssetsManifestFile(
|
|
307
|
+
await writeAssetsManifestFile(assetsJsonFilePath, config);
|
|
309
308
|
}
|
|
310
309
|
if ((0, isViteServerBuild_js_1.isViteServerBuild)(config, viteEnv)) {
|
|
311
310
|
const outDir = options.dir;
|
|
@@ -319,10 +318,10 @@ async function handleAssetsManifest(config, viteEnv, options, bundle) {
|
|
|
319
318
|
(0, utils_js_1.assert)(!noop); // dist/server should always contain __VITE_ASSETS_MANIFEST__
|
|
320
319
|
}
|
|
321
320
|
}
|
|
322
|
-
async function writeAssetsManifestFile(
|
|
321
|
+
async function writeAssetsManifestFile(assetsJsonFilePath, config) {
|
|
323
322
|
const isFixEnabled = handleAssetsManifest_isFixEnabled(config);
|
|
324
|
-
const clientManifestFilePath =
|
|
325
|
-
const serverManifestFilePath =
|
|
323
|
+
const clientManifestFilePath = getManifestFilePath(config, true);
|
|
324
|
+
const serverManifestFilePath = getManifestFilePath(config, false);
|
|
326
325
|
if (!isFixEnabled) {
|
|
327
326
|
await promises_1.default.copyFile(clientManifestFilePath, assetsJsonFilePath);
|
|
328
327
|
}
|
|
@@ -333,3 +332,12 @@ async function writeAssetsManifestFile(outDirs, assetsJsonFilePath, config) {
|
|
|
333
332
|
await promises_1.default.rm(clientManifestFilePath);
|
|
334
333
|
await promises_1.default.rm(serverManifestFilePath);
|
|
335
334
|
}
|
|
335
|
+
function getManifestFilePath(config, client) {
|
|
336
|
+
const outDirs = (0, getOutDirs_js_1.getOutDirs)(config);
|
|
337
|
+
const outDir = client ? outDirs.outDirClient : outDirs.outDirServer;
|
|
338
|
+
const env = client ? config.environments.client : config.environments.ssr;
|
|
339
|
+
(0, utils_js_1.assert)(env);
|
|
340
|
+
const manifestFilePathRelative = (0, getManifestFilePathRelative_js_1.getManifestFilePathRelative)(env.build.manifest);
|
|
341
|
+
const manifestFilePath = node_path_1.default.posix.join(outDir, manifestFilePathRelative);
|
|
342
|
+
return manifestFilePath;
|
|
343
|
+
}
|
|
@@ -11,12 +11,12 @@ const context_js_1 = require("../../../prerender/context.js");
|
|
|
11
11
|
const isViteCliCall_js_1 = require("../../shared/isViteCliCall.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
13
|
const logErrorHint_js_1 = require("../../../runtime/renderPage/logErrorHint.js");
|
|
14
|
-
const pluginBuildConfig_js_1 = require("./pluginBuildConfig.js");
|
|
15
14
|
const resolveVikeConfigInternal_js_1 = require("../../shared/resolveVikeConfigInternal.js");
|
|
16
15
|
const context_js_2 = require("../../../api/context.js");
|
|
17
16
|
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
18
17
|
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
19
18
|
const runPrerenderEntry_js_1 = require("../../../prerender/runPrerenderEntry.js");
|
|
19
|
+
const getManifestFilePathRelative_js_1 = require("../../shared/getManifestFilePathRelative.js");
|
|
20
20
|
(0, utils_js_1.assertIsSingleModuleInstance)('build/pluginAutoFullBuild.ts');
|
|
21
21
|
let forceExit = false;
|
|
22
22
|
function pluginAutoFullBuild() {
|
|
@@ -87,7 +87,7 @@ async function triggerFullBuild(config, viteEnv, bundle) {
|
|
|
87
87
|
// - The legacy plugin triggers its own Rollup build for the client-side.
|
|
88
88
|
// - The legacy plugin doesn't generate a manifest => we can use that to detect the legacy plugin build.
|
|
89
89
|
// - Issue & reproduction: https://github.com/vikejs/vike/issues/1154#issuecomment-1965954636
|
|
90
|
-
if (!bundle[
|
|
90
|
+
if (!bundle[(0, getManifestFilePathRelative_js_1.getManifestFilePathRelative)(config.build.manifest)])
|
|
91
91
|
return;
|
|
92
92
|
const configInline = getFullBuildInlineConfig(config);
|
|
93
93
|
if (!isBuilderApp) {
|
|
@@ -8,6 +8,34 @@ const pluginAutoFullBuild_js_1 = require("./pluginAutoFullBuild.js");
|
|
|
8
8
|
const resolveVikeConfigInternal_js_1 = require("../../shared/resolveVikeConfigInternal.js");
|
|
9
9
|
function pluginBuildApp() {
|
|
10
10
|
return [
|
|
11
|
+
{
|
|
12
|
+
name: 'vike:build:pluginBuildApp:pre',
|
|
13
|
+
apply: 'build',
|
|
14
|
+
enforce: 'pre',
|
|
15
|
+
config: {
|
|
16
|
+
order: 'pre',
|
|
17
|
+
async handler(_config) {
|
|
18
|
+
const vikeConfig = await (0, resolveVikeConfigInternal_js_1.getVikeConfigInternal)();
|
|
19
|
+
if (!vikeConfig.config.vite6BuilderApp)
|
|
20
|
+
return;
|
|
21
|
+
return {
|
|
22
|
+
builder: {
|
|
23
|
+
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
24
|
+
async buildApp(builder) {
|
|
25
|
+
(0, utils_js_1.assert)(builder.environments.client);
|
|
26
|
+
(0, utils_js_1.assert)(builder.environments.ssr);
|
|
27
|
+
await builder.build(builder.environments.client);
|
|
28
|
+
await builder.build(builder.environments.ssr);
|
|
29
|
+
if ((0, pluginAutoFullBuild_js_1.isPrerenderForceExit)()) {
|
|
30
|
+
(0, runPrerenderEntry_js_1.runPrerender_forceExit)();
|
|
31
|
+
(0, utils_js_1.assert)(false);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
11
39
|
{
|
|
12
40
|
name: 'vike:build:pluginBuildApp',
|
|
13
41
|
apply: 'build',
|
|
@@ -16,19 +44,6 @@ function pluginBuildApp() {
|
|
|
16
44
|
if (!vikeConfig.config.vite6BuilderApp)
|
|
17
45
|
return;
|
|
18
46
|
return {
|
|
19
|
-
builder: {
|
|
20
|
-
// Can be overridden by another plugin e.g vike-vercel https://github.com/vikejs/vike/pull/2184#issuecomment-2659425195
|
|
21
|
-
async buildApp(builder) {
|
|
22
|
-
(0, utils_js_1.assert)(builder.environments.client);
|
|
23
|
-
(0, utils_js_1.assert)(builder.environments.ssr);
|
|
24
|
-
await builder.build(builder.environments.client);
|
|
25
|
-
await builder.build(builder.environments.ssr);
|
|
26
|
-
if ((0, pluginAutoFullBuild_js_1.isPrerenderForceExit)()) {
|
|
27
|
-
(0, runPrerenderEntry_js_1.runPrerender_forceExit)();
|
|
28
|
-
(0, utils_js_1.assert)(false);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
47
|
environments: {
|
|
33
48
|
ssr: {
|
|
34
49
|
consumer: 'server',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.manifestTempFile = void 0;
|
|
4
3
|
exports.pluginBuildConfig = pluginBuildConfig;
|
|
5
4
|
exports.assertRollupInput = assertRollupInput;
|
|
6
5
|
exports.analyzeClientEntries = analyzeClientEntries;
|
|
@@ -16,8 +15,6 @@ const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
|
16
15
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
17
16
|
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
18
17
|
const getPageAssets_js_1 = require("../../../runtime/renderPage/getPageAssets.js");
|
|
19
|
-
const manifestTempFile = '_temp_manifest.json';
|
|
20
|
-
exports.manifestTempFile = manifestTempFile;
|
|
21
18
|
function pluginBuildConfig() {
|
|
22
19
|
let config;
|
|
23
20
|
return [
|