vike 0.4.181-commit-2f53249 → 0.4.181-commit-b6b5064
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/plugins/importUserCode/v1-design/getVikeConfig.js +27 -0
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +8 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +27 -0
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -255,6 +255,33 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
255
255
|
if (isGlobalConfig(configName))
|
|
256
256
|
return;
|
|
257
257
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
258
|
+
// TODO/soon: refactor
|
|
259
|
+
// - Dedupe: most of the code below is a copy-paste of the assertUsage() inside getGlobalConfigs()
|
|
260
|
+
// - update comment above `await Promise.all`
|
|
261
|
+
if (configDef.global) {
|
|
262
|
+
const locationIds = (0, utils_js_1.objectKeys)(interfaceFilesByLocationId);
|
|
263
|
+
if (!(0, filesystemRouting_js_1.isGlobalLocation)(interfaceFile.locationId, locationIds)) {
|
|
264
|
+
const interfaceFilesGlobal = (0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
265
|
+
return (0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds);
|
|
266
|
+
}));
|
|
267
|
+
const interfaceFilesGlobalPaths = [];
|
|
268
|
+
(0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
269
|
+
(0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
|
|
270
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
271
|
+
if (filePathAbsoluteUserRootDir) {
|
|
272
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path_1.default.posix.dirname(p))));
|
|
277
|
+
(0, utils_js_1.assertUsage)(false, [
|
|
278
|
+
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${picocolors_1.default.cyan(configName)} which is global:`,
|
|
279
|
+
globalPaths.length
|
|
280
|
+
? `define ${picocolors_1.default.cyan(configName)} in ${(0, utils_js_1.joinEnglish)(globalPaths, 'or')} instead`
|
|
281
|
+
: `create a global config (e.g. /pages/+config.js) and define ${picocolors_1.default.cyan(configName)} there instead`
|
|
282
|
+
].join(' '));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
258
285
|
if (!isLoadableAtBuildTime(configDef))
|
|
259
286
|
return;
|
|
260
287
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
@@ -31,6 +31,14 @@ type ConfigDefinition = {
|
|
|
31
31
|
* https://vike.dev/meta
|
|
32
32
|
*/
|
|
33
33
|
effect?: ConfigEffect;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the configuration always applies to all pages (no config inheritance).
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*
|
|
39
|
+
* https://vike.dev/extends#inheritance
|
|
40
|
+
*/
|
|
41
|
+
global?: boolean;
|
|
34
42
|
};
|
|
35
43
|
/**
|
|
36
44
|
* Function called when the config value is defined.
|
|
@@ -251,6 +251,33 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev, crawlWithGit) {
|
|
|
251
251
|
if (isGlobalConfig(configName))
|
|
252
252
|
return;
|
|
253
253
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
254
|
+
// TODO/soon: refactor
|
|
255
|
+
// - Dedupe: most of the code below is a copy-paste of the assertUsage() inside getGlobalConfigs()
|
|
256
|
+
// - update comment above `await Promise.all`
|
|
257
|
+
if (configDef.global) {
|
|
258
|
+
const locationIds = objectKeys(interfaceFilesByLocationId);
|
|
259
|
+
if (!isGlobalLocation(interfaceFile.locationId, locationIds)) {
|
|
260
|
+
const interfaceFilesGlobal = objectFromEntries(objectEntries(interfaceFilesByLocationId).filter(([locationId]) => {
|
|
261
|
+
return isGlobalLocation(locationId, locationIds);
|
|
262
|
+
}));
|
|
263
|
+
const interfaceFilesGlobalPaths = [];
|
|
264
|
+
objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
265
|
+
assert(isGlobalLocation(locationId, locationIds));
|
|
266
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
267
|
+
if (filePathAbsoluteUserRootDir) {
|
|
268
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
const globalPaths = Array.from(new Set(interfaceFilesGlobalPaths.map((p) => path.posix.dirname(p))));
|
|
273
|
+
assertUsage(false, [
|
|
274
|
+
`${interfaceFile.filePath.filePathToShowToUser} defines the config ${pc.cyan(configName)} which is global:`,
|
|
275
|
+
globalPaths.length
|
|
276
|
+
? `define ${pc.cyan(configName)} in ${joinEnglish(globalPaths, 'or')} instead`
|
|
277
|
+
: `create a global config (e.g. /pages/+config.js) and define ${pc.cyan(configName)} there instead`
|
|
278
|
+
].join(' '));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
254
281
|
if (!isLoadableAtBuildTime(configDef))
|
|
255
282
|
return;
|
|
256
283
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.181-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.181-commit-b6b5064";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.181-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.181-commit-b6b5064';
|