vike 0.4.172 → 0.4.174
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/plugin/index.js +3 -0
- package/dist/cjs/node/plugin/plugins/commonConfig.js +4 -8
- package/dist/cjs/node/plugin/plugins/config/index.js +9 -5
- package/dist/cjs/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +135 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +22 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +19 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +22 -42
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/cjs/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/cjs/node/plugin/resolveClientEntriesDev.js +59 -0
- package/dist/cjs/node/plugin/shared/addSsrMiddleware.js +7 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/shared/loggerVite.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/cjs/node/runtime/onLoad.js +4 -0
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/cjs/node/runtime/renderPage.js +7 -4
- package/dist/cjs/node/{plugin/shared → shared}/isErrorDebug.js +1 -1
- package/dist/cjs/node/shared/utils.js +1 -0
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/utils/assert.js +9 -3
- package/dist/cjs/utils/findFile.js +5 -3
- package/dist/cjs/utils/findPackageJson.js +19 -0
- package/dist/cjs/utils/joinEnglish.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/isClientSideRoutable.js +2 -2
- package/dist/esm/node/plugin/index.js +3 -0
- package/dist/esm/node/plugin/plugins/commonConfig.js +5 -9
- package/dist/esm/node/plugin/plugins/config/index.js +9 -5
- package/dist/esm/node/plugin/plugins/devConfig/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/assertExtensions.js +129 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +23 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +20 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +14 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -41
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +1 -1
- package/dist/esm/node/plugin/plugins/previewConfig.js +2 -2
- package/dist/esm/node/plugin/resolveClientEntriesDev.d.ts +4 -0
- package/dist/esm/node/plugin/resolveClientEntriesDev.js +56 -0
- package/dist/esm/node/plugin/shared/addSsrMiddleware.d.ts +2 -2
- package/dist/esm/node/plugin/shared/addSsrMiddleware.js +7 -1
- package/dist/esm/node/plugin/shared/loggerNotProd/log.js +1 -1
- package/dist/esm/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/esm/node/plugin/shared/loggerVite.js +1 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -1
- package/dist/esm/node/runtime/onLoad.js +4 -0
- package/dist/esm/node/runtime/renderPage/analyzePage.js +4 -4
- package/dist/esm/node/runtime/renderPage/getPageAssets.d.ts +3 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +9 -59
- package/dist/esm/node/runtime/renderPage.js +7 -4
- package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.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/shared/ConfigVike.d.ts +7 -0
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +5 -2
- package/dist/esm/shared/page-configs/Config.d.ts +13 -1
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/utils/assert.d.ts +2 -0
- package/dist/esm/utils/assert.js +8 -2
- package/dist/esm/utils/findFile.js +5 -3
- package/dist/esm/utils/findPackageJson.d.ts +5 -0
- package/dist/esm/utils/findPackageJson.js +16 -0
- package/dist/esm/utils/joinEnglish.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +5 -4
- /package/dist/esm/node/{plugin/shared → shared}/isErrorDebug.d.ts +0 -0
|
@@ -32,7 +32,7 @@ __exportStar(require("../../utils/escapeRegex.js"), exports);
|
|
|
32
32
|
__exportStar(require("../../utils/stripAnsi.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/trimWithAnsi.js"), exports);
|
|
34
34
|
__exportStar(require("../../utils/removeEmptyLines.js"), exports);
|
|
35
|
-
__exportStar(require("../../utils/
|
|
35
|
+
__exportStar(require("../../utils/findPackageJson.js"), exports);
|
|
36
36
|
__exportStar(require("../../utils/getPropAccessNotation.js"), exports);
|
|
37
37
|
__exportStar(require("../../utils/deepEqual.js"), exports);
|
|
38
38
|
__exportStar(require("../../utils/assertKeys.js"), exports);
|
|
@@ -35,7 +35,7 @@ function serializePageContextClientSide(pageContext) {
|
|
|
35
35
|
pageContextClient[prop] = pageContext[prop];
|
|
36
36
|
});
|
|
37
37
|
if (Object.keys(pageContext._pageContextInit).some((p) => passToClient.includes(p))) {
|
|
38
|
-
pageContextClient.
|
|
38
|
+
pageContextClient[pageContextInitIsPassedToClient_js_1.pageContextInitIsPassedToClient] = true;
|
|
39
39
|
}
|
|
40
40
|
let pageContextSerialized;
|
|
41
41
|
try {
|
|
@@ -4,9 +4,13 @@ exports.onLoad = void 0;
|
|
|
4
4
|
const assertIsNotBrowser_js_1 = require("../../utils/assertIsNotBrowser.js");
|
|
5
5
|
const assertNodeVersion_js_1 = require("../../utils/assertNodeVersion.js");
|
|
6
6
|
const require_shim_1 = require("@brillout/require-shim");
|
|
7
|
+
const utils_js_1 = require("./utils.js");
|
|
8
|
+
const isErrorDebug_js_1 = require("../shared/isErrorDebug.js");
|
|
7
9
|
function onLoad() {
|
|
8
10
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
9
11
|
(0, assertNodeVersion_js_1.assertNodeVersion)();
|
|
10
12
|
(0, require_shim_1.installRequireShim)();
|
|
13
|
+
if ((0, isErrorDebug_js_1.isErrorDebug)())
|
|
14
|
+
(0, utils_js_1.setAlwaysShowStackTrace)();
|
|
11
15
|
}
|
|
12
16
|
exports.onLoad = onLoad;
|
|
@@ -9,17 +9,17 @@ const globalContext_js_1 = require("../globalContext.js");
|
|
|
9
9
|
const getConfigValue_js_1 = require("../../../shared/page-configs/getConfigValue.js");
|
|
10
10
|
function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
11
11
|
if (pageConfig) {
|
|
12
|
-
const {
|
|
12
|
+
const { clientEntryLoaded, isClientRouting } = (0, analyzeClientSide_js_1.analyzeClientSide)(pageConfig, pageFilesAll, pageId);
|
|
13
13
|
const clientEntries = [];
|
|
14
14
|
const clientFilePath = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'client', 'string')?.value ?? null;
|
|
15
15
|
if (clientFilePath)
|
|
16
16
|
clientEntries.push(clientFilePath);
|
|
17
|
-
if (
|
|
17
|
+
if (clientEntryLoaded)
|
|
18
18
|
clientEntries.push((0, determineClientEntry_js_1.getVikeClientEntry)(isClientRouting));
|
|
19
19
|
const clientDependencies = [];
|
|
20
20
|
clientDependencies.push({
|
|
21
21
|
id: (0, virtualFilePageConfigValuesAll_js_1.getVirtualFileIdPageConfigValuesAll)(pageConfig.pageId, true),
|
|
22
|
-
onlyAssets:
|
|
22
|
+
onlyAssets: clientEntryLoaded ? false : true,
|
|
23
23
|
eagerlyImported: false
|
|
24
24
|
});
|
|
25
25
|
// In production we inject the import of the server virtual module with ?extractAssets inside the client virtual module
|
|
@@ -55,7 +55,7 @@ function analyzePage(pageFilesAll, pageConfig, pageId) {
|
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
return {
|
|
58
|
-
isHtmlOnly: !
|
|
58
|
+
isHtmlOnly: !clientEntryLoaded,
|
|
59
59
|
isClientRouting,
|
|
60
60
|
clientEntries,
|
|
61
61
|
clientDependencies,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPageAssets = void 0;
|
|
3
|
+
exports.setResolveClientEntriesDev = exports.getPageAssets = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
const retrieveAssetsDev_js_1 = require("./getPageAssets/retrieveAssetsDev.js");
|
|
6
6
|
const retrieveAssetsProd_js_1 = require("./getPageAssets/retrieveAssetsProd.js");
|
|
@@ -8,7 +8,9 @@ const inferMediaType_js_1 = require("./inferMediaType.js");
|
|
|
8
8
|
const getManifestEntry_js_1 = require("./getPageAssets/getManifestEntry.js");
|
|
9
9
|
const sortPageAssetsForEarlyHintsHeader_js_1 = require("./getPageAssets/sortPageAssetsForEarlyHintsHeader.js");
|
|
10
10
|
const globalContext_js_1 = require("../globalContext.js");
|
|
11
|
-
const
|
|
11
|
+
const globalObject = (0, utils_js_1.getGlobalObject)('getPageAssets.ts', {
|
|
12
|
+
resolveClientEntriesDev: null
|
|
13
|
+
});
|
|
12
14
|
async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
13
15
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
14
16
|
const isDev = !globalContext.isProduction;
|
|
@@ -16,7 +18,7 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
16
18
|
let clientEntriesSrc;
|
|
17
19
|
if (isDev) {
|
|
18
20
|
const { viteDevServer } = globalContext;
|
|
19
|
-
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => resolveClientEntriesDev(clientEntry, viteDevServer)));
|
|
21
|
+
clientEntriesSrc = await Promise.all(clientEntries.map((clientEntry) => globalObject.resolveClientEntriesDev(clientEntry, viteDevServer)));
|
|
20
22
|
assetUrls = await (0, retrieveAssetsDev_js_1.retrieveAssetsDev)(clientDependencies, viteDevServer);
|
|
21
23
|
}
|
|
22
24
|
else {
|
|
@@ -57,62 +59,6 @@ async function getPageAssets(pageContext, clientDependencies, clientEntries) {
|
|
|
57
59
|
return pageAssets;
|
|
58
60
|
}
|
|
59
61
|
exports.getPageAssets = getPageAssets;
|
|
60
|
-
async function resolveClientEntriesDev(clientEntry, viteDevServer) {
|
|
61
|
-
let root = viteDevServer.config.root;
|
|
62
|
-
(0, utils_js_1.assert)(root);
|
|
63
|
-
root = (0, utils_js_1.toPosixPath)(root);
|
|
64
|
-
// The `?import` suffix is needed for MDX to be transpiled:
|
|
65
|
-
// - Not transpiled: `/pages/markdown.page.mdx`
|
|
66
|
-
// - Transpiled: `/pages/markdown.page.mdx?import`
|
|
67
|
-
// But `?import` doesn't work with `/@fs/`:
|
|
68
|
-
// - Not transpiled: /@fs/home/runner/work/vike/vike/examples/react-full/pages/markdown.page.mdx
|
|
69
|
-
// - Not transpiled: /@fs/home/runner/work/vike/vike/examples/react-full/pages/markdown.page.mdx?import
|
|
70
|
-
if (clientEntry.endsWith('?import')) {
|
|
71
|
-
(0, utils_js_1.assert)(clientEntry.startsWith('/'));
|
|
72
|
-
return clientEntry;
|
|
73
|
-
}
|
|
74
|
-
(0, utils_js_1.assertPosixPath)(clientEntry);
|
|
75
|
-
let filePath;
|
|
76
|
-
if (clientEntry.startsWith('/')) {
|
|
77
|
-
filePath = (0, utils_js_1.pathJoin)(root, clientEntry);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
const { createRequire } = (await (0, import_1.import_)('module')).default;
|
|
81
|
-
const { dirname } = (await (0, import_1.import_)('path')).default;
|
|
82
|
-
const { fileURLToPath } = (await (0, import_1.import_)('url')).default;
|
|
83
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
84
|
-
const importMetaUrl = `file://${__filename}`;
|
|
85
|
-
const require_ = createRequire(importMetaUrl);
|
|
86
|
-
const __dirname_ = dirname(fileURLToPath(importMetaUrl));
|
|
87
|
-
// @ts-expect-error
|
|
88
|
-
// Bun workaround https://github.com/vikejs/vike/pull/1048
|
|
89
|
-
const res = typeof Bun !== 'undefined' ? (toPath) => Bun.resolveSync(toPath, __dirname_) : require_.resolve;
|
|
90
|
-
if (clientEntry.startsWith('@@vike/')) {
|
|
91
|
-
(0, utils_js_1.assert)(clientEntry.endsWith('.js'));
|
|
92
|
-
try {
|
|
93
|
-
// For Vitest (which doesn't resolve vike to its dist but to its source files)
|
|
94
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/node/runtime/renderPage/getPageAssets.js
|
|
95
|
-
filePath = (0, utils_js_1.toPosixPath)(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../client/').replace('.js', '.ts')));
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
98
|
-
// For users
|
|
99
|
-
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/runtime/renderPage/getPageAssets.js
|
|
100
|
-
filePath = (0, utils_js_1.toPosixPath)(res(clientEntry.replace('@@vike/dist/esm/client/', '../../../../../dist/esm/client/')));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
(0, utils_js_1.assertIsNpmPackageImport)(clientEntry);
|
|
105
|
-
filePath = res(clientEntry);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (!filePath.startsWith('/')) {
|
|
109
|
-
(0, utils_js_1.assert)(process.platform === 'win32');
|
|
110
|
-
filePath = '/' + filePath;
|
|
111
|
-
}
|
|
112
|
-
filePath = '/@fs' + filePath;
|
|
113
|
-
(0, utils_js_1.assertPosixPath)(filePath);
|
|
114
|
-
return filePath;
|
|
115
|
-
}
|
|
116
62
|
function resolveClientEntriesProd(clientEntry, assetsManifest) {
|
|
117
63
|
const { manifestEntry } = (0, getManifestEntry_js_1.getManifestEntry)(clientEntry, assetsManifest);
|
|
118
64
|
(0, utils_js_1.assert)(manifestEntry.isEntry || manifestEntry.isDynamicEntry || clientEntry.endsWith('.css'), { clientEntry });
|
|
@@ -120,3 +66,7 @@ function resolveClientEntriesProd(clientEntry, assetsManifest) {
|
|
|
120
66
|
(0, utils_js_1.assert)(!file.startsWith('/'));
|
|
121
67
|
return '/' + file;
|
|
122
68
|
}
|
|
69
|
+
function setResolveClientEntriesDev(resolveClientEntriesDev) {
|
|
70
|
+
globalObject.resolveClientEntriesDev = resolveClientEntriesDev;
|
|
71
|
+
}
|
|
72
|
+
exports.setResolveClientEntriesDev = setResolveClientEntriesDev;
|
|
@@ -205,7 +205,7 @@ function logHttpRequest(urlOriginal, httpRequestId) {
|
|
|
205
205
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(getRequestInfoMessage(urlOriginal), httpRequestId, 'info', clearErrors);
|
|
206
206
|
}
|
|
207
207
|
function getRequestInfoMessage(urlOriginal) {
|
|
208
|
-
return `HTTP request: ${
|
|
208
|
+
return `HTTP request: ${prettyUrl(urlOriginal)}`;
|
|
209
209
|
}
|
|
210
210
|
function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
211
211
|
const statusCode = pageContextReturn.httpResponse?.statusCode ?? null;
|
|
@@ -221,7 +221,7 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
221
221
|
// - We should show `HTTP response ${urlOriginal} ERR` instead.
|
|
222
222
|
// - Maybe we can/should make the error available at pageContext.errorWhileRendering
|
|
223
223
|
(0, utils_js_1.assert)(errorWhileRendering === null || errorWhileRendering === undefined);
|
|
224
|
-
msg = `HTTP response ${
|
|
224
|
+
msg = `HTTP response ${prettyUrl(urlOriginal)} ${picocolors_1.default.dim('null')}`;
|
|
225
225
|
// Erroneous value (it shoud sometimes be `false`) but it's fine as it doesn't seem to have much of an impact.
|
|
226
226
|
isNominal = true;
|
|
227
227
|
}
|
|
@@ -241,7 +241,7 @@ function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
|
241
241
|
const urlRedirect = headerRedirect[1];
|
|
242
242
|
urlOriginal = urlRedirect;
|
|
243
243
|
}
|
|
244
|
-
msg = `HTTP ${type} ${
|
|
244
|
+
msg = `HTTP ${type} ${prettyUrl(urlOriginal)} ${color(statusCode ?? 'ERR')}`;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
(0, loggerRuntime_js_1.logRuntimeInfo)?.(msg, httpRequestId, isNominal ? 'info' : 'error');
|
|
@@ -449,9 +449,12 @@ function checkBaseUrl(pageContextInit, httpRequestId) {
|
|
|
449
449
|
const { urlWithoutPageContextRequestSuffix } = (0, handlePageContextRequestUrl_js_1.handlePageContextRequestUrl)(urlOriginal);
|
|
450
450
|
const { hasBaseServer } = (0, utils_js_1.parseUrl)(urlWithoutPageContextRequestSuffix, baseServer);
|
|
451
451
|
if (!hasBaseServer) {
|
|
452
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`${getRequestInfoMessage(urlOriginal)} skipped because URL ${
|
|
452
|
+
(0, loggerRuntime_js_1.logRuntimeInfo)?.(`${getRequestInfoMessage(urlOriginal)} skipped because URL ${prettyUrl(urlOriginal)} doesn't start with Base URL ${prettyUrl(baseServer)} (https://vike.dev/base-url)`, httpRequestId, 'info');
|
|
453
453
|
const pageContextHttpResponseNull = getPageContextHttpResponseNull(pageContextInit);
|
|
454
454
|
return pageContextHttpResponseNull;
|
|
455
455
|
}
|
|
456
456
|
return null;
|
|
457
457
|
}
|
|
458
|
+
function prettyUrl(url) {
|
|
459
|
+
return picocolors_1.default.bold(decodeURI(url));
|
|
460
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isErrorDebug = void 0;
|
|
4
|
-
const utils_js_1 = require("
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
5
5
|
function isErrorDebug() {
|
|
6
6
|
return (0, utils_js_1.isDebugActivated)('vike:error');
|
|
7
7
|
}
|
|
@@ -32,3 +32,4 @@ __exportStar(require("../../utils/virtual-files.js"), exports);
|
|
|
32
32
|
__exportStar(require("../../utils/assertIsNotBrowser.js"), exports);
|
|
33
33
|
__exportStar(require("../../utils/isNotNullish.js"), exports);
|
|
34
34
|
__exportStar(require("../../utils/unique.js"), exports);
|
|
35
|
+
__exportStar(require("../../utils/debug.js"), exports);
|
|
@@ -7,14 +7,14 @@ function analyzeClientSide(pageConfig, pageFilesAll, pageId) {
|
|
|
7
7
|
// V1 design
|
|
8
8
|
if (pageConfig) {
|
|
9
9
|
const isClientRouting = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
10
|
-
const
|
|
11
|
-
return {
|
|
10
|
+
const clientEntryLoaded = (0, getConfigValue_js_1.getConfigValueRuntime)(pageConfig, 'clientEntryLoaded', 'boolean')?.value ?? false;
|
|
11
|
+
return { clientEntryLoaded, isClientRouting };
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
14
|
// TODO/v1-release: remove
|
|
15
15
|
// V0.4 design
|
|
16
16
|
const { isHtmlOnly, isClientRouting } = (0, analyzePageClientSide_js_1.analyzePageClientSide)(pageFilesAll, pageId);
|
|
17
|
-
return {
|
|
17
|
+
return { clientEntryLoaded: !isHtmlOnly, isClientRouting };
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.analyzeClientSide = analyzeClientSide;
|
package/dist/cjs/utils/assert.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.isBug = exports.overwriteAssertProductionLogger = exports.getAssertErrMsg = exports.addOnBeforeLogHook = exports.getProjectError = exports.assertInfo = exports.assertWarning = exports.assertUsage = exports.assert = void 0;
|
|
6
|
+
exports.setAlwaysShowStackTrace = exports.isBug = exports.overwriteAssertProductionLogger = exports.getAssertErrMsg = exports.addOnBeforeLogHook = exports.getProjectError = exports.assertInfo = exports.assertWarning = exports.assertUsage = exports.assert = void 0;
|
|
7
7
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
8
8
|
const createErrorWithCleanStackTrace_js_1 = require("./createErrorWithCleanStackTrace.js");
|
|
9
9
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
@@ -37,9 +37,9 @@ function assert(condition, debugInfo) {
|
|
|
37
37
|
const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : JSON.stringify(debugInfo);
|
|
38
38
|
return picocolors_1.default.dim(`Debug info (for Vike maintainers; you can ignore this): ${debugInfoSerialized}`);
|
|
39
39
|
})();
|
|
40
|
+
const link = picocolors_1.default.blue('https://github.com/vikejs/vike/issues/new');
|
|
40
41
|
let errMsg = [
|
|
41
|
-
`You stumbled upon a Vike bug.`,
|
|
42
|
-
`Go to ${picocolors_1.default.blue('https://github.com/vikejs/vike/issues/new')} and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).`,
|
|
42
|
+
`You stumbled upon a Vike bug. Go to ${link} and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).`,
|
|
43
43
|
debugStr
|
|
44
44
|
]
|
|
45
45
|
.filter(Boolean)
|
|
@@ -55,6 +55,7 @@ exports.assert = assert;
|
|
|
55
55
|
function assertUsage(condition, errMsg, { showStackTrace } = {}) {
|
|
56
56
|
if (condition)
|
|
57
57
|
return;
|
|
58
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
58
59
|
errMsg = addWhitespace(errMsg);
|
|
59
60
|
errMsg = addPrefixAssertType(errMsg, 'Wrong Usage');
|
|
60
61
|
errMsg = addPrefixProjctName(errMsg);
|
|
@@ -77,6 +78,7 @@ exports.getProjectError = getProjectError;
|
|
|
77
78
|
function assertWarning(condition, msg, { onlyOnce, showStackTrace }) {
|
|
78
79
|
if (condition)
|
|
79
80
|
return;
|
|
81
|
+
showStackTrace = showStackTrace || globalObject.alwaysShowStackTrace;
|
|
80
82
|
msg = addWhitespace(msg);
|
|
81
83
|
msg = addPrefixAssertType(msg, 'Warning');
|
|
82
84
|
msg = addPrefixProjctName(msg);
|
|
@@ -193,3 +195,7 @@ function isBug(err) {
|
|
|
193
195
|
return !String(err).includes('[Bug]');
|
|
194
196
|
}
|
|
195
197
|
exports.isBug = isBug;
|
|
198
|
+
function setAlwaysShowStackTrace() {
|
|
199
|
+
globalObject.alwaysShowStackTrace = true;
|
|
200
|
+
}
|
|
201
|
+
exports.setAlwaysShowStackTrace = setAlwaysShowStackTrace;
|
|
@@ -7,19 +7,21 @@ exports.findFile = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const isArray_js_1 = require("./isArray.js");
|
|
10
|
+
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
10
11
|
function findFile(arg, cwd) {
|
|
12
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(cwd);
|
|
11
13
|
const filenames = (0, isArray_js_1.isArray)(arg) ? arg : [arg];
|
|
12
14
|
let dir = cwd;
|
|
13
15
|
while (true) {
|
|
14
16
|
for (const filename of filenames) {
|
|
15
|
-
const configFilePath = path_1.default.join(dir, `./${filename}`);
|
|
17
|
+
const configFilePath = path_1.default.posix.join(dir, `./${filename}`);
|
|
16
18
|
if (fs_1.default.existsSync(configFilePath)) {
|
|
17
|
-
|
|
19
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(configFilePath);
|
|
18
20
|
return configFilePath;
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
const dirPrevious = dir;
|
|
22
|
-
dir = path_1.default.dirname(dir);
|
|
24
|
+
dir = path_1.default.posix.dirname(dir);
|
|
23
25
|
if (dir === dirPrevious) {
|
|
24
26
|
return null;
|
|
25
27
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findPackageJson = void 0;
|
|
4
|
+
const findFile_js_1 = require("./findFile.js");
|
|
5
|
+
const module_1 = require("module");
|
|
6
|
+
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
7
|
+
const importMetaUrl = `file://${__filename}`;
|
|
8
|
+
const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
9
|
+
function findPackageJson(cwd) {
|
|
10
|
+
const packageJsonPath = (0, findFile_js_1.findFile)('package.json', cwd);
|
|
11
|
+
if (!packageJsonPath)
|
|
12
|
+
return null;
|
|
13
|
+
const packageJson = require_(packageJsonPath);
|
|
14
|
+
return {
|
|
15
|
+
packageJson,
|
|
16
|
+
packageJsonPath
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.findPackageJson = findPackageJson;
|
|
@@ -9,6 +9,6 @@ function joinEnglish(arr, conjunction, colorizer = (s) => s) {
|
|
|
9
9
|
return colorizer(arr[0]);
|
|
10
10
|
const firsts = arr.slice(0, arr.length - 1);
|
|
11
11
|
const last = arr[arr.length - 1];
|
|
12
|
-
return firsts.map(colorizer).join(', ') +
|
|
12
|
+
return firsts.map(colorizer).join(', ') + `, ${conjunction} ` + colorizer(last);
|
|
13
13
|
}
|
|
14
14
|
exports.joinEnglish = joinEnglish;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const PROJECT_VERSION = '0.4.
|
|
4
|
+
const PROJECT_VERSION = '0.4.174';
|
|
5
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
@@ -7,6 +7,6 @@ async function isClientSideRoutable(pageId, pageContext) {
|
|
|
7
7
|
sharedPageFilesAlreadyLoaded: false
|
|
8
8
|
});
|
|
9
9
|
const pageConfig = findPageConfig(pageContext._pageConfigs, pageId);
|
|
10
|
-
const {
|
|
11
|
-
return
|
|
10
|
+
const { clientEntryLoaded, isClientRouting } = analyzeClientSide(pageConfig, pageContext._pageFilesAll, pageId);
|
|
11
|
+
return clientEntryLoaded && isClientRouting;
|
|
12
12
|
}
|
|
@@ -24,9 +24,12 @@ import { baseUrls } from './plugins/baseUrls.js';
|
|
|
24
24
|
import { envVarsPlugin } from './plugins/envVars.js';
|
|
25
25
|
import pc from '@brillout/picocolors';
|
|
26
26
|
import { fileEnv } from './plugins/fileEnv.js';
|
|
27
|
+
import { setResolveClientEntriesDev } from '../runtime/renderPage/getPageAssets.js';
|
|
28
|
+
import { resolveClientEntriesDev } from './resolveClientEntriesDev.js';
|
|
27
29
|
assertNodeEnv_onVikePluginLoad();
|
|
28
30
|
markEnvAsVikePluginLoaded();
|
|
29
31
|
assertViteVersion();
|
|
32
|
+
setResolveClientEntriesDev(resolveClientEntriesDev);
|
|
30
33
|
// Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
|
|
31
34
|
function plugin(vikeConfig) {
|
|
32
35
|
const plugins = [
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
export { commonConfig };
|
|
2
|
-
import { assert, assertUsage, assertWarning,
|
|
2
|
+
import { assert, assertUsage, assertWarning, findPackageJson } from '../utils.js';
|
|
3
3
|
import { assertRollupInput } from './buildConfig.js';
|
|
4
4
|
import { installRequireShim_setUserRootDir } from '@brillout/require-shim';
|
|
5
5
|
import pc from '@brillout/picocolors';
|
|
6
6
|
import path from 'path';
|
|
7
|
-
import { createRequire } from 'module';
|
|
8
7
|
import { assertResolveAlias } from './commonConfig/assertResolveAlias.js';
|
|
9
|
-
// @ts-ignore Shimmed by dist-cjs-fixup.js for CJS build.
|
|
10
|
-
const importMetaUrl = import.meta.url;
|
|
11
|
-
const require_ = createRequire(importMetaUrl);
|
|
12
8
|
const pluginName = 'vike:commonConfig-1';
|
|
13
9
|
function commonConfig() {
|
|
14
10
|
return [
|
|
@@ -64,11 +60,11 @@ function workaroundCI(config) {
|
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
62
|
function assertEsm(userViteRoot) {
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
63
|
+
const found = findPackageJson(userViteRoot);
|
|
64
|
+
if (!found)
|
|
69
65
|
return;
|
|
70
|
-
const packageJson =
|
|
71
|
-
let dir = path.dirname(packageJsonPath);
|
|
66
|
+
const { packageJson, packageJsonPath } = found;
|
|
67
|
+
let dir = path.posix.dirname(packageJsonPath);
|
|
72
68
|
if (dir !== '/') {
|
|
73
69
|
assert(!dir.endsWith('/'));
|
|
74
70
|
dir = dir + '/';
|
|
@@ -20,15 +20,16 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
20
20
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
21
21
|
const fromViteConfig = (config.vike ?? {});
|
|
22
22
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
23
|
-
|
|
23
|
+
assertVikeConfig(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
24
|
+
// TODO/v1-release: deprecate this
|
|
25
|
+
assertVikeConfig(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
26
|
+
const crawlWithGit = fromPluginOptions.crawl?.git ?? null;
|
|
27
|
+
const { globalVikeConfig: fromPlusConfigFile } = await getVikeConfig(config, isDev2(config), { crawlWithGit });
|
|
24
28
|
configs.push(fromPlusConfigFile);
|
|
25
29
|
assertVikeConfig(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
26
30
|
// TODO: add config file path ?
|
|
27
31
|
return `config ${pc.cyan(prop)} ${errMsg}`;
|
|
28
32
|
});
|
|
29
|
-
assertVikeConfig(fromViteConfig, ({ prop, errMsg }) => `vite.config.js#vike.${prop} ${errMsg}`);
|
|
30
|
-
// TODO/v1-release: deprecate this
|
|
31
|
-
assertVikeConfig(fromPluginOptions, ({ prop, errMsg }) => `vite.config.js > vike option ${prop} ${errMsg}`);
|
|
32
33
|
const { baseServer, baseAssets } = resolveBase(configs, config);
|
|
33
34
|
const configVike = {
|
|
34
35
|
disableAutoFullBuild: pickFirst(configs.map((c) => c.disableAutoFullBuild)) ?? null,
|
|
@@ -38,7 +39,10 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
38
39
|
baseAssets,
|
|
39
40
|
redirects: merge(configs.map((c) => c.redirects)) ?? {},
|
|
40
41
|
disableUrlNormalization: pickFirst(configs.map((c) => c.disableUrlNormalization)) ?? false,
|
|
41
|
-
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false
|
|
42
|
+
trailingSlash: pickFirst(configs.map((c) => c.trailingSlash)) ?? false,
|
|
43
|
+
crawl: {
|
|
44
|
+
git: crawlWithGit
|
|
45
|
+
}
|
|
42
46
|
};
|
|
43
47
|
return configVike;
|
|
44
48
|
}
|
|
@@ -4,7 +4,7 @@ import { determineFsAllowList } from './determineFsAllowList.js';
|
|
|
4
4
|
import { addSsrMiddleware } from '../../shared/addSsrMiddleware.js';
|
|
5
5
|
import { markEnvAsViteDev } from '../../utils.js';
|
|
6
6
|
import { improveViteLogs } from '../../shared/loggerVite.js';
|
|
7
|
-
import { isErrorDebug } from '
|
|
7
|
+
import { isErrorDebug } from '../../../shared/isErrorDebug.js';
|
|
8
8
|
import { installHttpRequestAsyncStore } from '../../shared/getHttpRequestAsyncStore.js';
|
|
9
9
|
if (isErrorDebug()) {
|
|
10
10
|
Error.stackTraceLimit = Infinity;
|
|
@@ -77,7 +77,7 @@ function devConfig() {
|
|
|
77
77
|
if (config.server.middlewareMode || hasHonoViteDevServer)
|
|
78
78
|
return;
|
|
79
79
|
return () => {
|
|
80
|
-
addSsrMiddleware(server.middlewares);
|
|
80
|
+
addSsrMiddleware(server.middlewares, config, false);
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
},
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { assertExtensionsConventions };
|
|
2
|
+
export { assertExtensionsPeerDependencies };
|
|
3
|
+
import { type InterfaceFile } from './getVikeConfig.js';
|
|
4
|
+
declare function assertExtensionsConventions(interfaceFile: InterfaceFile): void;
|
|
5
|
+
declare function assertExtensionsPeerDependencies(interfaceFilesRelevantList: InterfaceFile[]): void;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export { assertExtensionsConventions };
|
|
2
|
+
export { assertExtensionsPeerDependencies };
|
|
3
|
+
import pc from '@brillout/picocolors';
|
|
4
|
+
import { isObjectOfStrings } from '../../../../../utils/isObjectOfStrings.js';
|
|
5
|
+
import { PROJECT_VERSION, assert, assertUsage, assertWarning, findPackageJson } from '../../../utils.js';
|
|
6
|
+
import { getConfigValueInterfaceFile } from './getVikeConfig.js';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import semver from 'semver';
|
|
9
|
+
function assertExtensionsConventions(interfaceFile) {
|
|
10
|
+
assertExtensionName(interfaceFile);
|
|
11
|
+
assertConfigExportPath(interfaceFile);
|
|
12
|
+
}
|
|
13
|
+
function assertConfigExportPath(interfaceFile) {
|
|
14
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
15
|
+
assert(importPathAbsolute);
|
|
16
|
+
const name = getConfigNameValue(interfaceFile);
|
|
17
|
+
assert(name); // already asserted in assertExtensionName()
|
|
18
|
+
const importPathAbsoluteExpected = `${name}/config`;
|
|
19
|
+
assertWarning(importPathAbsolute === importPathAbsoluteExpected, `The Vike configuration of ${pc.bold(name)} is exported at ${pc.bold(importPathAbsolute)}, but it should be exported at ${pc.bold(importPathAbsoluteExpected)} instead.`, { onlyOnce: true });
|
|
20
|
+
}
|
|
21
|
+
function assertExtensionName(interfaceFile) {
|
|
22
|
+
let nameDeduced;
|
|
23
|
+
{
|
|
24
|
+
const { importPathAbsolute } = interfaceFile.filePath;
|
|
25
|
+
assert(importPathAbsolute);
|
|
26
|
+
nameDeduced = importPathAbsolute
|
|
27
|
+
.split('/')
|
|
28
|
+
.slice(0, importPathAbsolute.startsWith('@') ? 2 : 1)
|
|
29
|
+
.join('/');
|
|
30
|
+
}
|
|
31
|
+
const name = getConfigNameValue(interfaceFile);
|
|
32
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
33
|
+
if (name) {
|
|
34
|
+
assertWarning(name === nameDeduced, `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} is ${pc.bold(name)}, but it should be ${pc.bold(nameDeduced)} instead (the name of the npm package).`, { onlyOnce: true });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (
|
|
38
|
+
// Let's eventually remove this
|
|
39
|
+
[
|
|
40
|
+
'vike-react',
|
|
41
|
+
'vike-react-query',
|
|
42
|
+
'vike-react-zustand',
|
|
43
|
+
'vike-vue',
|
|
44
|
+
'vike-vue-query',
|
|
45
|
+
'vike-vue-pinia',
|
|
46
|
+
'vike-pinia',
|
|
47
|
+
'vike-solid'
|
|
48
|
+
].includes(nameDeduced)) {
|
|
49
|
+
assertUsage(false, `Update ${nameDeduced} to its latest version.`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
assertUsage(false, `The setting ${pc.bold('name')} is missing: it should be set by the config ${filePathToShowToUser} of ${pc.bold(nameDeduced)}.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function assertExtensionsPeerDependencies(interfaceFilesRelevantList) {
|
|
57
|
+
// Get installed extensions
|
|
58
|
+
const extensions = {};
|
|
59
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
60
|
+
const name = getConfigNameValue(interfaceFile);
|
|
61
|
+
if (name) {
|
|
62
|
+
const version = getExtensionVersion(name, interfaceFile);
|
|
63
|
+
extensions[name] = version;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Enforce peer dependencies
|
|
67
|
+
interfaceFilesRelevantList.forEach((interfaceFile) => {
|
|
68
|
+
const require = getConfigRequireValue(interfaceFile);
|
|
69
|
+
if (!require)
|
|
70
|
+
return;
|
|
71
|
+
const name = getConfigNameValue(interfaceFile);
|
|
72
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
73
|
+
assertUsage(name, `Setting ${pc.bold('name')} is required for being able to use setting ${pc.bold('require')} in ${filePathToShowToUser}.`);
|
|
74
|
+
Object.entries(require).forEach(([reqName, reqVersion]) => {
|
|
75
|
+
const errBase = `${pc.bold(name)} requires ${pc.bold(reqName)}`;
|
|
76
|
+
if (reqName === 'vike') {
|
|
77
|
+
assertUsage(isVersionRange(PROJECT_VERSION, reqVersion), `${errBase} version ${pc.bold(reqVersion)}, but ${pc.bold(PROJECT_VERSION)} is installed.`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const extensionVersion = extensions[reqName];
|
|
81
|
+
assertUsage(extensionVersion, `${errBase}.`);
|
|
82
|
+
assertUsage(isVersionRange(extensionVersion, reqVersion), `${errBase} version ${pc.bold(reqVersion)}, but ${pc.bold(extensionVersion)} is installed.`);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function getConfigRequireValue(interfaceFile) {
|
|
87
|
+
const require = getConfigValueInterfaceFile(interfaceFile, 'require');
|
|
88
|
+
if (!require)
|
|
89
|
+
return null;
|
|
90
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
91
|
+
assert(filePathToShowToUserResolved);
|
|
92
|
+
assertUsage(isObjectOfStrings(require), `The setting ${pc.bold('require')} defined at ${filePathToShowToUserResolved} should be an object with string values (${pc.bold('Record<string, string>')}).`);
|
|
93
|
+
return require;
|
|
94
|
+
}
|
|
95
|
+
function getConfigNameValue(interfaceFile) {
|
|
96
|
+
const name = getConfigValueInterfaceFile(interfaceFile, 'name');
|
|
97
|
+
if (!name)
|
|
98
|
+
return null;
|
|
99
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
100
|
+
assertUsage(typeof name === 'string', `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} should be a string.`);
|
|
101
|
+
return name;
|
|
102
|
+
}
|
|
103
|
+
// We use a forever cache: users need to restart the dev server anyways when touching node_modules/**/* (I presume Vite doesn't pick up node_modules/**/* changes).
|
|
104
|
+
const extensionsVersion = {};
|
|
105
|
+
function getExtensionVersion(name, interfaceFile) {
|
|
106
|
+
if (!extensionsVersion[name]) {
|
|
107
|
+
const extensionConfigFilePath = interfaceFile.filePath.filePathAbsoluteFilesystem;
|
|
108
|
+
const found = findPackageJson(path.posix.dirname(extensionConfigFilePath));
|
|
109
|
+
assert(found);
|
|
110
|
+
const { packageJson, packageJsonPath } = found;
|
|
111
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceFile);
|
|
112
|
+
const nameExpected = packageJson.name;
|
|
113
|
+
assertWarning(name === nameExpected, `The setting ${pc.bold('name')} defined at ${filePathToShowToUser} is ${pc.bold(JSON.stringify(name))}, but it should be equal to ${pc.bold(JSON.stringify(nameExpected))} (the value of ${packageJsonPath}${pc.dim('#')}${pc.bold('name')})`, { onlyOnce: true });
|
|
114
|
+
const { version } = packageJson;
|
|
115
|
+
assert(typeof version === 'string');
|
|
116
|
+
extensionsVersion[name] = version;
|
|
117
|
+
}
|
|
118
|
+
return extensionsVersion[name];
|
|
119
|
+
}
|
|
120
|
+
function getFilePathToShowToUser(interfaceFile) {
|
|
121
|
+
const { filePathToShowToUserResolved } = interfaceFile.filePath;
|
|
122
|
+
assert(filePathToShowToUserResolved);
|
|
123
|
+
return filePathToShowToUserResolved;
|
|
124
|
+
}
|
|
125
|
+
function isVersionRange(version, range) {
|
|
126
|
+
// Remove pre-release tag
|
|
127
|
+
version = version.split('-')[0];
|
|
128
|
+
return semver.satisfies(version, range);
|
|
129
|
+
}
|
|
@@ -7,7 +7,7 @@ export type { ConfigNameGlobal };
|
|
|
7
7
|
export type { ConfigEffect };
|
|
8
8
|
import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources, DefinedAtFilePath } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
9
9
|
import type { Config, ConfigNameBuiltIn } from '../../../../../../shared/page-configs/Config.js';
|
|
10
|
-
import type
|
|
10
|
+
import { type ConfigDefinedAt } from '../../../../../../shared/page-configs/getConfigDefinedAt.js';
|
|
11
11
|
/** The meta definition of a config.
|
|
12
12
|
*
|
|
13
13
|
* https://vike.dev/meta
|