vike 0.4.217-commit-99ea561 → 0.4.218-commit-01a099d
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 +9 -8
- package/dist/cjs/node/api/build.js +20 -11
- package/dist/cjs/node/api/index.js +17 -7
- package/dist/cjs/node/api/prepareViteApiCall.js +109 -26
- package/dist/cjs/node/api/utils.js +2 -0
- package/dist/cjs/node/cli/entry.js +17 -7
- package/dist/cjs/node/plugin/index.js +6 -5
- package/dist/cjs/node/plugin/plugins/autoFullBuild.js +2 -3
- package/dist/cjs/node/plugin/plugins/baseUrls.js +20 -18
- 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 +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +7 -9
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +182 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- 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/isPrerenderEnabled.js +8 -0
- package/dist/cjs/node/prerender/runPrerender.js +21 -12
- package/dist/cjs/node/runtime/globalContext.js +44 -21
- 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/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 +3 -3
- package/dist/cjs/node/runtime-dev/index.js +17 -7
- package/dist/cjs/node/shared/resolveBase.js +2 -2
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- 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/serialize/serializeConfigValues.js +79 -54
- 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/esm/__internal/index.d.ts +3 -5
- package/dist/esm/__internal/index.js +4 -5
- package/dist/esm/client/client-routing-runtime/createPageContext.js +7 -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/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/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 +8 -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/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/api/build.js +3 -4
- package/dist/esm/node/api/prepareViteApiCall.d.ts +9 -3
- package/dist/esm/node/api/prepareViteApiCall.js +91 -21
- package/dist/esm/node/api/utils.d.ts +2 -0
- package/dist/esm/node/api/utils.js +2 -0
- package/dist/esm/node/cli/parseCli.d.ts +1 -1
- package/dist/esm/node/plugin/index.d.ts +1 -1
- package/dist/esm/node/plugin/index.js +6 -5
- package/dist/esm/node/plugin/plugins/autoFullBuild.js +2 -3
- package/dist/esm/node/plugin/plugins/baseUrls.d.ts +1 -2
- package/dist/esm/node/plugin/plugins/baseUrls.js +21 -19
- 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 +1 -1
- package/dist/esm/node/plugin/plugins/commonConfig.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +1 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +8 -10
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +99 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +182 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +2 -1
- 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/isPrerenderEnabled.d.ts +3 -0
- package/dist/esm/node/prerender/isPrerenderEnabled.js +6 -0
- package/dist/esm/node/prerender/runPrerender.d.ts +1 -2
- package/dist/esm/node/prerender/runPrerender.js +3 -4
- package/dist/esm/node/runtime/globalContext.d.ts +4 -4
- package/dist/esm/node/runtime/globalContext.js +44 -21
- 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/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 +5 -5
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js +3 -3
- package/dist/esm/node/shared/resolveBase.js +2 -2
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/{setPageFiles.js → getPageFiles.js} +2 -3
- 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.d.ts +1 -1
- package/dist/esm/shared/page-configs/PageConfig.d.ts +7 -3
- package/dist/esm/shared/{getPageFiles/getExports.d.ts → page-configs/getPageConfigUserFriendly.d.ts} +23 -12
- package/dist/esm/shared/{getPageFiles/getExports.js → page-configs/getPageConfigUserFriendly.js} +112 -80
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.d.ts +28 -4
- package/dist/esm/shared/page-configs/serialize/serializeConfigValues.js +79 -54
- 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/projectInfo.d.ts +1 -1
- package/package.json +2 -21
- package/__internal/loadImportBuild.js +0 -3
- package/__internal/setup.js +0 -3
- package/dist/cjs/node/plugin/plugins/commonConfig/pluginName.js +0 -4
- 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/cjs/node/runtime/page-files/setup.js +0 -5
- 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/commonConfig/pluginName.d.ts +0 -1
- package/dist/esm/node/plugin/plugins/commonConfig/pluginName.js +0 -1
- 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/esm/node/runtime/page-files/setup.d.ts +0 -1
- package/dist/esm/node/runtime/page-files/setup.js +0 -3
- 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/getPageFiles/{setPageFiles.d.ts → getPageFiles.d.ts} +1 -1
- /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,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setBuildEntry = 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, "setBuildEntry", { enumerable: true, get: function () { return globalContext_js_1.setBuildEntry; } });
|
|
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
14
|
const renderPageAlreadyRouted_js_1 = require("../node/runtime/renderPage/renderPageAlreadyRouted.js");
|
|
11
15
|
/**
|
|
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
|
|
16
|
+
* Used by {@link https://github.com/magne4000/vite-plugin-vercel|vite-plugin-vercel} to compute some rewrite rules and extract { isr } configs.
|
|
16
17
|
*/
|
|
17
18
|
async function getPagesAndRoutes() {
|
|
18
19
|
(0, assertSetup_js_1.setNodeEnvProduction)();
|
|
@@ -41,8 +42,8 @@ async function getMiddlewares() {
|
|
|
41
42
|
// - Remove it in favor of https://vike.dev/getGlobalContext
|
|
42
43
|
// Demo usage: https://github.com/vikejs/vike/pull/1823
|
|
43
44
|
async function getPageFilesAllSafe(isProduction) {
|
|
44
|
-
await (0,
|
|
45
|
-
const globalContext = (0,
|
|
45
|
+
await (0, globalContext_js_2.initGlobalContext_getGlobalContextAsync)(isProduction);
|
|
46
|
+
const globalContext = (0, globalContext_js_2.getGlobalContext)();
|
|
46
47
|
const pageFilesAll = await (0, getPageFiles_js_1.getPageFilesAll)(false, globalContext.isProduction);
|
|
47
48
|
return pageFilesAll;
|
|
48
49
|
}
|
|
@@ -15,17 +15,28 @@ 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.build = build;
|
|
27
37
|
const prepareViteApiCall_js_1 = require("./prepareViteApiCall.js");
|
|
28
38
|
const vite_1 = require("vite");
|
|
39
|
+
const isPrerenderEnabled_js_1 = require("../prerender/isPrerenderEnabled.js");
|
|
29
40
|
/**
|
|
30
41
|
* Programmatically trigger `$ vike build`
|
|
31
42
|
*
|
|
@@ -38,9 +49,7 @@ async function build(options = {}) {
|
|
|
38
49
|
// Build server-side
|
|
39
50
|
const outputServer = await (0, vite_1.build)(setSSR(viteConfigEnhanced));
|
|
40
51
|
// Pre-render
|
|
41
|
-
if (vikeConfigGlobal
|
|
42
|
-
!vikeConfigGlobal.prerender.disableAutoRun &&
|
|
43
|
-
vikeConfigGlobal.disableAutoFullBuild !== 'prerender') {
|
|
52
|
+
if ((0, isPrerenderEnabled_js_1.isPrerenderEnabled)(vikeConfigGlobal)) {
|
|
44
53
|
const { runPrerenderFromAutoRun } = await Promise.resolve().then(() => __importStar(require('../prerender/runPrerender.js')));
|
|
45
54
|
await runPrerenderFromAutoRun(viteConfigEnhanced, true);
|
|
46
55
|
}
|
|
@@ -56,7 +65,7 @@ function setSSR(viteConfig) {
|
|
|
56
65
|
return {
|
|
57
66
|
...viteConfig,
|
|
58
67
|
build: {
|
|
59
|
-
...viteConfig
|
|
68
|
+
...viteConfig?.build,
|
|
60
69
|
ssr: true
|
|
61
70
|
}
|
|
62
71
|
};
|
|
@@ -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,49 +15,117 @@ 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
|
-
|
|
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
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
37
|
};
|
|
25
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
39
|
exports.prepareViteApiCall = prepareViteApiCall;
|
|
40
|
+
exports.getViteRoot = getViteRoot;
|
|
41
|
+
exports.assertViteRoot = assertViteRoot;
|
|
42
|
+
exports.normalizeViteRoot = normalizeViteRoot;
|
|
43
|
+
// TODO: enable Vike extensions to add Vite plugins
|
|
27
44
|
const vite_1 = require("vite");
|
|
28
|
-
const pluginName_js_1 = require("../plugin/plugins/commonConfig/pluginName.js");
|
|
29
45
|
const context_js_1 = require("./context.js");
|
|
30
46
|
const getVikeConfig_js_1 = require("../plugin/plugins/importUserCode/v1-design/getVikeConfig.js");
|
|
31
|
-
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
48
|
+
const utils_js_1 = require("./utils.js");
|
|
49
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
50
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('prepareViteApiCall.ts', {});
|
|
51
|
+
async function prepareViteApiCall(viteConfig, operation) {
|
|
32
52
|
(0, context_js_1.setOperation)(operation);
|
|
33
53
|
return enhanceViteConfig(viteConfig, operation);
|
|
34
54
|
}
|
|
35
|
-
async function enhanceViteConfig(viteConfig
|
|
36
|
-
|
|
55
|
+
async function enhanceViteConfig(viteConfig, operation) {
|
|
56
|
+
const { root, vikeVitePluginOptions, viteConfigEnhanced } = await getInfoFromVite(viteConfig, operation);
|
|
57
|
+
await assertViteRoot2(root, viteConfigEnhanced, operation);
|
|
58
|
+
const { vikeConfigGlobal } = await (0, getVikeConfig_js_1.getVikeConfig2)(root, operation === 'dev', vikeVitePluginOptions);
|
|
59
|
+
return {
|
|
60
|
+
viteConfigEnhanced,
|
|
61
|
+
vikeConfigGlobal
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function getViteRoot(operation) {
|
|
65
|
+
if (!globalObject.root)
|
|
66
|
+
await getInfoFromVite(undefined, operation);
|
|
67
|
+
(0, utils_js_1.assert)(globalObject.root);
|
|
68
|
+
return globalObject.root;
|
|
69
|
+
}
|
|
70
|
+
async function getInfoFromVite(viteConfig, operation) {
|
|
71
|
+
const viteConfigFromFile = await loadViteConfigFile(viteConfig, operation);
|
|
72
|
+
const root = normalizeViteRoot(viteConfigFromFile?.root ?? viteConfig?.root ?? process.cwd());
|
|
73
|
+
globalObject.root = root;
|
|
74
|
+
let vikeVitePluginOptions;
|
|
37
75
|
let viteConfigEnhanced = viteConfig;
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
76
|
+
const found = findVikeVitePlugin([...(viteConfig?.plugins ?? []), ...(viteConfigFromFile?.plugins ?? [])]);
|
|
77
|
+
if (found) {
|
|
78
|
+
vikeVitePluginOptions = found.vikeVitePluginOptions;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// Add Vike to plugins if not present.
|
|
82
|
+
// Using a dynamic import because the script calling the Vike API may not live in the same place as vite.config.js, thus vike/plugin may resolved to two different node_modules/vike directories.
|
|
41
83
|
const { plugin: vikePlugin } = await Promise.resolve().then(() => __importStar(require('../plugin/index.js')));
|
|
42
84
|
viteConfigEnhanced = {
|
|
43
85
|
...viteConfig,
|
|
44
|
-
plugins: [...(viteConfig
|
|
86
|
+
plugins: [...(viteConfig?.plugins ?? []), vikePlugin()]
|
|
45
87
|
};
|
|
46
|
-
|
|
88
|
+
const res = findVikeVitePlugin(viteConfigEnhanced.plugins);
|
|
89
|
+
(0, utils_js_1.assert)(res);
|
|
90
|
+
vikeVitePluginOptions = res.vikeVitePluginOptions;
|
|
47
91
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
92
|
+
(0, utils_js_1.assert)(vikeVitePluginOptions);
|
|
93
|
+
return { root, vikeVitePluginOptions, viteConfigEnhanced };
|
|
94
|
+
}
|
|
95
|
+
function findVikeVitePlugin(plugins) {
|
|
96
|
+
let vikeVitePluginOptions;
|
|
97
|
+
let vikeVitePuginFound = false;
|
|
98
|
+
plugins.forEach((p) => {
|
|
99
|
+
if (p && '__vikeVitePluginOptions' in p) {
|
|
100
|
+
vikeVitePuginFound = true;
|
|
101
|
+
const options = p.__vikeVitePluginOptions;
|
|
102
|
+
vikeVitePluginOptions ?? (vikeVitePluginOptions = {});
|
|
103
|
+
Object.assign(vikeVitePluginOptions, options);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
if (!vikeVitePuginFound)
|
|
107
|
+
return null;
|
|
108
|
+
return { vikeVitePluginOptions };
|
|
55
109
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
110
|
+
// Copied from https://github.com/vitejs/vite/blob/4f5845a3182fc950eb9cd76d7161698383113b18/packages/vite/src/node/config.ts#L961-L1005
|
|
111
|
+
async function loadViteConfigFile(viteConfig, operation) {
|
|
112
|
+
const [inlineConfig, command, defaultMode, _defaultNodeEnv, isPreview] = getResolveConfigArgs(viteConfig, operation);
|
|
113
|
+
let config = inlineConfig;
|
|
114
|
+
let mode = inlineConfig.mode || defaultMode;
|
|
115
|
+
const configEnv = {
|
|
116
|
+
mode,
|
|
117
|
+
command,
|
|
118
|
+
isSsrBuild: command === 'build' && !!config.build?.ssr,
|
|
119
|
+
isPreview
|
|
120
|
+
};
|
|
121
|
+
let { configFile } = config;
|
|
122
|
+
if (configFile !== false) {
|
|
123
|
+
const loadResult = await (0, vite_1.loadConfigFromFile)(configEnv, configFile, config.root, config.logLevel, config.customLogger);
|
|
124
|
+
return loadResult?.config;
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
59
127
|
}
|
|
60
|
-
function getResolveConfigArgs(viteConfig, operation) {
|
|
128
|
+
function getResolveConfigArgs(viteConfig = {}, operation) {
|
|
61
129
|
const inlineConfig = viteConfig;
|
|
62
130
|
const command = operation === 'build' || operation === 'prerender' ? 'build' : 'serve';
|
|
63
131
|
const defaultMode = operation === 'dev' ? 'development' : 'production';
|
|
@@ -65,3 +133,18 @@ function getResolveConfigArgs(viteConfig, operation) {
|
|
|
65
133
|
const isPreview = operation === 'preview';
|
|
66
134
|
return [inlineConfig, command, defaultMode, defaultNodeEnv, isPreview];
|
|
67
135
|
}
|
|
136
|
+
function normalizeViteRoot(root) {
|
|
137
|
+
return (0, utils_js_1.toPosixPath)(path_1.default.resolve(root));
|
|
138
|
+
}
|
|
139
|
+
const errMsg = `A Vite plugin is modifying Vite's setting ${picocolors_1.default.cyan('root')} which is forbidden`;
|
|
140
|
+
async function assertViteRoot2(root, viteConfigEnhanced, operation) {
|
|
141
|
+
const args = getResolveConfigArgs(viteConfigEnhanced, operation);
|
|
142
|
+
// We can eventually this resolveConfig() call (along with removing the whole assertViteRoot2() function which is redundant with the assertViteRoot() function) so that Vike doesn't make any resolveConfig() (except for pre-rendering which is required). But let's keep it for now, just to see whether calling resolveConfig() can be problematic.
|
|
143
|
+
const viteConfigResolved = await (0, vite_1.resolveConfig)(...args);
|
|
144
|
+
(0, utils_js_1.assertUsage)(normalizeViteRoot(viteConfigResolved.root) === normalizeViteRoot(root), errMsg);
|
|
145
|
+
}
|
|
146
|
+
function assertViteRoot(root, config) {
|
|
147
|
+
if (globalObject.root)
|
|
148
|
+
(0, utils_js_1.assert)(normalizeViteRoot(globalObject.root) === normalizeViteRoot(root));
|
|
149
|
+
(0, utils_js_1.assertUsage)(normalizeViteRoot(root) === normalizeViteRoot(config.root), errMsg);
|
|
150
|
+
}
|
|
@@ -20,3 +20,5 @@ const onLoad_js_1 = require("./onLoad.js");
|
|
|
20
20
|
(0, onLoad_js_1.onLoad)();
|
|
21
21
|
__exportStar(require("../../utils/assert.js"), exports);
|
|
22
22
|
__exportStar(require("../../utils/getGlobalObject.js"), exports);
|
|
23
|
+
__exportStar(require("../../utils/filesystemPathHandling.js"), exports);
|
|
24
|
+
__exportStar(require("../../utils/isObject.js"), exports);
|
|
@@ -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
|
};
|
|
@@ -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,12 +32,12 @@ 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);
|
|
39
39
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
40
|
-
function plugin(vikeVitePluginOptions) {
|
|
40
|
+
function plugin(vikeVitePluginOptions = {}) {
|
|
41
41
|
const plugins = [
|
|
42
42
|
...(0, commonConfig_js_1.commonConfig)(vikeVitePluginOptions),
|
|
43
43
|
(0, index_js_2.importUserCode)(),
|
|
@@ -52,13 +52,14 @@ 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.
|
|
55
|
+
...(0, index_js_3.buildEntry)(),
|
|
56
56
|
(0, baseUrls_js_1.baseUrls)(vikeVitePluginOptions),
|
|
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
|
+
Object.assign(plugins, { __vikeVitePluginOptions: vikeVitePluginOptions });
|
|
62
63
|
return plugins;
|
|
63
64
|
}
|
|
64
65
|
// Error upon wrong usage
|
|
@@ -8,6 +8,7 @@ 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 isPrerenderEnabled_js_1 = require("../../prerender/isPrerenderEnabled.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");
|
|
@@ -95,9 +96,7 @@ async function triggerFullBuild(config, vikeConfigGlobal, bundle) {
|
|
|
95
96
|
(0, logErrorHint_js_1.logErrorHint)(err);
|
|
96
97
|
process.exit(1);
|
|
97
98
|
}
|
|
98
|
-
if (vikeConfigGlobal
|
|
99
|
-
!vikeConfigGlobal.prerender.disableAutoRun &&
|
|
100
|
-
vikeConfigGlobal.disableAutoFullBuild !== 'prerender') {
|
|
99
|
+
if ((0, isPrerenderEnabled_js_1.isPrerenderEnabled)(vikeConfigGlobal)) {
|
|
101
100
|
await (0, runPrerender_js_1.runPrerenderFromAutoRun)(configInline, false);
|
|
102
101
|
forceExit = true;
|
|
103
102
|
}
|
|
@@ -4,35 +4,41 @@ 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
|
+
const prepareViteApiCall_js_1 = require("../../api/prepareViteApiCall.js");
|
|
7
8
|
function baseUrls(vikeVitePluginOptions) {
|
|
8
|
-
let
|
|
9
|
+
let basesResolved;
|
|
10
|
+
let root;
|
|
9
11
|
return {
|
|
10
12
|
name: 'vike:baseUrls',
|
|
11
13
|
enforce: 'post',
|
|
12
|
-
async config(config) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
async config(config, env) {
|
|
15
|
+
const isDev = config._isDev;
|
|
16
|
+
(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
|
+
const baseViteOriginal = config.base ?? '/__UNSET__'; // '/__UNSET__' because Vite resolves `_baseViteOriginal: null` to `undefined`
|
|
21
|
+
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig2)(root, isDev, vikeVitePluginOptions);
|
|
22
|
+
basesResolved = (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets);
|
|
16
23
|
// We cannot define these in configResolved() because Vite picks up the env variables before any configResolved() hook is called
|
|
17
|
-
process.env.BASE_SERVER = baseServer;
|
|
18
|
-
process.env.BASE_ASSETS = baseAssets;
|
|
24
|
+
process.env.BASE_SERVER = basesResolved.baseServer;
|
|
25
|
+
process.env.BASE_ASSETS = basesResolved.baseAssets;
|
|
19
26
|
return {
|
|
20
27
|
envPrefix: [
|
|
21
28
|
'VITE_', // Vite doesn't seem to merge in its default, see https://github.com/vikejs/vike/issues/554
|
|
22
29
|
'BASE_SERVER',
|
|
23
30
|
'BASE_ASSETS'
|
|
24
31
|
],
|
|
25
|
-
base: baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
|
|
26
|
-
_baseViteOriginal:
|
|
32
|
+
base: basesResolved.baseAssets, // Make Vite inject baseAssets to imports e.g. `import logoUrl from './logo.svg.js'`
|
|
33
|
+
_baseViteOriginal: baseViteOriginal
|
|
27
34
|
};
|
|
28
35
|
},
|
|
29
36
|
async configResolved(config) {
|
|
37
|
+
(0, prepareViteApiCall_js_1.assertViteRoot)(root, config);
|
|
30
38
|
const vikeConfig = await (0, getVikeConfig_js_1.getVikeConfig)(config);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(0, utils_js_1.assert)(basesResolved.baseServer === bases.baseServer);
|
|
35
|
-
(0, utils_js_1.assert)(basesResolved.baseAssets === bases.baseAssets);
|
|
39
|
+
const basesResolved2 = (0, resolveBase_js_1.resolveBaseFromResolvedConfig)(vikeConfig.vikeConfigGlobal.baseServer, vikeConfig.vikeConfigGlobal.baseAssets, config);
|
|
40
|
+
(0, utils_js_1.assert)(basesResolved2.baseServer === basesResolved.baseServer);
|
|
41
|
+
(0, utils_js_1.assert)(basesResolved2.baseAssets === basesResolved.baseAssets);
|
|
36
42
|
/* In dev, Vite seems buggy around setting vite.config.js#base to an absolute URL (e.g. http://localhost:8080/cdn/)
|
|
37
43
|
* - In dev, Vite removes the URL origin. (I.e. it resolves the user config `vite.config.js#base: 'http://localhost:8080/cdn/'` to resolved config `config.base === '/cdn/'`.)
|
|
38
44
|
* - Instead of having an internal Vike assertion fail, we let the user discover Vite's buggy behavior.
|
|
@@ -41,7 +47,3 @@ function baseUrls(vikeVitePluginOptions) {
|
|
|
41
47
|
}
|
|
42
48
|
};
|
|
43
49
|
}
|
|
44
|
-
function resolveBaseFromUserConfig(config, vikeVitePluginOptions) {
|
|
45
|
-
const baseViteOriginal = config.base ?? null;
|
|
46
|
-
return (0, resolveBase_js_1.resolveBase)(baseViteOriginal, vikeVitePluginOptions?.baseServer ?? null, vikeVitePluginOptions?.baseAssets ?? null);
|
|
47
|
-
}
|
|
@@ -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 { setBuildEntry } 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
|
+
' setBuildEntry({',
|
|
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);
|
|
@@ -11,14 +11,14 @@ const require_shim_1 = require("@brillout/require-shim");
|
|
|
11
11
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const assertResolveAlias_js_1 = require("./commonConfig/assertResolveAlias.js");
|
|
14
|
-
const pluginName_js_1 = require("./commonConfig/pluginName.js");
|
|
15
14
|
const getEnvVarObject_js_1 = require("../shared/getEnvVarObject.js");
|
|
16
15
|
const isViteCliCall_js_1 = require("../shared/isViteCliCall.js");
|
|
17
16
|
const context_js_1 = require("../../api/context.js");
|
|
18
|
-
|
|
17
|
+
const pluginName = 'vike:commonConfig';
|
|
18
|
+
function commonConfig(vikeVitePluginOptions) {
|
|
19
19
|
return [
|
|
20
20
|
{
|
|
21
|
-
name: `${
|
|
21
|
+
name: `${pluginName}:pre`,
|
|
22
22
|
enforce: 'pre',
|
|
23
23
|
config: {
|
|
24
24
|
order: 'pre',
|
|
@@ -31,14 +31,14 @@ function commonConfig(vikeVitePluginOptions = {}) {
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
name:
|
|
34
|
+
name: pluginName,
|
|
35
35
|
configResolved(config) {
|
|
36
36
|
assertSingleInstance(config);
|
|
37
37
|
(0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name: `${
|
|
41
|
+
name: `${pluginName}:post`,
|
|
42
42
|
enforce: 'post',
|
|
43
43
|
configResolved: {
|
|
44
44
|
order: 'post',
|
|
@@ -111,7 +111,7 @@ function assertEsm(userViteRoot) {
|
|
|
111
111
|
(0, utils_js_1.assertWarning)(packageJson.type === 'module', `We recommend setting ${dir}package.json#type to "module", see https://vike.dev/CJS`, { onlyOnce: true });
|
|
112
112
|
}
|
|
113
113
|
function assertSingleInstance(config) {
|
|
114
|
-
const numberOfInstances = config.plugins.filter((o) => o.name ===
|
|
114
|
+
const numberOfInstances = config.plugins.filter((o) => o.name === pluginName).length;
|
|
115
115
|
(0, utils_js_1.assertUsage)(numberOfInstances === 1, `Vike's Vite plugin (${picocolors_1.default.cyan("import vike from 'vike/plugin'")}) is being added ${numberOfInstances} times to the list of Vite plugins. Make sure to add it only once instead.`);
|
|
116
116
|
}
|
|
117
117
|
function assertVikeCliOrApi(config) {
|
|
@@ -145,9 +145,7 @@ const configDefinitionsBuiltInGlobal = {
|
|
|
145
145
|
env: { server: true, client: 'if-client-routing' },
|
|
146
146
|
eager: true
|
|
147
147
|
},
|
|
148
|
-
prerender: {
|
|
149
|
-
env: { config: true }
|
|
150
|
-
},
|
|
148
|
+
prerender: { env: { config: true } },
|
|
151
149
|
disableAutoFullBuild: { env: { config: true } },
|
|
152
150
|
includeAssetsImportedByServer: { env: { config: true } },
|
|
153
151
|
baseAssets: { env: { config: true } },
|