vike 0.4.218 → 0.4.220-commit-a9f46b8
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/__internal/index.js +11 -11
- package/dist/cjs/node/api/build.js +22 -48
- package/dist/cjs/node/api/context.js +8 -6
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +40 -13
- package/dist/cjs/node/cli/context.js +16 -0
- package/dist/cjs/node/cli/entry.js +21 -7
- package/dist/cjs/node/cli/utils.js +1 -0
- package/dist/cjs/node/plugin/index.js +5 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +32 -20
- package/dist/cjs/node/plugin/plugins/baseUrls.js +3 -10
- package/dist/cjs/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/cjs/node/plugin/plugins/commonConfig.js +41 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +26 -23
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +171 -68
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -5
- package/dist/cjs/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/cjs/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/cjs/node/plugin/shared/getHttpRequestAsyncStore.js +17 -7
- package/dist/cjs/node/prerender/context.js +24 -0
- package/dist/cjs/node/prerender/runPrerender.js +146 -96
- package/dist/cjs/node/prerender/utils.js +2 -0
- package/dist/cjs/node/runtime/globalContext.js +109 -55
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +2 -2
- package/dist/cjs/node/runtime/index-common.js +0 -15
- package/dist/cjs/node/runtime/onLoad.js +17 -3
- package/dist/cjs/node/runtime/page-files/setup.js +2 -4
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/createHttpResponse/getCacheControl.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +1 -1
- package/dist/cjs/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
- package/dist/cjs/node/runtime/renderPage/resolveRedirects.js +9 -1
- package/dist/cjs/node/runtime/renderPage.js +21 -22
- package/dist/cjs/node/runtime/utils.js +2 -0
- package/dist/cjs/node/runtime-dev/index.js +17 -7
- package/dist/cjs/node/shared/assertRuntimeManifest.js +0 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
- package/dist/cjs/shared/getPageFiles.js +3 -9
- package/dist/cjs/shared/hooks/getHook.js +3 -3
- package/dist/cjs/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +113 -81
- package/dist/cjs/shared/page-configs/loadConfigValues.js +5 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValues.js +80 -55
- package/dist/cjs/shared/route/loadPageRoutes.js +3 -3
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/assert.js +4 -3
- package/dist/cjs/utils/assertSetup.js +47 -16
- package/dist/cjs/utils/catchInfiniteLoop.js +34 -0
- package/dist/cjs/utils/debug.js +11 -6
- package/dist/cjs/utils/getGlobalObject.js +1 -2
- package/dist/cjs/utils/isDev.js +2 -0
- package/dist/cjs/utils/makePublicCopy.js +32 -0
- package/dist/cjs/utils/objectReplace.js +9 -0
- package/dist/esm/__internal/index.d.ts +3 -5
- package/dist/esm/__internal/index.js +6 -8
- package/dist/esm/client/client-routing-runtime/createPageContext.js +4 -1
- package/dist/esm/client/client-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/entry.js +0 -1
- package/dist/esm/client/client-routing-runtime/getPageContextCurrent.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +4 -4
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +1 -1
- package/dist/esm/client/client-routing-runtime/history.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/history.js +23 -18
- package/dist/esm/client/client-routing-runtime/index.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/index.js +0 -1
- package/dist/esm/client/client-routing-runtime/initClientRouter.js +2 -2
- package/dist/esm/client/client-routing-runtime/initOnLinkClick.js +3 -4
- package/dist/esm/client/client-routing-runtime/initOnPopState.d.ts +0 -10
- package/dist/esm/client/client-routing-runtime/initOnPopState.js +50 -62
- package/dist/esm/client/client-routing-runtime/prefetch/getPrefetchSettings.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +2 -2
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +15 -15
- package/dist/esm/client/client-routing-runtime/scrollRestoration.d.ts +4 -6
- package/dist/esm/client/client-routing-runtime/scrollRestoration.js +17 -12
- package/dist/esm/client/client-routing-runtime/setScrollPosition.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/setScrollPosition.js +29 -5
- package/dist/esm/client/client-routing-runtime/utils.d.ts +1 -0
- package/dist/esm/client/client-routing-runtime/utils.js +1 -0
- package/dist/esm/client/server-routing-runtime/entry.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/entry.js +0 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.js +5 -2
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/client/shared/normalizeClientSideUrl.js +2 -3
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/build.d.ts +1 -6
- package/dist/esm/node/api/build.js +20 -26
- package/dist/esm/node/api/context.d.ts +4 -2
- package/dist/esm/node/api/context.js +8 -7
- package/dist/esm/node/api/prepareViteApiCall.d.ts +0 -1
- package/dist/esm/node/api/prepareViteApiCall.js +26 -9
- package/dist/esm/node/cli/context.d.ts +5 -0
- package/dist/esm/node/cli/context.js +14 -0
- package/dist/esm/node/cli/entry.js +4 -0
- package/dist/esm/node/cli/parseCli.d.ts +3 -1
- package/dist/esm/node/cli/utils.d.ts +1 -0
- package/dist/esm/node/cli/utils.js +1 -0
- package/dist/esm/node/plugin/index.d.ts +1 -1
- package/dist/esm/node/plugin/index.js +5 -5
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +32 -20
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +4 -11
- package/dist/esm/node/plugin/plugins/buildConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/index.js +16 -17
- package/dist/esm/node/plugin/plugins/commonConfig.d.ts +10 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +42 -5
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +6 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +25 -22
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +96 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +167 -64
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +7 -5
- package/dist/esm/node/plugin/plugins/setGlobalContext.js +1 -1
- package/dist/esm/node/plugin/plugins/workaroundVite6HmrRegression.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/{vite6HmrRegressionWorkaround.js → workaroundVite6HmrRegression.js} +3 -3
- package/dist/esm/node/prerender/context.d.ts +9 -0
- package/dist/esm/node/prerender/context.js +22 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +42 -2
- package/dist/esm/node/prerender/runPrerender.js +130 -90
- package/dist/esm/node/prerender/utils.d.ts +2 -0
- package/dist/esm/node/prerender/utils.js +2 -0
- package/dist/esm/node/runtime/globalContext.d.ts +23 -7
- package/dist/esm/node/runtime/globalContext.js +109 -55
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -1
- package/dist/esm/node/runtime/index-common.d.ts +0 -1
- package/dist/esm/node/runtime/index-common.js +0 -15
- package/dist/esm/node/runtime/index-deprecated.d.ts +1 -0
- package/dist/esm/node/runtime/onLoad.js +16 -2
- package/dist/esm/node/runtime/page-files/setup.js +3 -3
- package/dist/esm/node/runtime/renderPage/analyzePage.js +1 -1
- package/dist/esm/node/runtime/renderPage/createHttpResponse/getCacheControl.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +31 -46
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +11 -33
- package/dist/esm/node/runtime/renderPage/resolveRedirects.d.ts +1 -1
- package/dist/esm/node/runtime/renderPage/resolveRedirects.js +9 -1
- package/dist/esm/node/runtime/renderPage.js +22 -23
- package/dist/esm/node/runtime/utils.d.ts +2 -0
- package/dist/esm/node/runtime/utils.js +2 -0
- package/dist/esm/node/shared/assertPluginManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertRuntimeManifest.d.ts +0 -1
- package/dist/esm/node/shared/assertRuntimeManifest.js +1 -3
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +3 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +8 -6
- package/dist/esm/shared/getPageFiles.d.ts +2 -5
- package/dist/esm/shared/getPageFiles.js +1 -4
- package/dist/esm/shared/hooks/getHook.d.ts +3 -3
- package/dist/esm/shared/hooks/getHook.js +1 -1
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +9 -5
- package/dist/esm/shared/page-configs/Config.d.ts +20 -2
- package/dist/esm/shared/page-configs/PageConfig.d.ts +13 -6
- package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +26 -12
- package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
- package/dist/esm/shared/page-configs/loadConfigValues.js +6 -2
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +26 -6
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +80 -55
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/shared/types.d.ts +1 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/assert.js +4 -3
- package/dist/esm/utils/assertSetup.js +47 -16
- package/dist/esm/utils/catchInfiniteLoop.d.ts +2 -0
- package/dist/esm/utils/catchInfiniteLoop.js +32 -0
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +11 -6
- package/dist/esm/utils/getGlobalObject.js +1 -2
- package/dist/esm/utils/isDev.js +2 -0
- package/dist/esm/utils/makePublicCopy.d.ts +3 -0
- package/dist/esm/utils/makePublicCopy.js +30 -0
- package/dist/esm/utils/objectReplace.d.ts +1 -0
- package/dist/esm/utils/objectReplace.js +6 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +4 -13
- package/__internal/loadImportBuild.js +0 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -128
- package/dist/cjs/node/runtime/globalContext/loadImportBuild.js +0 -25
- package/dist/cjs/node/runtime/page-files/getPageFilesExports.js +0 -22
- package/dist/esm/client/client-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/client-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/client/server-routing-runtime/pageFiles.d.ts +0 -1
- package/dist/esm/client/server-routing-runtime/pageFiles.js +0 -4
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.d.ts +0 -104
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveVikeConfigGlobal.js +0 -123
- package/dist/esm/node/plugin/plugins/vite6HmrRegressionWorkaround.d.ts +0 -3
- package/dist/esm/node/runtime/globalContext/loadImportBuild.d.ts +0 -18
- package/dist/esm/node/runtime/globalContext/loadImportBuild.js +0 -23
- package/dist/esm/node/runtime/page-files/getPageFilesExports.d.ts +0 -2
- package/dist/esm/node/runtime/page-files/getPageFilesExports.js +0 -20
- /package/dist/cjs/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- /package/dist/cjs/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
- /package/dist/esm/node/plugin/plugins/{importBuild → buildEntry}/getVikeManifest.js +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.d.ts → getConfigValueRuntime.d.ts} +0 -0
- /package/dist/esm/shared/page-configs/{getConfigValue.js → getConfigValueRuntime.js} +0 -0
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setGlobalContext_buildEntry = void 0;
|
|
3
4
|
exports.route = route;
|
|
4
5
|
exports.getPagesAndRoutes = getPagesAndRoutes;
|
|
5
6
|
exports.getMiddlewares = getMiddlewares;
|
|
7
|
+
// Internals needed by Vike
|
|
8
|
+
var globalContext_js_1 = require("../node/runtime/globalContext.js");
|
|
9
|
+
Object.defineProperty(exports, "setGlobalContext_buildEntry", { enumerable: true, get: function () { return globalContext_js_1.setGlobalContext_buildEntry; } });
|
|
6
10
|
const index_js_1 = require("../shared/route/index.js");
|
|
7
|
-
const getPageFiles_js_1 = require("../shared/getPageFiles.js");
|
|
8
|
-
const
|
|
11
|
+
const getPageFiles_js_1 = require("../shared/getPageFiles/getPageFiles.js");
|
|
12
|
+
const globalContext_js_2 = require("../node/runtime/globalContext.js");
|
|
9
13
|
const assertSetup_js_1 = require("../utils/assertSetup.js");
|
|
10
|
-
const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderPageAlreadyRouted.js");
|
|
11
14
|
/**
|
|
12
|
-
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel}
|
|
13
|
-
* to compute some rewrite rules and extract { isr } configs.
|
|
14
|
-
* Needs `import 'vike/__internal/setup'`
|
|
15
|
-
* @param config
|
|
15
|
+
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel} to compute some rewrite rules and extract { isr } configs.
|
|
16
16
|
*/
|
|
17
17
|
async function getPagesAndRoutes() {
|
|
18
18
|
(0, assertSetup_js_1.setNodeEnvProduction)();
|
|
19
|
-
const
|
|
19
|
+
const globalContext = (0, globalContext_js_2.getGlobalContext)();
|
|
20
20
|
const {
|
|
21
21
|
//
|
|
22
|
-
pageRoutes, pageFilesAll, pageConfigs, allPageIds } =
|
|
22
|
+
pageRoutes, pageFilesAll, pageConfigs, allPageIds } = globalContext;
|
|
23
23
|
return {
|
|
24
24
|
pageRoutes,
|
|
25
25
|
pageFilesAll,
|
|
@@ -41,8 +41,8 @@ async function getMiddlewares() {
|
|
|
41
41
|
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
42
42
|
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
43
43
|
async function getPageFilesAllSafe(isProduction) {
|
|
44
|
-
await (0,
|
|
45
|
-
const globalContext = (0,
|
|
44
|
+
await (0, globalContext_js_2.initGlobalContext_getGlobalContextAsync)(isProduction);
|
|
45
|
+
const globalContext = (0, globalContext_js_2.getGlobalContext)();
|
|
46
46
|
const pageFilesAll = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
47
47
|
return pageFilesAll;
|
|
48
48
|
}
|
|
@@ -1,63 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.build = build;
|
|
27
7
|
const prepareViteApiCall_js_1 = require("./prepareViteApiCall.js");
|
|
28
8
|
const vite_1 = require("vite");
|
|
9
|
+
const assert_1 = __importDefault(require("assert"));
|
|
10
|
+
const context_js_1 = require("../cli/context.js");
|
|
11
|
+
const context_js_2 = require("../prerender/context.js");
|
|
29
12
|
/**
|
|
30
13
|
* Programmatically trigger `$ vike build`
|
|
31
14
|
*
|
|
32
15
|
* https://vike.dev/api#build
|
|
33
16
|
*/
|
|
34
17
|
async function build(options = {}) {
|
|
35
|
-
const { viteConfigEnhanced
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
const { viteConfigEnhanced } = await (0, prepareViteApiCall_js_1.prepareViteApiCall)(options.viteConfig, 'build');
|
|
19
|
+
// Pass it to autoFullBuild()
|
|
20
|
+
if (viteConfigEnhanced)
|
|
21
|
+
viteConfigEnhanced._viteConfigEnhanced = viteConfigEnhanced;
|
|
22
|
+
// 1. Build client-side
|
|
23
|
+
// 2. Build server-side
|
|
24
|
+
// > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L90
|
|
25
|
+
// 3. Pre-render (if enabled)
|
|
26
|
+
// > See: https://github.com/vikejs/vike/blob/c6c7533a56b3a16fc43ed644fc5c10c02d0ff375/vike/node/plugin/plugins/autoFullBuild.ts#L98
|
|
27
|
+
// > We purposely don't start the pre-rendering in this `build()` function but in a Rollup hook instead.
|
|
28
|
+
// > Rationale: https://github.com/vikejs/vike/issues/2123
|
|
29
|
+
await (0, vite_1.build)(viteConfigEnhanced);
|
|
30
|
+
// When using the Vike CLI with pre-rendering the process is forcefully exited at the end of the buildVite() call above
|
|
31
|
+
(0, assert_1.default)(!((0, context_js_1.isVikeCli)() && (0, context_js_2.isPrerendering)()));
|
|
47
32
|
return {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
rollupOutputClient: outputClient,
|
|
52
|
-
rollupOutputServer: outputServer
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function setSSR(viteConfig) {
|
|
56
|
-
return {
|
|
57
|
-
...viteConfig,
|
|
58
|
-
build: {
|
|
59
|
-
...viteConfig?.build,
|
|
60
|
-
ssr: true
|
|
61
|
-
}
|
|
33
|
+
/* We don't return `viteConfig` because `viteConfigEnhanced` is `InlineConfig` not `ResolvedConfig`
|
|
34
|
+
viteConfig: viteConfigEnhanced,
|
|
35
|
+
*/
|
|
62
36
|
};
|
|
63
37
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isVikeCliOrApi = isVikeCliOrApi;
|
|
4
|
-
exports.
|
|
4
|
+
exports.setContextApiOperation = setContextApiOperation;
|
|
5
|
+
exports.clearContextApiOperation = clearContextApiOperation;
|
|
5
6
|
const utils_js_1 = require("./utils.js");
|
|
6
|
-
const globalObject = (0, utils_js_1.getGlobalObject)('context.ts', {
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
function getOperation() {
|
|
7
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('api/context.ts', {});
|
|
8
|
+
function getApiOperation() {
|
|
10
9
|
(0, utils_js_1.assert)(globalObject.apiOperation);
|
|
11
10
|
return globalObject.apiOperation;
|
|
12
11
|
}
|
|
@@ -14,7 +13,10 @@ function isVikeCliOrApi() {
|
|
|
14
13
|
// The CLI uses the API
|
|
15
14
|
return !!globalObject.apiOperation;
|
|
16
15
|
}
|
|
17
|
-
function
|
|
16
|
+
function setContextApiOperation(operation) {
|
|
18
17
|
(0, utils_js_1.assert)(!globalObject.apiOperation);
|
|
19
18
|
globalObject.apiOperation = operation;
|
|
20
19
|
}
|
|
20
|
+
function clearContextApiOperation() {
|
|
21
|
+
globalObject.apiOperation = undefined;
|
|
22
|
+
}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.prerender = exports.preview = exports.dev = exports.build = void 0;
|
|
27
37
|
const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -37,20 +47,37 @@ const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/g
|
|
|
37
47
|
const path_1 = __importDefault(require("path"));
|
|
38
48
|
const utils_js_1 = require("./utils.js");
|
|
39
49
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
50
|
+
const globalContext_js_1 = require("../runtime/globalContext.js");
|
|
40
51
|
const globalObject = (0, utils_js_1.getGlobalObject)('prepareViteApiCall.ts', {});
|
|
41
52
|
async function prepareViteApiCall(viteConfig, operation) {
|
|
42
|
-
(
|
|
53
|
+
clear();
|
|
54
|
+
(0, context_js_1.setContextApiOperation)(operation);
|
|
43
55
|
return enhanceViteConfig(viteConfig, operation);
|
|
44
56
|
}
|
|
57
|
+
// For subsequent API calls, e.g. calling prerender() after build()
|
|
58
|
+
function clear() {
|
|
59
|
+
(0, context_js_1.clearContextApiOperation)();
|
|
60
|
+
(0, globalContext_js_1.clearGlobalContext)();
|
|
61
|
+
}
|
|
45
62
|
async function enhanceViteConfig(viteConfig, operation) {
|
|
46
|
-
const
|
|
47
|
-
await assertViteRoot2(root, viteConfigEnhanced, operation);
|
|
48
|
-
const
|
|
63
|
+
const viteInfo = await getInfoFromVite(viteConfig, operation);
|
|
64
|
+
await assertViteRoot2(viteInfo.root, viteInfo.viteConfigEnhanced, operation);
|
|
65
|
+
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(viteInfo.root, operation === 'dev', viteInfo.vikeVitePluginOptions);
|
|
66
|
+
const viteConfigEnhanced = addViteSettingsSetByVikeConfig(viteInfo.viteConfigEnhanced, vikeConfig);
|
|
49
67
|
return {
|
|
50
|
-
viteConfigEnhanced
|
|
51
|
-
vikeConfigGlobal
|
|
68
|
+
viteConfigEnhanced
|
|
52
69
|
};
|
|
53
70
|
}
|
|
71
|
+
function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
72
|
+
const viteConfigs = vikeConfig.global.from.configsCumulative.vite;
|
|
73
|
+
if (!viteConfigs)
|
|
74
|
+
return viteConfigEnhanced;
|
|
75
|
+
viteConfigs.values.forEach((v) => {
|
|
76
|
+
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(v.value), `${v.definedAt} should be an object`);
|
|
77
|
+
viteConfigEnhanced = (0, vite_1.mergeConfig)(viteConfigEnhanced ?? {}, v.value);
|
|
78
|
+
});
|
|
79
|
+
return viteConfigEnhanced;
|
|
80
|
+
}
|
|
54
81
|
async function getViteRoot(operation) {
|
|
55
82
|
if (!globalObject.root)
|
|
56
83
|
await getInfoFromVite(undefined, operation);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isVikeCli = isVikeCli;
|
|
4
|
+
exports.setContextCliCommand = setContextCliCommand;
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
6
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('cli/context.ts', {});
|
|
7
|
+
function getCliCommand() {
|
|
8
|
+
return globalObject.cliCommand;
|
|
9
|
+
}
|
|
10
|
+
function isVikeCli() {
|
|
11
|
+
return !!globalObject.cliCommand;
|
|
12
|
+
}
|
|
13
|
+
function setContextCliCommand(command) {
|
|
14
|
+
(0, utils_js_1.assert)(!globalObject.cliCommand);
|
|
15
|
+
globalObject.cliCommand = command;
|
|
16
|
+
}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -30,9 +40,11 @@ const utils_js_1 = require("./utils.js");
|
|
|
30
40
|
const index_js_1 = require("../api/index.js");
|
|
31
41
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
32
42
|
const parseCli_js_1 = require("./parseCli.js");
|
|
43
|
+
const context_js_1 = require("./context.js");
|
|
33
44
|
cli();
|
|
34
45
|
async function cli() {
|
|
35
46
|
const { command } = (0, parseCli_js_1.parseCli)();
|
|
47
|
+
(0, context_js_1.setContextCliCommand)(command);
|
|
36
48
|
if (command === 'dev') {
|
|
37
49
|
await cmdDev();
|
|
38
50
|
}
|
|
@@ -77,6 +89,8 @@ async function cmdBuild() {
|
|
|
77
89
|
console.error(err);
|
|
78
90
|
process.exit(1);
|
|
79
91
|
}
|
|
92
|
+
// See comments at runPrerender_forceExit()
|
|
93
|
+
process.exit(0);
|
|
80
94
|
}
|
|
81
95
|
async function cmdPreview() {
|
|
82
96
|
try {
|
|
@@ -21,3 +21,4 @@ const onLoad_js_1 = require("./onLoad.js");
|
|
|
21
21
|
__exportStar(require("../../utils/assert.js"), exports);
|
|
22
22
|
__exportStar(require("../../utils/projectInfo.js"), exports);
|
|
23
23
|
__exportStar(require("../../utils/includes.js"), exports);
|
|
24
|
+
__exportStar(require("../../utils/getGlobalObject.js"), exports);
|
|
@@ -23,7 +23,7 @@ const extractAssetsPlugin_js_1 = require("./plugins/extractAssetsPlugin.js");
|
|
|
23
23
|
const extractExportNamesPlugin_js_1 = require("./plugins/extractExportNamesPlugin.js");
|
|
24
24
|
const suppressRollupWarning_js_1 = require("./plugins/suppressRollupWarning.js");
|
|
25
25
|
const setGlobalContext_js_1 = require("./plugins/setGlobalContext.js");
|
|
26
|
-
const index_js_3 = require("./plugins/
|
|
26
|
+
const index_js_3 = require("./plugins/buildEntry/index.js");
|
|
27
27
|
const commonConfig_js_1 = require("./plugins/commonConfig.js");
|
|
28
28
|
const baseUrls_js_1 = require("./plugins/baseUrls.js");
|
|
29
29
|
const envVars_js_1 = require("./plugins/envVars.js");
|
|
@@ -32,7 +32,7 @@ const fileEnv_js_1 = require("./plugins/fileEnv.js");
|
|
|
32
32
|
const getPageAssets_js_1 = require("../runtime/renderPage/getPageAssets.js");
|
|
33
33
|
const resolveClientEntriesDev_js_1 = require("./resolveClientEntriesDev.js");
|
|
34
34
|
const workaroundCssModuleHmr_js_1 = require("./plugins/workaroundCssModuleHmr.js");
|
|
35
|
-
const
|
|
35
|
+
const workaroundVite6HmrRegression_js_1 = require("./plugins/workaroundVite6HmrRegression.js");
|
|
36
36
|
(0, utils_js_2.markSetup_vikeVitePlugin)();
|
|
37
37
|
assertViteVersion();
|
|
38
38
|
(0, getPageAssets_js_1.setResolveClientEntriesDev)(resolveClientEntriesDev_js_1.resolveClientEntriesDev);
|
|
@@ -52,12 +52,12 @@ function plugin(vikeVitePluginOptions = {}) {
|
|
|
52
52
|
(0, extractExportNamesPlugin_js_1.extractExportNamesPlugin)(),
|
|
53
53
|
(0, suppressRollupWarning_js_1.suppressRollupWarning)(),
|
|
54
54
|
...(0, setGlobalContext_js_1.setGlobalContext)(),
|
|
55
|
-
...(0, index_js_3.
|
|
56
|
-
(0, baseUrls_js_1.baseUrls)(
|
|
55
|
+
...(0, index_js_3.buildEntry)(),
|
|
56
|
+
(0, baseUrls_js_1.baseUrls)(),
|
|
57
57
|
(0, envVars_js_1.envVarsPlugin)(),
|
|
58
58
|
(0, fileEnv_js_1.fileEnv)(),
|
|
59
59
|
(0, workaroundCssModuleHmr_js_1.workaroundCssModuleHmr)(),
|
|
60
|
-
(0,
|
|
60
|
+
(0, workaroundVite6HmrRegression_js_1.workaroundVite6HmrRegression)()
|
|
61
61
|
];
|
|
62
62
|
Object.assign(plugins, { __vikeVitePluginOptions: vikeVitePluginOptions });
|
|
63
63
|
return plugins;
|
|
@@ -8,11 +8,14 @@ exports.autoFullBuild = autoFullBuild;
|
|
|
8
8
|
const vite_1 = require("vite");
|
|
9
9
|
const utils_js_1 = require("../utils.js");
|
|
10
10
|
const runPrerender_js_1 = require("../../prerender/runPrerender.js");
|
|
11
|
+
const context_js_1 = require("../../prerender/context.js");
|
|
11
12
|
const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
|
|
12
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
14
|
const logErrorHint_js_1 = require("../../runtime/renderPage/logErrorHint.js");
|
|
14
15
|
const buildConfig_js_1 = require("./buildConfig.js");
|
|
15
16
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
17
|
+
const context_js_2 = require("../../api/context.js");
|
|
18
|
+
const context_js_3 = require("../../cli/context.js");
|
|
16
19
|
let forceExit = false;
|
|
17
20
|
function autoFullBuild() {
|
|
18
21
|
let config;
|
|
@@ -73,35 +76,43 @@ async function triggerFullBuild(config, vikeConfigGlobal, bundle) {
|
|
|
73
76
|
if (!bundle[buildConfig_js_1.manifestTempFile])
|
|
74
77
|
return;
|
|
75
78
|
const configFromCli = !(0, isViteCliCall_js_1.isViteCliCall)() ? null : (0, isViteCliCall_js_1.getViteConfigFromCli)();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
await (0, vite_1.build)({
|
|
86
|
-
...configInline,
|
|
79
|
+
let configInline;
|
|
80
|
+
if (config._viteConfigEnhanced) {
|
|
81
|
+
configInline = config._viteConfigEnhanced;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
configInline = {
|
|
85
|
+
...configFromCli,
|
|
86
|
+
configFile: configFromCli?.configFile || config.configFile,
|
|
87
|
+
root: config.root,
|
|
87
88
|
build: {
|
|
88
|
-
...
|
|
89
|
-
ssr: true
|
|
89
|
+
...configFromCli?.build
|
|
90
90
|
}
|
|
91
|
-
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
await (0, vite_1.build)(setSSR(configInline));
|
|
92
95
|
}
|
|
93
96
|
catch (err) {
|
|
94
97
|
console.error(err);
|
|
95
98
|
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
96
99
|
process.exit(1);
|
|
97
100
|
}
|
|
98
|
-
if (vikeConfigGlobal
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
forceExit = true;
|
|
101
|
+
if ((0, context_js_1.isPrerenderAutoRunEnabled)(vikeConfigGlobal)) {
|
|
102
|
+
const { prerenderContextPublic } = await (0, runPrerender_js_1.runPrerenderFromAutoRun)(configInline);
|
|
103
|
+
config.vike.prerenderContext = prerenderContextPublic;
|
|
104
|
+
forceExit = (0, context_js_3.isVikeCli)() || (0, isViteCliCall_js_1.isViteCliCall)();
|
|
103
105
|
}
|
|
104
106
|
}
|
|
107
|
+
function setSSR(configInline) {
|
|
108
|
+
return {
|
|
109
|
+
...configInline,
|
|
110
|
+
build: {
|
|
111
|
+
...configInline.build,
|
|
112
|
+
ssr: true
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
105
116
|
function abortViteBuildSsr(vikeConfigGlobal) {
|
|
106
117
|
if (vikeConfigGlobal.disableAutoFullBuild !== true && (0, isViteCliCall_js_1.isViteCliCall)() && (0, isViteCliCall_js_1.getViteConfigFromCli)()?.build.ssr) {
|
|
107
118
|
(0, utils_js_1.assertWarning)(false, `The CLI call ${picocolors_1.default.cyan('$ vite build --ssr')} is superfluous since ${picocolors_1.default.cyan('$ vite build')} also builds the server-side. If you want two separate build steps then use https://vike.dev/disableAutoFullBuild or use Vite's ${picocolors_1.default.cyan('build()')} API.`, { onlyOnce: true });
|
|
@@ -111,7 +122,8 @@ function abortViteBuildSsr(vikeConfigGlobal) {
|
|
|
111
122
|
function isDisabled(vikeConfigGlobal) {
|
|
112
123
|
const { disableAutoFullBuild } = vikeConfigGlobal;
|
|
113
124
|
if (disableAutoFullBuild === null || disableAutoFullBuild === 'prerender') {
|
|
114
|
-
|
|
125
|
+
const isViteApi = !(0, isViteCliCall_js_1.isViteCliCall)() && !(0, context_js_2.isVikeCliOrApi)();
|
|
126
|
+
return isViteApi;
|
|
115
127
|
}
|
|
116
128
|
else {
|
|
117
129
|
return disableAutoFullBuild;
|
|
@@ -4,22 +4,16 @@ exports.baseUrls = baseUrls;
|
|
|
4
4
|
const resolveBase_js_1 = require("../../shared/resolveBase.js");
|
|
5
5
|
const utils_js_1 = require("../utils.js");
|
|
6
6
|
const getVikeConfig_js_1 = require("./importUserCode/v1-design/getVikeConfig.js");
|
|
7
|
-
|
|
8
|
-
function baseUrls(vikeVitePluginOptions) {
|
|
7
|
+
function baseUrls() {
|
|
9
8
|
let basesResolved;
|
|
10
|
-
let root;
|
|
11
9
|
return {
|
|
12
10
|
name: 'vike:baseUrls',
|
|
13
11
|
enforce: 'post',
|
|
14
|
-
async config(config
|
|
12
|
+
async config(config) {
|
|
15
13
|
const isDev = config._isDev;
|
|
16
14
|
(0, utils_js_1.assert)(typeof isDev === 'boolean');
|
|
17
|
-
const operation = env.command === 'build' ? 'build' : env.isPreview ? 'preview' : 'dev';
|
|
18
|
-
root = config.root ? (0, prepareViteApiCall_js_1.normalizeViteRoot)(config.root) : await (0, prepareViteApiCall_js_1.getViteRoot)(operation);
|
|
19
|
-
(0, utils_js_1.assert)(root);
|
|
20
15
|
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
21
|
-
|
|
22
|
-
basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets);
|
|
16
|
+
basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, config._vikeConfigGlobal.baseServer, config._vikeConfigGlobal.baseAssets);
|
|
23
17
|
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
24
18
|
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
25
19
|
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
@@ -34,7 +28,6 @@ function baseUrls(vikeVitePluginOptions) {
|
|
|
34
28
|
};
|
|
35
29
|
},
|
|
36
30
|
async configResolved(config) {
|
|
37
|
-
(0, prepareViteApiCall_js_1.assertViteRoot)(root, config);
|
|
38
31
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
39
32
|
const basesResolved2 = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets, config);
|
|
40
33
|
(0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
|
|
@@ -16,7 +16,7 @@ const module_1 = require("module");
|
|
|
16
16
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const fixServerAssets_js_1 = require("./buildConfig/fixServerAssets.js");
|
|
19
|
-
const index_js_1 = require("./
|
|
19
|
+
const index_js_1 = require("./buildEntry/index.js");
|
|
20
20
|
const prependEntriesDir_js_1 = require("../../shared/prependEntriesDir.js");
|
|
21
21
|
const getFilePath_js_1 = require("../shared/getFilePath.js");
|
|
22
22
|
const getConfigValueBuildTime_js_1 = require("../../../shared/page-configs/getConfigValueBuildTime.js");
|
|
@@ -123,7 +123,7 @@ async function getEntries(config) {
|
|
|
123
123
|
if ((0, utils_js_1.viteIsSSR)(config)) {
|
|
124
124
|
const pageEntries = getPageEntries(pageConfigs);
|
|
125
125
|
const entries = {
|
|
126
|
-
//
|
|
126
|
+
// buildEntry: resolve('dist/esm/node/buildEntry.js'), // TODO/next-major-release: remove
|
|
127
127
|
...pageFileEntries,
|
|
128
128
|
// Ensure Rollup generates a bundle per page: https://github.com/vikejs/vike/issues/349#issuecomment-1166247275
|
|
129
129
|
...pageEntries
|
|
@@ -3,26 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.buildEntry = buildEntry;
|
|
7
7
|
exports.set_ASSETS_MAP = set_ASSETS_MAP;
|
|
8
8
|
const plugin_1 = require("@brillout/vite-plugin-server-entry/plugin");
|
|
9
|
+
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
|
+
const getVikeManifest_js_1 = require("./getVikeManifest.js");
|
|
11
|
+
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
9
12
|
const utils_js_1 = require("../../utils.js");
|
|
13
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
10
14
|
const path_1 = __importDefault(require("path"));
|
|
11
15
|
const module_1 = require("module");
|
|
12
|
-
const getVikeManifest_js_1 = require("./getVikeManifest.js");
|
|
13
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
14
|
-
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
15
|
-
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
16
16
|
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
17
17
|
const importMetaUrl = `file://${__filename}`;
|
|
18
18
|
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
19
19
|
const ASSETS_MAP = '__VITE_ASSETS_MAP__';
|
|
20
|
-
function
|
|
20
|
+
function buildEntry() {
|
|
21
21
|
let config;
|
|
22
22
|
let vikeConfigGlobal;
|
|
23
23
|
return [
|
|
24
24
|
{
|
|
25
|
-
name: 'vike:
|
|
25
|
+
name: 'vike:buildEntry',
|
|
26
26
|
enforce: 'post',
|
|
27
27
|
async configResolved(config_) {
|
|
28
28
|
config = config_;
|
|
@@ -43,17 +43,16 @@ function getServerProductionEntryCode(config, vikeConfigGlobal) {
|
|
|
43
43
|
const vikeManifest = (0, getVikeManifest_js_1.getVikeManifest)(vikeConfigGlobal, config);
|
|
44
44
|
// Let's eventually simplify and move everything to a single virtual module
|
|
45
45
|
const importerCode = [
|
|
46
|
-
` import {
|
|
46
|
+
` import { setGlobalContext_buildEntry } from '${importPath}';`,
|
|
47
47
|
` import * as pageFiles from '${virtualFileImportUserCode_js_1.virtualFileIdImportUserCodeServer}';`,
|
|
48
48
|
` {`,
|
|
49
49
|
// We first set the values to a variable because of a Rollup bug, and this workaround doesn't work: https://github.com/vikejs/vike/commit/d5f3a4f7aae5a8bc44192e6cbb2bcb9007be188d
|
|
50
50
|
` const assetsManifest = ${ASSETS_MAP};`,
|
|
51
51
|
` const pluginManifest = ${JSON.stringify(vikeManifest, null, 2)};`,
|
|
52
|
-
'
|
|
53
|
-
` pageFiles
|
|
54
|
-
`
|
|
55
|
-
|
|
56
|
-
` pluginManifest: () => pluginManifest,`,
|
|
52
|
+
' setGlobalContext_buildEntry({',
|
|
53
|
+
` pageFiles,`,
|
|
54
|
+
` assetsManifest,`,
|
|
55
|
+
` pluginManifest,`,
|
|
57
56
|
' });',
|
|
58
57
|
` }`,
|
|
59
58
|
''
|
|
@@ -90,12 +89,12 @@ function find_ASSETS_MAP(bundle) {
|
|
|
90
89
|
function getImportPath(config) {
|
|
91
90
|
// We resolve filePathAbsolute even if we don't use it: we use require.resolve() as an assertion that the relative path is correct
|
|
92
91
|
const filePathAbsolute = (0, utils_js_1.toPosixPath)(
|
|
93
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/
|
|
94
|
-
require_.resolve(`../../../../../../dist/esm/
|
|
92
|
+
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/buildEntry/index.js
|
|
93
|
+
require_.resolve(`../../../../../../dist/esm/__internal/index.js`));
|
|
95
94
|
if (
|
|
96
|
-
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal
|
|
95
|
+
// Let's implement a new config if a user needs the import to be a relative path instead of 'vike/__internal' (AFAIK a relative path is needed only if a framework has npm package 'vike' as direct dependency instead of a peer dependency and if the user of that framework uses pnpm)
|
|
97
96
|
true) {
|
|
98
|
-
return 'vike/__internal
|
|
97
|
+
return 'vike/__internal';
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
100
|
const { outDirServer } = (0, utils_js_1.getOutDirs)(config);
|