vike 0.4.236-commit-64431e7 → 0.4.236-commit-08fbc10
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 +1 -1
- package/dist/cjs/node/runtime/globalContext.js +17 -79
- package/dist/cjs/node/runtime/html/injectAssets/getViteDevScript.js +1 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +1 -3
- package/dist/cjs/node/runtime/utils.js +1 -1
- 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 +0 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginBuildConfig.js +1 -2
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginDistFileNames.js +12 -9
- package/dist/cjs/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/cjs/node/vite/plugins/pluginCommon.js +0 -1
- package/dist/cjs/node/vite/plugins/pluginDev/determineOptimizeDeps.js +100 -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/pluginReplaceConstants.js +1 -1
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +1 -0
- package/dist/cjs/node/vite/plugins/pluginVirtualFiles.js +4 -5
- package/dist/cjs/node/vite/shared/applyRegExWithMagicString.js +0 -1
- package/dist/cjs/node/vite/utils.js +1 -0
- package/dist/cjs/shared/createGlobalContextShared.js +1 -5
- 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 +0 -3
- package/dist/cjs/utils/debug.js +0 -1
- package/dist/cjs/utils/isFilePathAbsoluteFilesystem.js +1 -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/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/node/prerender/runPrerender.d.ts +132 -40
- package/dist/esm/node/runtime/globalContext.d.ts +52 -32
- package/dist/esm/node/runtime/globalContext.js +18 -80
- package/dist/esm/node/runtime/html/injectAssets/getViteDevScript.js +1 -8
- package/dist/esm/node/runtime/renderPage/createPageContextServerSide.d.ts +33 -10
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsDev.js +4 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +2 -4
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +66 -20
- package/dist/esm/node/runtime/renderPage.d.ts +33 -10
- package/dist/esm/node/runtime/utils.d.ts +1 -1
- package/dist/esm/node/runtime/utils.js +1 -1
- 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 +0 -2
- package/dist/esm/node/vite/plugins/pluginBuild/handleAssetsManifest.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildApp.js +28 -13
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.d.ts +1 -1
- package/dist/esm/node/vite/plugins/pluginBuild/pluginBuildConfig.js +1 -2
- package/dist/esm/node/vite/plugins/pluginBuild/pluginDistFileNames.js +12 -9
- package/dist/esm/node/vite/plugins/pluginBuild/pluginModuleBanner.js +2 -2
- package/dist/esm/node/vite/plugins/pluginCommon.d.ts +0 -3
- package/dist/esm/node/vite/plugins/pluginCommon.js +0 -1
- package/dist/esm/node/vite/plugins/pluginDev/determineOptimizeDeps.js +101 -59
- package/dist/esm/node/vite/plugins/pluginExtractAssets.js +3 -4
- package/dist/esm/node/vite/plugins/pluginVirtualFiles/getVirtualFilePageConfigLazy.js +1 -0
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +3 -4
- package/dist/esm/node/vite/shared/applyRegExWithMagicString.js +0 -1
- 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 +1 -5
- 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 +0 -3
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +0 -1
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.d.ts +7 -0
- package/dist/esm/utils/isFilePathAbsoluteFilesystem.js +1 -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 +3 -12
- package/dist/cjs/node/shared/virtualFiles.js +0 -41
- package/dist/cjs/node/vite/plugins/pluginViteRPC.js +0 -42
- package/dist/cjs/utils/getViteRPC.js +0 -79
- package/dist/esm/node/shared/virtualFiles.d.ts +0 -8
- package/dist/esm/node/vite/plugins/pluginViteRPC.d.ts +0 -25
- package/dist/esm/node/vite/plugins/pluginViteRPC.js +0 -40
- package/dist/esm/utils/getViteRPC.d.ts +0 -6
- package/dist/esm/utils/getViteRPC.js +0 -77
|
@@ -32,7 +32,7 @@ function createGetGlobalContextClient(virtualFileExports, isClientRouting, addGl
|
|
|
32
32
|
/**
|
|
33
33
|
* Whether the environment is client-side or server-side / pre-rendering.
|
|
34
34
|
*
|
|
35
|
-
* We recommend using `
|
|
35
|
+
* We recommend using `import.meta.env.SSR` instead, see https://vike.dev/globalContext
|
|
36
36
|
*/
|
|
37
37
|
isClientSide: true,
|
|
38
38
|
};
|
|
@@ -155,9 +155,6 @@ function setGlobalContext_isPrerendering() {
|
|
|
155
155
|
setIsProduction(true);
|
|
156
156
|
}
|
|
157
157
|
function setGlobalContext_isProduction(isProduction, tolerateContraditction = false) {
|
|
158
|
-
// TODO/now: try to remove globalObject.isProduction ?
|
|
159
|
-
// TODO/now: `rename tolerateContraditction tolerateContradiction`
|
|
160
|
-
tolerateContraditction = true;
|
|
161
158
|
if (debug.isActivated)
|
|
162
159
|
debug('setGlobalContext_isProduction()', { isProduction, tolerateContraditction });
|
|
163
160
|
if (globalObject.isProduction === undefined) {
|
|
@@ -208,12 +205,7 @@ async function initGlobalContext() {
|
|
|
208
205
|
const { isProduction } = globalObject;
|
|
209
206
|
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
210
207
|
if (!isProduction) {
|
|
211
|
-
|
|
212
|
-
await globalObject.viteDevServerPromise;
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
await updateUserFiles();
|
|
216
|
-
}
|
|
208
|
+
await globalObject.viteDevServerPromise;
|
|
217
209
|
(0, utils_js_1.assert)(globalObject.waitForUserFilesUpdate);
|
|
218
210
|
await globalObject.waitForUserFilesUpdate;
|
|
219
211
|
}
|
|
@@ -347,27 +339,16 @@ async function updateUserFiles() {
|
|
|
347
339
|
// 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).
|
|
348
340
|
viteDevServer !== globalObject.viteDevServer;
|
|
349
341
|
const { viteDevServer } = globalObject;
|
|
342
|
+
(0, utils_js_1.assert)(viteDevServer);
|
|
350
343
|
let hasError = false;
|
|
351
344
|
let virtualFileExports;
|
|
352
345
|
let err;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
virtualFileExports = await viteDevServer.ssrLoadModule(virtualFileEntry_js_1.virtualFileIdEntryServer);
|
|
356
|
-
}
|
|
357
|
-
catch (err_) {
|
|
358
|
-
hasError = true;
|
|
359
|
-
err = err_;
|
|
360
|
-
}
|
|
346
|
+
try {
|
|
347
|
+
virtualFileExports = await viteDevServer.ssrLoadModule(virtualFileEntry_js_1.virtualFileIdEntryServer);
|
|
361
348
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
virtualFileExports = await __VIKE__DYNAMIC_IMPORT('virtual:vike:entry:server');
|
|
366
|
-
}
|
|
367
|
-
catch (err_) {
|
|
368
|
-
hasError = true;
|
|
369
|
-
err = err_;
|
|
370
|
-
}
|
|
349
|
+
catch (err_) {
|
|
350
|
+
hasError = true;
|
|
351
|
+
err = err_;
|
|
371
352
|
}
|
|
372
353
|
if (isOutdated())
|
|
373
354
|
return { success: false };
|
|
@@ -393,7 +374,7 @@ async function updateUserFiles() {
|
|
|
393
374
|
async function setGlobalContext(virtualFileExports) {
|
|
394
375
|
debug('setGlobalContext()');
|
|
395
376
|
(0, utils_js_1.assert)(!(0, getVikeConfigError_js_1.getVikeConfigErrorBuild)());
|
|
396
|
-
const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContext, addGlobalContextTmp
|
|
377
|
+
const globalContext = await (0, createGlobalContextShared_js_1.createGlobalContextShared)(virtualFileExports, globalObject, addGlobalContext, addGlobalContextTmp);
|
|
397
378
|
(0, assertV1Design_js_1.assertV1Design)(
|
|
398
379
|
// pageConfigs is PageConfigRuntime[] but assertV1Design() requires PageConfigBuildTime[]
|
|
399
380
|
globalContext._pageConfigs.length > 0, globalContext._pageFilesAll);
|
|
@@ -419,18 +400,23 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
419
400
|
_pageRoutes: pageRoutes,
|
|
420
401
|
_onBeforeRouteHook: onBeforeRouteHook,
|
|
421
402
|
};
|
|
422
|
-
const { viteDevServer, viteConfig, isPrerendering, isProduction } = globalObject;
|
|
403
|
+
const { viteDevServer, viteConfig, viteConfigRuntime, isPrerendering, isProduction } = globalObject;
|
|
423
404
|
(0, utils_js_1.assert)(typeof isProduction === 'boolean');
|
|
424
405
|
if (!isProduction) {
|
|
406
|
+
(0, utils_js_1.assert)(viteDevServer);
|
|
425
407
|
(0, utils_js_1.assert)(globalContext); // main common requirement
|
|
408
|
+
(0, utils_js_1.assert)(viteConfig);
|
|
409
|
+
(0, utils_js_1.assert)(viteConfigRuntime);
|
|
426
410
|
(0, utils_js_1.assert)(!isPrerendering);
|
|
427
411
|
return {
|
|
428
412
|
...globalContextBase,
|
|
413
|
+
...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
|
|
429
414
|
_isProduction: false,
|
|
430
415
|
_isPrerendering: false,
|
|
431
416
|
assetsManifest: null,
|
|
432
417
|
_viteDevServer: viteDevServer,
|
|
433
418
|
viteConfig,
|
|
419
|
+
viteConfigRuntime,
|
|
434
420
|
};
|
|
435
421
|
}
|
|
436
422
|
else {
|
|
@@ -441,9 +427,11 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
441
427
|
(0, utils_js_1.assert)(assetsManifest);
|
|
442
428
|
const globalContextBase2 = {
|
|
443
429
|
...globalContextBase,
|
|
430
|
+
...resolveBaseRuntime(buildInfo.viteConfigRuntime, globalContext.config),
|
|
444
431
|
_isProduction: true,
|
|
445
432
|
assetsManifest,
|
|
446
433
|
_viteDevServer: null,
|
|
434
|
+
viteConfigRuntime: buildInfo.viteConfigRuntime,
|
|
447
435
|
_usesClientRouter: buildInfo.usesClientRouter,
|
|
448
436
|
};
|
|
449
437
|
if (isPrerendering) {
|
|
@@ -463,45 +451,14 @@ function addGlobalContextCommon(globalContext, pageRoutes, onBeforeRouteHook) {
|
|
|
463
451
|
}
|
|
464
452
|
}
|
|
465
453
|
}
|
|
466
|
-
async function addGlobalContextAsync(globalContext) {
|
|
467
|
-
debug('addGlobalContextAsync()');
|
|
468
|
-
let { viteConfigRuntime, buildInfo } = globalObject;
|
|
469
|
-
if (!viteConfigRuntime) {
|
|
470
|
-
if (buildInfo) {
|
|
471
|
-
viteConfigRuntime = buildInfo.viteConfigRuntime;
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
if (!isProcessSharedWithVite()) {
|
|
475
|
-
if (!globalObject.isProduction) {
|
|
476
|
-
const rpc = (0, utils_js_1.getViteRPC)();
|
|
477
|
-
viteConfigRuntime = await rpc.getViteConfigRuntimeRPC();
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
(0, utils_js_1.assert)(false); // production => globalObject.buildInfo should be set
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
(0, utils_js_1.assert)(false); // process shared with Vite => globalObject.viteConfigRuntime should be set
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
(0, utils_js_1.assert)(viteConfigRuntime);
|
|
489
|
-
return {
|
|
490
|
-
viteConfigRuntime,
|
|
491
|
-
...resolveBaseRuntime(viteConfigRuntime, globalContext.config),
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
454
|
function clearGlobalContext() {
|
|
495
455
|
debug('clearGlobalContext()');
|
|
496
456
|
(0, utils_js_1.objectReplace)(globalObject, getInitialGlobalObject(), ['buildEntryPrevious']);
|
|
497
457
|
}
|
|
498
458
|
function getInitialGlobalObject() {
|
|
499
|
-
|
|
500
|
-
if (debug.isActivated)
|
|
501
|
-
debug('getInitialGlobalObject()', { isProduction });
|
|
459
|
+
debug('getInitialGlobalObject()');
|
|
502
460
|
const { promise: viteDevServerPromise, resolve: viteDevServerPromiseResolve } = (0, utils_js_1.genPromise)();
|
|
503
461
|
return {
|
|
504
|
-
isProduction,
|
|
505
462
|
viteDevServerPromise,
|
|
506
463
|
viteDevServerPromiseResolve,
|
|
507
464
|
};
|
|
@@ -512,22 +469,3 @@ function resolveBaseRuntime(viteConfigRuntime, config) {
|
|
|
512
469
|
const baseAssetsUnresolved = config.baseAssets ?? null;
|
|
513
470
|
return (0, resolveBase_js_1.resolveBase)(baseViteOriginal, baseServerUnresolved, baseAssetsUnresolved);
|
|
514
471
|
}
|
|
515
|
-
function getIsProductionStatic() {
|
|
516
|
-
// TODO/now add @ts-ignore comments
|
|
517
|
-
// @ts-ignore
|
|
518
|
-
if (!({}))
|
|
519
|
-
return undefined;
|
|
520
|
-
// @ts-ignore
|
|
521
|
-
const PROD = ({}).PROD;
|
|
522
|
-
return PROD;
|
|
523
|
-
}
|
|
524
|
-
function isProcessSharedWithVite() {
|
|
525
|
-
const ret = globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE;
|
|
526
|
-
if (globalObject.isProcessSharedWithVite !== undefined) {
|
|
527
|
-
(0, utils_js_1.assert)(globalObject.isProcessSharedWithVite === ret);
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
globalObject.isProcessSharedWithVite = ret;
|
|
531
|
-
}
|
|
532
|
-
return ret;
|
|
533
|
-
}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getViteDevScript = getViteDevScript;
|
|
7
|
-
const getViteRPC_js_1 = require("../../../../utils/getViteRPC.js");
|
|
8
7
|
const utils_js_1 = require("../../utils.js");
|
|
9
8
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
10
9
|
const reachOutCTA = 'Create a new GitHub issue to discuss a solution.';
|
|
@@ -17,13 +16,7 @@ async function getViteDevScript(pageContext) {
|
|
|
17
16
|
const fakeHtmlBegin = '<html> <head>'; // White space to test whether user is using a minifier
|
|
18
17
|
const fakeHtmlEnd = '</head><body></body></html>';
|
|
19
18
|
let fakeHtml = fakeHtmlBegin + fakeHtmlEnd;
|
|
20
|
-
|
|
21
|
-
fakeHtml = await viteDevServer.transformIndexHtml('/', fakeHtml);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
const rpc = (0, getViteRPC_js_1.getViteRPC)();
|
|
25
|
-
fakeHtml = await rpc.transformIndexHtmlRPC(fakeHtml);
|
|
26
|
-
}
|
|
19
|
+
fakeHtml = await viteDevServer.transformIndexHtml('/', fakeHtml);
|
|
27
20
|
(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`);
|
|
28
21
|
(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`);
|
|
29
22
|
(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,9 +17,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
17
17
|
const { _isProduction: isProduction } = globalContext;
|
|
18
18
|
const isDev = !isProduction;
|
|
19
19
|
const { assetUrls, clientEntriesSrc } = isDev
|
|
20
|
-
?
|
|
21
|
-
? await (0, utils_js_1.getViteRPC)().retrievePageAssetsDevRPC(clientDependencies, clientEntries)
|
|
22
|
-
: await retrievePageAssetsDev(globalContext._viteDevServer, clientDependencies, clientEntries)
|
|
20
|
+
? await retrievePageAssetsDev(globalContext._viteDevServer, clientDependencies, clientEntries)
|
|
23
21
|
: retrievePageAssetsProd(globalContext.assetsManifest, clientDependencies, clientEntries, resolveIncludeAssetsImportedByServer(globalContext.config));
|
|
24
22
|
let pageAssets = [];
|
|
25
23
|
(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,4 +77,3 @@ __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);
|
|
79
|
-
__exportStar(require("../../utils/getViteRPC.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,7 +29,6 @@ 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 pluginViteRPC_js_1 = require("./plugins/pluginViteRPC.js");
|
|
33
32
|
// We don't call this in ./onLoad.ts to avoid a cyclic dependency with utils.ts
|
|
34
33
|
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
35
34
|
// Return `PluginInterop` instead of `Plugin` to avoid type mismatch upon different Vite versions
|
|
@@ -49,7 +48,6 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
49
48
|
(0, pluginWorkaroundCssModuleHmr_js_1.pluginWorkaroundCssModuleHmr)(),
|
|
50
49
|
(0, pluginWorkaroundVite6HmrRegression_js_1.pluginWorkaroundVite6HmrRegression)(),
|
|
51
50
|
(0, pluginReplaceConstants_js_1.pluginReplaceConstants)(),
|
|
52
|
-
(0, pluginViteRPC_js_1.pluginViteRPC)(),
|
|
53
51
|
];
|
|
54
52
|
Object.assign(plugins, { _vikeVitePluginOptions: vikeVitePluginOptions });
|
|
55
53
|
return plugins;
|
|
@@ -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',
|
|
@@ -16,8 +16,7 @@ const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
|
16
16
|
const getOutDirs_js_1 = require("../../shared/getOutDirs.js");
|
|
17
17
|
const handleAssetsManifest_js_1 = require("./handleAssetsManifest.js");
|
|
18
18
|
const getPageAssets_js_1 = require("../../../runtime/renderPage/getPageAssets.js");
|
|
19
|
-
|
|
20
|
-
const manifestTempFile = '.vite/manifest.json';
|
|
19
|
+
const manifestTempFile = '_temp_manifest.json';
|
|
21
20
|
exports.manifestTempFile = manifestTempFile;
|
|
22
21
|
function pluginBuildConfig() {
|
|
23
22
|
let config;
|
|
@@ -18,8 +18,6 @@ function pluginDistFileNames() {
|
|
|
18
18
|
apply: 'build',
|
|
19
19
|
enforce: 'post',
|
|
20
20
|
configResolved(config) {
|
|
21
|
-
// TODO/now remove
|
|
22
|
-
// if (true as boolean) return
|
|
23
21
|
const rollupOutputs = getRollupOutputs(config);
|
|
24
22
|
// We need to support multiple outputs: @vite/plugin-legacy adds an output, see https://github.com/vikejs/vike/issues/477#issuecomment-1406434802
|
|
25
23
|
rollupOutputs.forEach((rollupOutput) => {
|
|
@@ -158,13 +156,8 @@ function getEntryFileName(chunkInfo, config, isEntry) {
|
|
|
158
156
|
return `${name}.${isEntry ? 'mjs' : 'js'}`;
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
|
-
function removePathSeparators(name
|
|
159
|
+
function removePathSeparators(name) {
|
|
162
160
|
(0, utils_js_1.assertPosixPath)(name);
|
|
163
|
-
if (name.startsWith(userRootDir)) {
|
|
164
|
-
name = name.slice(userRootDir.length);
|
|
165
|
-
if (name.startsWith('/'))
|
|
166
|
-
name = name.slice(1);
|
|
167
|
-
}
|
|
168
161
|
(0, utils_js_1.assert)(!name.startsWith('/'), { name });
|
|
169
162
|
const entryDir = 'entries/';
|
|
170
163
|
const hasEntryDir = name.startsWith(entryDir);
|
|
@@ -178,14 +171,24 @@ function removePathSeparators(name, userRootDir) {
|
|
|
178
171
|
}
|
|
179
172
|
return name;
|
|
180
173
|
}
|
|
174
|
+
function removeUserRootDir(name, userRootDir) {
|
|
175
|
+
if (name.startsWith(userRootDir)) {
|
|
176
|
+
name = name.slice(userRootDir.length);
|
|
177
|
+
if (name.startsWith('/'))
|
|
178
|
+
name = name.slice(1);
|
|
179
|
+
}
|
|
180
|
+
(0, utils_js_1.assert)(!name.startsWith('/'), { name });
|
|
181
|
+
return name;
|
|
182
|
+
}
|
|
181
183
|
function clean(name, userRootDir, removePathSep, fixGlob) {
|
|
184
|
+
name = removeUserRootDir(name, userRootDir);
|
|
182
185
|
name = fixExtractAssetsQuery(name);
|
|
183
186
|
if (fixGlob) {
|
|
184
187
|
name = workaroundGlob(name);
|
|
185
188
|
}
|
|
186
189
|
name = replaceNonLatinCharacters(name);
|
|
187
190
|
if (removePathSep) {
|
|
188
|
-
name = removePathSeparators(name
|
|
191
|
+
name = removePathSeparators(name);
|
|
189
192
|
}
|
|
190
193
|
name = removeLeadingUnderscoreInFilename(name);
|
|
191
194
|
name = removeUnderscoreDoublets(name);
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.pluginModuleBanner = pluginModuleBanner;
|
|
7
7
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
8
|
-
const
|
|
8
|
+
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const isViteServerBuild_js_1 = require("../../shared/isViteServerBuild.js");
|
|
10
10
|
// Rollup's banner feature doesn't work with Vite: https://github.com/vitejs/vite/issues/8412
|
|
11
11
|
// But, anyways, we want to prepend the banner at the beginning of each module, not at the beginning of each file (I believe that's what Rollup's banner feature does).
|
|
@@ -28,7 +28,7 @@ function pluginModuleBanner() {
|
|
|
28
28
|
}
|
|
29
29
|
if (id.startsWith('\0'))
|
|
30
30
|
id = id;
|
|
31
|
-
id = (0,
|
|
31
|
+
id = (0, utils_js_1.removeVirtualFileIdPrefix)(id);
|
|
32
32
|
if (id.startsWith(config.root))
|
|
33
33
|
id = id.slice(config.root.length + 1);
|
|
34
34
|
id = id.replaceAll('*/', '*\\/'); // https://github.com/vikejs/vike/issues/2377
|
|
@@ -16,7 +16,6 @@ const resolveVikeConfigInternal_js_1 = require("../shared/resolveVikeConfigInter
|
|
|
16
16
|
const prepareViteApiCall_js_1 = require("../../api/prepareViteApiCall.js");
|
|
17
17
|
const context_js_2 = require("../../prerender/context.js");
|
|
18
18
|
const pluginName = 'vike:pluginCommon';
|
|
19
|
-
globalThis.__VIKE__IS_PROCESS_SHARED_WITH_VITE = true;
|
|
20
19
|
function pluginCommon(vikeVitePluginOptions) {
|
|
21
20
|
return [
|
|
22
21
|
{
|