vike 0.4.221-commit-ab9e52a → 0.4.221-commit-937dbfb
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/crawlPlusFiles.js +27 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +0 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +4 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +11 -5
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +3 -3
- package/dist/cjs/shared/page-configs/getPageConfigUserFriendly.js +4 -2
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/esm/client/client-routing-runtime/prefetch.js +1 -1
- package/dist/esm/client/client-routing-runtime/renderPageClientSide.js +2 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
- package/dist/esm/client/server-routing-runtime/getPageContext.js +4 -3
- package/dist/esm/client/shared/loadUserFilesClientSide.d.ts +3 -2
- package/dist/esm/client/shared/loadUserFilesClientSide.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +28 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +0 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +4 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +12 -6
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +3 -3
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.d.ts +2 -2
- package/dist/esm/shared/page-configs/getPageConfigUserFriendly.js +4 -2
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/debug.js +1 -0
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -12,6 +12,7 @@ const util_1 = require("util");
|
|
|
12
12
|
const transpileAndExecuteFile_js_1 = require("./transpileAndExecuteFile.js");
|
|
13
13
|
const getEnvVarObject_js_1 = require("../../../../shared/getEnvVarObject.js");
|
|
14
14
|
const execA = (0, util_1.promisify)(child_process_1.exec);
|
|
15
|
+
const debug = (0, utils_js_1.createDebugger)('vike:crawl');
|
|
15
16
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
16
17
|
(0, utils_js_1.assertIsSingleModuleInstance)('crawlPlusFiles.ts');
|
|
17
18
|
let gitIsNotUsable = false;
|
|
@@ -35,17 +36,16 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
35
36
|
//
|
|
36
37
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
37
38
|
// Crawl
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
files
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
39
|
+
const filesGit = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
40
|
+
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
41
|
+
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await fastGlob(userRootDir, outDirRelativeFromUserRootDir));
|
|
42
|
+
let files = !filesGitNothingFound
|
|
43
|
+
? filesGit
|
|
44
|
+
: // Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
45
|
+
filesGlob;
|
|
46
|
+
(0, utils_js_1.assert)(files);
|
|
47
|
+
if (debug.isActivated)
|
|
48
|
+
(0, utils_js_1.assert)((0, utils_js_1.deepEqual)(filesGlob, filesGit), "Git and glob results aren't matching.");
|
|
49
49
|
// Filter build files
|
|
50
50
|
files = files.filter((filePath) => !(0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(filePath));
|
|
51
51
|
// Normalize
|
|
@@ -74,7 +74,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
74
74
|
preserveUTF8,
|
|
75
75
|
'ls-files',
|
|
76
76
|
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
77
|
-
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
77
|
+
...utils_js_1.scriptFileExtensionList.map((ext) => `"**/+*.${ext}" "+*.${ext}"`),
|
|
78
78
|
// Performance gain is non-negligible.
|
|
79
79
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
80
80
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
@@ -101,6 +101,12 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
101
101
|
}
|
|
102
102
|
throw err;
|
|
103
103
|
}
|
|
104
|
+
if (debug.isActivated) {
|
|
105
|
+
debug('[git] userRootDir:', userRootDir);
|
|
106
|
+
debug('[git] cmd:', cmd);
|
|
107
|
+
debug('[git] result:', filesAll);
|
|
108
|
+
debug('[git] filesDeleted:', filesDeleted);
|
|
109
|
+
}
|
|
104
110
|
const files = [];
|
|
105
111
|
for (const filePath of filesAll) {
|
|
106
112
|
// + file?
|
|
@@ -121,14 +127,21 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
121
127
|
}
|
|
122
128
|
// Same as gitLsFiles() but using fast-glob
|
|
123
129
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
124
|
-
const
|
|
130
|
+
const pattern = `**/+*.${utils_js_1.scriptFileExtensions}`;
|
|
131
|
+
const options = {
|
|
125
132
|
ignore: getIgnoreAsPatterns(outDirRelativeFromUserRootDir),
|
|
126
133
|
cwd: userRootDir,
|
|
127
134
|
dot: false
|
|
128
|
-
}
|
|
135
|
+
};
|
|
136
|
+
const files = await (0, fast_glob_1.default)(pattern, options);
|
|
129
137
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
130
138
|
// https://github.com/vikejs/vike/pull/1750
|
|
131
139
|
files.sort();
|
|
140
|
+
if (debug.isActivated) {
|
|
141
|
+
debug('[glob] pattern:', pattern);
|
|
142
|
+
debug('[glob] options:', options);
|
|
143
|
+
debug('[glob] result:', files);
|
|
144
|
+
}
|
|
132
145
|
return files;
|
|
133
146
|
}
|
|
134
147
|
// Same as getIgnoreAsFilterFn() but as glob pattern
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -8,7 +8,6 @@ exports.getFilesystemRouteDefinedBy = getFilesystemRouteDefinedBy;
|
|
|
8
8
|
exports.isInherited = isInherited;
|
|
9
9
|
exports.getLocationId = getLocationId;
|
|
10
10
|
exports.sortAfterInheritanceOrder = sortAfterInheritanceOrder;
|
|
11
|
-
exports.isGlobalLocation = isGlobalLocation;
|
|
12
11
|
exports.applyFilesystemRoutingRootEffect = applyFilesystemRoutingRootEffect;
|
|
13
12
|
exports.getLogicalPath = getLogicalPath;
|
|
14
13
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -45,10 +44,6 @@ function getLogicalPath(locationId, ignoredDirs, removeParenthesesDirs) {
|
|
|
45
44
|
assertIsPath(logicalPath);
|
|
46
45
|
return logicalPath;
|
|
47
46
|
}
|
|
48
|
-
/** Whether configs defined in `locationId` apply in every `locationIds` */
|
|
49
|
-
function isGlobalLocation(locationId, locationIds) {
|
|
50
|
-
return locationIds.every((locId) => isInherited(locationId, locId) || locationIsRendererDir(locId));
|
|
51
|
-
}
|
|
52
47
|
function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
|
|
53
48
|
assertLocationId(locationId1);
|
|
54
49
|
assertLocationId(locationId2);
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -56,7 +56,7 @@ async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir,
|
|
|
56
56
|
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig, esbuildCache) {
|
|
57
57
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
58
58
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
59
|
-
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig
|
|
59
|
+
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, userRootDir, isExtensionConfig, esbuildCache);
|
|
60
60
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [...visited, filePathAbsoluteFilesystem], esbuildCache);
|
|
61
61
|
const configFile = {
|
|
62
62
|
fileExports,
|
|
@@ -26,7 +26,7 @@ const debug = (0, utils_js_1.createDebugger)('vike:pointer-imports');
|
|
|
26
26
|
const debugEsbuildResolve = (0, utils_js_1.createDebugger)('vike:esbuild-resolve');
|
|
27
27
|
if (debugEsbuildResolve.isActivated)
|
|
28
28
|
debugEsbuildResolve('esbuild version', esbuild_1.version);
|
|
29
|
-
async function transpileAndExecuteFile(filePath, userRootDir,
|
|
29
|
+
async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig, esbuildCache) {
|
|
30
30
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
31
31
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
32
32
|
if (esbuildCache[filePathAbsoluteFilesystem]) {
|
|
@@ -40,12 +40,12 @@ async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile, esbu
|
|
|
40
40
|
(0, utils_js_1.assertWarning)(false, `${picocolors_1.default.cyan('.h.js')} files are deprecated: simply renaming ${filePathToShowToUserResolved} to ${removeHeaderFileExtension(filePathToShowToUserResolved)} is usually enough, although you may occasionally need to use ${picocolors_1.default.cyan("with { type: 'pointer' }")} as explained at https://vike.dev/config#pointer-imports`, { onlyOnce: true });
|
|
41
41
|
}
|
|
42
42
|
let fileExports;
|
|
43
|
-
if (
|
|
43
|
+
if (isExtensionConfig && !isHeader && fileExtension.endsWith('js')) {
|
|
44
44
|
// This doesn't track dependencies => we should never use this for user land configs
|
|
45
45
|
fileExports = await executeFile(filePathAbsoluteFilesystem, filePath);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
const transformImports =
|
|
48
|
+
const transformImports = isHeader ? 'all' : true;
|
|
49
49
|
const code = await transpileFile(filePath, transformImports, userRootDir);
|
|
50
50
|
fileExports = await executeTranspiledFile(filePath, code);
|
|
51
51
|
}
|
|
@@ -338,6 +338,7 @@ function isTemporaryBuildFile(filePath) {
|
|
|
338
338
|
const fileName = path_1.default.posix.basename(filePath);
|
|
339
339
|
return /\.build-[a-z0-9]{12}\.mjs$/.test(fileName);
|
|
340
340
|
}
|
|
341
|
+
// TODO/next-major: remove
|
|
341
342
|
function isHeaderFile(filePath) {
|
|
342
343
|
(0, utils_js_1.assertPosixPath)(filePath);
|
|
343
344
|
const fileExtensions = getFileExtensions(filePath);
|
|
@@ -141,7 +141,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
141
141
|
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
142
142
|
const esbuildCache = {};
|
|
143
143
|
const plusFilesAll = await (0, getPlusFilesAll_js_1.getPlusFilesAll)(userRootDir, esbuildCache);
|
|
144
|
-
assertKnownConfigs(plusFilesAll)
|
|
144
|
+
// assertKnownConfigs(plusFilesAll)
|
|
145
145
|
const configDefinitionsResolved = await resolveConfigDefinitions(plusFilesAll, userRootDir, esbuildCache);
|
|
146
146
|
const { pageConfigGlobal, pageConfigs } = getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRootDir);
|
|
147
147
|
// interop vike(options) in vite.config.js
|
|
@@ -235,10 +235,9 @@ function assertPageConfigGlobal(pageConfigGlobal, plusFilesAll) {
|
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
function assertGlobalConfigLocation(configName, sources, plusFilesAll, configDefinitionsGlobal) {
|
|
238
|
-
const locationIdsAll = (0, utils_js_1.objectKeys)(plusFilesAll);
|
|
239
238
|
// Determine existing global +config.js files
|
|
240
239
|
const configFilePathsGlobal = [];
|
|
241
|
-
const plusFilesGlobal = Object.values((0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(plusFilesAll).filter(([locationId]) =>
|
|
240
|
+
const plusFilesGlobal = Object.values((0, utils_js_1.objectFromEntries)((0, utils_js_1.objectEntries)(plusFilesAll).filter(([locationId]) => isGlobalLocation(locationId, plusFilesAll)))).flat();
|
|
242
241
|
plusFilesGlobal
|
|
243
242
|
.filter((i) => i.isConfigFile)
|
|
244
243
|
.forEach((plusFile) => {
|
|
@@ -257,7 +256,7 @@ function assertGlobalConfigLocation(configName, sources, plusFilesAll, configDef
|
|
|
257
256
|
if (!filePathAbsoluteUserRootDir)
|
|
258
257
|
return;
|
|
259
258
|
(0, utils_js_1.assert)(!plusFile.isExtensionConfig);
|
|
260
|
-
if (!
|
|
259
|
+
if (!isGlobalLocation(source.locationId, plusFilesAll)) {
|
|
261
260
|
const configDef = configDefinitionsGlobal[configName];
|
|
262
261
|
(0, utils_js_1.assert)(configDef);
|
|
263
262
|
const isConditionallyGlobal = (0, utils_js_1.isCallable)(configDef.global);
|
|
@@ -360,7 +359,7 @@ function sortForGlobal(plusFilesAll) {
|
|
|
360
359
|
const locationIdsAll = (0, utils_js_1.objectKeys)(plusFilesAll);
|
|
361
360
|
const plusFilesAllSorted = Object.fromEntries((0, utils_js_1.objectEntries)(plusFilesAll)
|
|
362
361
|
.sort((0, utils_js_1.lowerFirst)(([locationId]) => locationId.split('/').length))
|
|
363
|
-
.sort((0, utils_js_1.makeFirst)(([locationId]) =>
|
|
362
|
+
.sort((0, utils_js_1.makeFirst)(([locationId]) => isGlobalLocation(locationId, plusFilesAll))));
|
|
364
363
|
return plusFilesAllSorted;
|
|
365
364
|
}
|
|
366
365
|
function resolveConfigValueSources(configName, configDef, plusFilesRelevant, userRootDir, isGlobal) {
|
|
@@ -932,3 +931,10 @@ function resolveConfigEnv(configEnv, filePath) {
|
|
|
932
931
|
}
|
|
933
932
|
return configEnvResolved;
|
|
934
933
|
}
|
|
934
|
+
/** Whether configs defined in `locationId` apply to every page */
|
|
935
|
+
function isGlobalLocation(locationId, plusFilesAll) {
|
|
936
|
+
const locationIdsPage = (0, utils_js_1.objectEntries)(plusFilesAll)
|
|
937
|
+
.filter(([_locationId, plusFiles]) => isDefiningPage(plusFiles))
|
|
938
|
+
.map(([locationId]) => locationId);
|
|
939
|
+
return locationIdsPage.every((locId) => (0, filesystemRouting_js_1.isInherited)(locationId, locId));
|
|
940
|
+
}
|
|
@@ -14,7 +14,7 @@ async function loadUserFilesServerSide(pageContext) {
|
|
|
14
14
|
const pageConfig = (0, findPageConfig_js_1.findPageConfig)(pageContext._pageConfigs, pageContext.pageId); // Make pageConfig globally available as pageContext._pageConfig?
|
|
15
15
|
const globalContext = pageContext._globalContext;
|
|
16
16
|
const [{ pageFilesLoaded, pageContextExports }] = await Promise.all([
|
|
17
|
-
loadPageUserFiles(pageContext._pageFilesAll, pageConfig, pageContext.pageId, !globalContext.isProduction),
|
|
17
|
+
loadPageUserFiles(pageContext._pageFilesAll, pageConfig, globalContext.pageConfigGlobal, pageContext.pageId, !globalContext.isProduction),
|
|
18
18
|
(0, analyzePageClientSide_js_1.analyzePageClientSideInit)(pageContext._pageFilesAll, pageContext.pageId, { sharedPageFilesAlreadyLoaded: true })
|
|
19
19
|
]);
|
|
20
20
|
const { isHtmlOnly, isClientRouting, clientEntries, clientDependencies, pageFilesClientSide, pageFilesServerSide } = await (0, analyzePage_js_1.analyzePage)(pageContext._pageFilesAll, pageConfig, pageContext.pageId, globalContext);
|
|
@@ -98,11 +98,11 @@ async function loadUserFilesServerSide(pageContext) {
|
|
|
98
98
|
}
|
|
99
99
|
return pageContextAddendum;
|
|
100
100
|
}
|
|
101
|
-
async function loadPageUserFiles(pageFilesAll, pageConfig, pageId, isDev) {
|
|
101
|
+
async function loadPageUserFiles(pageFilesAll, pageConfig, pageConfigGlobal, pageId, isDev) {
|
|
102
102
|
const pageFilesServerSide = (0, getPageFiles_js_1.getPageFilesServerSide)(pageFilesAll, pageId);
|
|
103
103
|
const pageConfigLoaded = !pageConfig ? null : await (0, loadConfigValues_js_1.loadConfigValues)(pageConfig, isDev);
|
|
104
104
|
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
105
|
-
const pageContextExports = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyOld)(pageFilesServerSide, pageConfigLoaded);
|
|
105
|
+
const pageContextExports = (0, getPageConfigUserFriendly_js_1.getPageConfigUserFriendlyOld)(pageFilesServerSide, pageConfigLoaded, pageConfigGlobal);
|
|
106
106
|
return {
|
|
107
107
|
pageContextExports,
|
|
108
108
|
pageFilesLoaded: pageFilesServerSide
|
|
@@ -19,7 +19,7 @@ function getPageConfigUserFriendlyNew(pageConfig) {
|
|
|
19
19
|
_from: res.from
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
22
|
+
function getPageConfigUserFriendlyOld(pageFiles, pageConfig, pageConfigGlobal) {
|
|
23
23
|
const config = {};
|
|
24
24
|
const configEntries = {}; // TODO/v1-release: remove
|
|
25
25
|
const exportsAll = {}; // TODO/v1-release: remove
|
|
@@ -44,7 +44,9 @@ function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
|
44
44
|
let sources;
|
|
45
45
|
let from;
|
|
46
46
|
if (pageConfig) {
|
|
47
|
-
const res = getPageConfigUserFriendlyV1Desin(
|
|
47
|
+
const res = getPageConfigUserFriendlyV1Desin({
|
|
48
|
+
configValues: { ...pageConfigGlobal.configValues, ...pageConfig.configValues }
|
|
49
|
+
});
|
|
48
50
|
source = res.source;
|
|
49
51
|
sources = res.sources;
|
|
50
52
|
from = res.from;
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -17,6 +17,7 @@ const isArray_js_1 = require("./isArray.js");
|
|
|
17
17
|
(0, assert_js_1.assert)(!(0, isBrowser_js_1.isBrowser)());
|
|
18
18
|
globalThis.__brillout_debug_createDebugger = createDebugger;
|
|
19
19
|
const flags = [
|
|
20
|
+
'vike:crawl',
|
|
20
21
|
'vike:error',
|
|
21
22
|
'vike:esbuild-resolve',
|
|
22
23
|
'vike:extractAssets',
|
|
@@ -45,7 +45,7 @@ function getPageContextPrefetched(pageContext) {
|
|
|
45
45
|
}
|
|
46
46
|
async function prefetchAssets(pageContextLink) {
|
|
47
47
|
try {
|
|
48
|
-
await loadUserFilesClientSide(pageContextLink.pageId, pageContextLink._pageFilesAll, pageContextLink._pageConfigs);
|
|
48
|
+
await loadUserFilesClientSide(pageContextLink.pageId, pageContextLink._pageFilesAll, pageContextLink._pageConfigs, pageContextLink._pageConfigGlobal);
|
|
49
49
|
}
|
|
50
50
|
catch (err) {
|
|
51
51
|
if (isErrorFetchingStaticAssets(err)) {
|
|
@@ -131,7 +131,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
131
131
|
objectAssign(pageContext, pageContextFromRoute);
|
|
132
132
|
}
|
|
133
133
|
try {
|
|
134
|
-
objectAssign(pageContext, await loadUserFilesClientSide(pageContext.pageId, pageContext._pageFilesAll, pageContext._pageConfigs));
|
|
134
|
+
objectAssign(pageContext, await loadUserFilesClientSide(pageContext.pageId, pageContext._pageFilesAll, pageContext._pageConfigs, pageContext._pageConfigGlobal));
|
|
135
135
|
}
|
|
136
136
|
catch (err) {
|
|
137
137
|
if (handleErrorFetchingStaticAssets(err, pageContext, isFirstRender)) {
|
|
@@ -336,7 +336,7 @@ async function renderPageClientSide(renderArgs) {
|
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
338
|
try {
|
|
339
|
-
objectAssign(pageContext, await loadUserFilesClientSide(pageContext.pageId, pageContext._pageFilesAll, pageContext._pageConfigs));
|
|
339
|
+
objectAssign(pageContext, await loadUserFilesClientSide(pageContext.pageId, pageContext._pageFilesAll, pageContext._pageConfigs, pageContext._pageConfigGlobal));
|
|
340
340
|
}
|
|
341
341
|
catch (err) {
|
|
342
342
|
if (handleErrorFetchingStaticAssets(err, pageContext, isFirstRender)) {
|
|
@@ -10,6 +10,7 @@ declare function getPageContext(): Promise<{
|
|
|
10
10
|
} & {
|
|
11
11
|
_pageFilesAll: import("../../shared/getPageFiles.js").PageFile[];
|
|
12
12
|
_pageConfigs: import("../../__internal/index.js").PageConfig[];
|
|
13
|
+
_pageConfigGlobal: import("../../shared/page-configs/PageConfig.js").PageConfigGlobalRuntime;
|
|
13
14
|
} & import("../../shared/getPageFiles.js").PageConfigUserFriendly & {
|
|
14
15
|
_pageFilesLoaded: import("../../shared/getPageFiles.js").PageFile[];
|
|
15
16
|
}>;
|
|
@@ -6,7 +6,7 @@ import { getCurrentUrl } from '../shared/getCurrentUrl.js';
|
|
|
6
6
|
import { getPageConfigsRuntime } from '../../shared/getPageConfigsRuntime.js';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import * as virtualFileExports from 'virtual:vike:importUserCode:client:server-routing';
|
|
9
|
-
const { pageFilesAll, pageConfigs } = getPageConfigsRuntime(virtualFileExports);
|
|
9
|
+
const { pageFilesAll, pageConfigs, pageConfigGlobal } = getPageConfigsRuntime(virtualFileExports);
|
|
10
10
|
const urlFirst = getCurrentUrl({ withoutHash: true });
|
|
11
11
|
async function getPageContext() {
|
|
12
12
|
const pageContext = getPageContextSerializedInHtml();
|
|
@@ -28,9 +28,10 @@ async function loadPageUserFiles(pageId) {
|
|
|
28
28
|
const pageContextAddendum = {};
|
|
29
29
|
objectAssign(pageContextAddendum, {
|
|
30
30
|
_pageFilesAll: pageFilesAll,
|
|
31
|
-
_pageConfigs: pageConfigs
|
|
31
|
+
_pageConfigs: pageConfigs,
|
|
32
|
+
_pageConfigGlobal: pageConfigGlobal
|
|
32
33
|
});
|
|
33
|
-
objectAssign(pageContextAddendum, await loadUserFilesClientSide(pageId, pageContextAddendum._pageFilesAll, pageContextAddendum._pageConfigs));
|
|
34
|
+
objectAssign(pageContextAddendum, await loadUserFilesClientSide(pageId, pageContextAddendum._pageFilesAll, pageContextAddendum._pageConfigs, pageContextAddendum._pageConfigGlobal));
|
|
34
35
|
pageFilesAll
|
|
35
36
|
.filter((p) => p.fileType !== '.page.server')
|
|
36
37
|
.forEach((p) => {
|
|
@@ -2,13 +2,14 @@ export { loadUserFilesClientSide };
|
|
|
2
2
|
export { isErrorFetchingStaticAssets };
|
|
3
3
|
export type { PageContextUserFiles };
|
|
4
4
|
import { type PageFile, type PageConfigUserFriendly } from '../../shared/getPageFiles.js';
|
|
5
|
-
import type { PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
5
|
+
import type { PageConfigGlobalRuntime, PageConfigRuntime } from '../../shared/page-configs/PageConfig.js';
|
|
6
6
|
type PageContextUserFilesLoaded = PageConfigUserFriendly & {
|
|
7
7
|
_pageFilesLoaded: PageFile[];
|
|
8
8
|
};
|
|
9
9
|
type PageContextUserFiles = {
|
|
10
10
|
_pageFilesAll: PageFile[];
|
|
11
11
|
_pageConfigs: PageConfigRuntime[];
|
|
12
|
+
_pageConfigGlobal: PageConfigGlobalRuntime;
|
|
12
13
|
};
|
|
13
|
-
declare function loadUserFilesClientSide(pageId: string, pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[]): Promise<PageContextUserFilesLoaded>;
|
|
14
|
+
declare function loadUserFilesClientSide(pageId: string, pageFilesAll: PageFile[], pageConfigs: PageConfigRuntime[], pageConfigGlobal: PageConfigGlobalRuntime): Promise<PageContextUserFilesLoaded>;
|
|
14
15
|
declare function isErrorFetchingStaticAssets(err: unknown): boolean;
|
|
@@ -6,7 +6,7 @@ import { findPageConfig } from '../../shared/page-configs/findPageConfig.js';
|
|
|
6
6
|
import { loadConfigValues } from '../../shared/page-configs/loadConfigValues.js';
|
|
7
7
|
import { objectAssign } from '../server-routing-runtime/utils.js';
|
|
8
8
|
const stamp = '__whileFetchingAssets';
|
|
9
|
-
async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
9
|
+
async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs, pageConfigGlobal) {
|
|
10
10
|
const pageFilesClientSide = getPageFilesClientSide(pageFilesAll, pageId);
|
|
11
11
|
const pageConfig = findPageConfig(pageConfigs, pageId);
|
|
12
12
|
let pageConfigLoaded;
|
|
@@ -30,7 +30,7 @@ async function loadUserFilesClientSide(pageId, pageFilesAll, pageConfigs) {
|
|
|
30
30
|
}
|
|
31
31
|
throw err;
|
|
32
32
|
}
|
|
33
|
-
const pageContextExports = getPageConfigUserFriendlyOld(pageFilesClientSide, pageConfigLoaded);
|
|
33
|
+
const pageContextExports = getPageConfigUserFriendlyOld(pageFilesClientSide, pageConfigLoaded, pageConfigGlobal);
|
|
34
34
|
const pageContextAddendum = {};
|
|
35
35
|
objectAssign(pageContextAddendum, pageContextExports);
|
|
36
36
|
objectAssign(pageContextAddendum, { _pageFilesLoaded: pageFilesClientSide });
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList } from '../../../../utils.js';
|
|
2
|
+
import { assertPosixPath, assert, scriptFileExtensions, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove, isScriptFile, scriptFileExtensionList, createDebugger, deepEqual } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import glob from 'fast-glob';
|
|
5
5
|
import { exec } from 'child_process';
|
|
@@ -7,6 +7,7 @@ import { promisify } from 'util';
|
|
|
7
7
|
import { isTemporaryBuildFile } from './transpileAndExecuteFile.js';
|
|
8
8
|
import { getEnvVarObject } from '../../../../shared/getEnvVarObject.js';
|
|
9
9
|
const execA = promisify(exec);
|
|
10
|
+
const debug = createDebugger('vike:crawl');
|
|
10
11
|
assertIsNotProductionRuntime();
|
|
11
12
|
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
12
13
|
let gitIsNotUsable = false;
|
|
@@ -30,17 +31,16 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem) {
|
|
|
30
31
|
//
|
|
31
32
|
!outDirRelativeFromUserRootDir.startsWith('../')));
|
|
32
33
|
// Crawl
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
files
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
34
|
+
const filesGit = !isGitCrawlDisabled() && (await gitLsFiles(userRootDir, outDirRelativeFromUserRootDir));
|
|
35
|
+
const filesGitNothingFound = !filesGit || filesGit.length === 0;
|
|
36
|
+
const filesGlob = (filesGitNothingFound || debug.isActivated) && (await fastGlob(userRootDir, outDirRelativeFromUserRootDir));
|
|
37
|
+
let files = !filesGitNothingFound
|
|
38
|
+
? filesGit
|
|
39
|
+
: // Fallback to fast-glob for users that dynamically generate plus files. (Assuming that no plus file is found because of the user's .gitignore list.)
|
|
40
|
+
filesGlob;
|
|
41
|
+
assert(files);
|
|
42
|
+
if (debug.isActivated)
|
|
43
|
+
assert(deepEqual(filesGlob, filesGit), "Git and glob results aren't matching.");
|
|
44
44
|
// Filter build files
|
|
45
45
|
files = files.filter((filePath) => !isTemporaryBuildFile(filePath));
|
|
46
46
|
// Normalize
|
|
@@ -69,7 +69,7 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
69
69
|
preserveUTF8,
|
|
70
70
|
'ls-files',
|
|
71
71
|
// Performance gain seems negligible: https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
72
|
-
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}"`),
|
|
72
|
+
...scriptFileExtensionList.map((ext) => `"**/+*.${ext}" "+*.${ext}"`),
|
|
73
73
|
// Performance gain is non-negligible.
|
|
74
74
|
// - https://github.com/vikejs/vike/pull/1688#issuecomment-2166206648
|
|
75
75
|
// - When node_modules/ is untracked the performance gain could be significant?
|
|
@@ -96,6 +96,12 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
96
96
|
}
|
|
97
97
|
throw err;
|
|
98
98
|
}
|
|
99
|
+
if (debug.isActivated) {
|
|
100
|
+
debug('[git] userRootDir:', userRootDir);
|
|
101
|
+
debug('[git] cmd:', cmd);
|
|
102
|
+
debug('[git] result:', filesAll);
|
|
103
|
+
debug('[git] filesDeleted:', filesDeleted);
|
|
104
|
+
}
|
|
99
105
|
const files = [];
|
|
100
106
|
for (const filePath of filesAll) {
|
|
101
107
|
// + file?
|
|
@@ -116,14 +122,21 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
116
122
|
}
|
|
117
123
|
// Same as gitLsFiles() but using fast-glob
|
|
118
124
|
async function fastGlob(userRootDir, outDirRelativeFromUserRootDir) {
|
|
119
|
-
const
|
|
125
|
+
const pattern = `**/+*.${scriptFileExtensions}`;
|
|
126
|
+
const options = {
|
|
120
127
|
ignore: getIgnoreAsPatterns(outDirRelativeFromUserRootDir),
|
|
121
128
|
cwd: userRootDir,
|
|
122
129
|
dot: false
|
|
123
|
-
}
|
|
130
|
+
};
|
|
131
|
+
const files = await glob(pattern, options);
|
|
124
132
|
// Make build deterministic, in order to get a stable generated hash for dist/client/assets/entries/entry-client-routing.${hash}.js
|
|
125
133
|
// https://github.com/vikejs/vike/pull/1750
|
|
126
134
|
files.sort();
|
|
135
|
+
if (debug.isActivated) {
|
|
136
|
+
debug('[glob] pattern:', pattern);
|
|
137
|
+
debug('[glob] options:', options);
|
|
138
|
+
debug('[glob] result:', files);
|
|
139
|
+
}
|
|
127
140
|
return files;
|
|
128
141
|
}
|
|
129
142
|
// Same as getIgnoreAsFilterFn() but as glob pattern
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { getFilesystemRouteDefinedBy };
|
|
|
3
3
|
export { isInherited };
|
|
4
4
|
export { getLocationId };
|
|
5
5
|
export { sortAfterInheritanceOrder };
|
|
6
|
-
export { isGlobalLocation };
|
|
7
6
|
export { applyFilesystemRoutingRootEffect };
|
|
8
7
|
export type { LocationId };
|
|
9
8
|
export { getLogicalPath };
|
|
@@ -46,8 +45,6 @@ declare function getFilesystemRouteString(locationId: LocationId): string;
|
|
|
46
45
|
* getLogicalPath('/pages/some-page', ['pages']) => '/some-page'
|
|
47
46
|
*/
|
|
48
47
|
declare function getLogicalPath(locationId: LocationId, ignoredDirs: string[], removeParenthesesDirs?: true): string;
|
|
49
|
-
/** Whether configs defined in `locationId` apply in every `locationIds` */
|
|
50
|
-
declare function isGlobalLocation(locationId: LocationId, locationIds: LocationId[]): boolean;
|
|
51
48
|
declare function sortAfterInheritanceOrder(locationId1: LocationId, locationId2: LocationId, locationIdPage: LocationId): -1 | 1 | 0;
|
|
52
49
|
/** Whether configs defined at `locationId1` also apply at `locationId2` */
|
|
53
50
|
declare function isInherited(locationId1: LocationId, locationId2: LocationId): boolean;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -3,7 +3,6 @@ export { getFilesystemRouteDefinedBy };
|
|
|
3
3
|
export { isInherited };
|
|
4
4
|
export { getLocationId };
|
|
5
5
|
export { sortAfterInheritanceOrder };
|
|
6
|
-
export { isGlobalLocation };
|
|
7
6
|
export { applyFilesystemRoutingRootEffect };
|
|
8
7
|
// For ./filesystemRouting.spec.ts
|
|
9
8
|
export { getLogicalPath };
|
|
@@ -41,10 +40,6 @@ function getLogicalPath(locationId, ignoredDirs, removeParenthesesDirs) {
|
|
|
41
40
|
assertIsPath(logicalPath);
|
|
42
41
|
return logicalPath;
|
|
43
42
|
}
|
|
44
|
-
/** Whether configs defined in `locationId` apply in every `locationIds` */
|
|
45
|
-
function isGlobalLocation(locationId, locationIds) {
|
|
46
|
-
return locationIds.every((locId) => isInherited(locationId, locId) || locationIsRendererDir(locId));
|
|
47
|
-
}
|
|
48
43
|
function sortAfterInheritanceOrder(locationId1, locationId2, locationIdPage) {
|
|
49
44
|
assertLocationId(locationId1);
|
|
50
45
|
assertLocationId(locationId2);
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -51,7 +51,7 @@ async function loadValueFile(interfaceValueFile, configDefinitions, userRootDir,
|
|
|
51
51
|
async function loadConfigFile(configFilePath, userRootDir, visited, isExtensionConfig, esbuildCache) {
|
|
52
52
|
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
53
53
|
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
54
|
-
const { fileExports } = await transpileAndExecuteFile(configFilePath, userRootDir, isExtensionConfig
|
|
54
|
+
const { fileExports } = await transpileAndExecuteFile(configFilePath, userRootDir, isExtensionConfig, esbuildCache);
|
|
55
55
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [...visited, filePathAbsoluteFilesystem], esbuildCache);
|
|
56
56
|
const configFile = {
|
|
57
57
|
fileExports,
|
|
@@ -10,7 +10,7 @@ type FileExports = {
|
|
|
10
10
|
};
|
|
11
11
|
type EsbuildCache = Record<string, // filePathAbsoluteFilesystem
|
|
12
12
|
Promise<FileExports>>;
|
|
13
|
-
declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir: string,
|
|
13
|
+
declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir: string, isExtensionConfig: boolean, esbuildCache: EsbuildCache): Promise<FileExports>;
|
|
14
14
|
declare function getConfigBuildErrorFormatted(err: unknown): null | string;
|
|
15
15
|
declare function getConfigExecutionErrorIntroMsg(err: unknown): string | null;
|
|
16
16
|
declare function isTemporaryBuildFile(filePath: string): boolean;
|
|
@@ -21,7 +21,7 @@ const debug = createDebugger('vike:pointer-imports');
|
|
|
21
21
|
const debugEsbuildResolve = createDebugger('vike:esbuild-resolve');
|
|
22
22
|
if (debugEsbuildResolve.isActivated)
|
|
23
23
|
debugEsbuildResolve('esbuild version', version);
|
|
24
|
-
async function transpileAndExecuteFile(filePath, userRootDir,
|
|
24
|
+
async function transpileAndExecuteFile(filePath, userRootDir, isExtensionConfig, esbuildCache) {
|
|
25
25
|
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
26
26
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
27
27
|
if (esbuildCache[filePathAbsoluteFilesystem]) {
|
|
@@ -35,12 +35,12 @@ async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile, esbu
|
|
|
35
35
|
assertWarning(false, `${pc.cyan('.h.js')} files are deprecated: simply renaming ${filePathToShowToUserResolved} to ${removeHeaderFileExtension(filePathToShowToUserResolved)} is usually enough, although you may occasionally need to use ${pc.cyan("with { type: 'pointer' }")} as explained at https://vike.dev/config#pointer-imports`, { onlyOnce: true });
|
|
36
36
|
}
|
|
37
37
|
let fileExports;
|
|
38
|
-
if (
|
|
38
|
+
if (isExtensionConfig && !isHeader && fileExtension.endsWith('js')) {
|
|
39
39
|
// This doesn't track dependencies => we should never use this for user land configs
|
|
40
40
|
fileExports = await executeFile(filePathAbsoluteFilesystem, filePath);
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
const transformImports =
|
|
43
|
+
const transformImports = isHeader ? 'all' : true;
|
|
44
44
|
const code = await transpileFile(filePath, transformImports, userRootDir);
|
|
45
45
|
fileExports = await executeTranspiledFile(filePath, code);
|
|
46
46
|
}
|
|
@@ -333,6 +333,7 @@ function isTemporaryBuildFile(filePath) {
|
|
|
333
333
|
const fileName = path.posix.basename(filePath);
|
|
334
334
|
return /\.build-[a-z0-9]{12}\.mjs$/.test(fileName);
|
|
335
335
|
}
|
|
336
|
+
// TODO/next-major: remove
|
|
336
337
|
function isHeaderFile(filePath) {
|
|
337
338
|
assertPosixPath(filePath);
|
|
338
339
|
const fileExtensions = getFileExtensions(filePath);
|
|
@@ -7,7 +7,7 @@ export { getConfVal };
|
|
|
7
7
|
export { getConfigDefinitionOptional };
|
|
8
8
|
import { assertPosixPath, assert, isObject, assertUsage, assertWarning, objectEntries, hasProp, includes, assertIsNotProductionRuntime, getMostSimilar, joinEnglish, assertKeys, objectKeys, objectFromEntries, unique, isCallable, makeFirst, lowerFirst } from '../../../utils.js';
|
|
9
9
|
import { configDefinitionsBuiltIn } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
10
|
-
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder,
|
|
10
|
+
import { getLocationId, getFilesystemRouteString, getFilesystemRouteDefinedBy, isInherited, sortAfterInheritanceOrder, applyFilesystemRoutingRootEffect } from './getVikeConfig/filesystemRouting.js';
|
|
11
11
|
import { isConfigInvalid, isConfigInvalid_set } from '../../../../runtime/renderPage/isConfigInvalid.js';
|
|
12
12
|
import { getViteDevServer } from '../../../../runtime/globalContext.js';
|
|
13
13
|
import { logConfigError, logConfigErrorRecover } from '../../../shared/loggerNotProd.js';
|
|
@@ -135,7 +135,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, vikeVitePlug
|
|
|
135
135
|
async function loadVikeConfig(userRootDir, vikeVitePluginOptions) {
|
|
136
136
|
const esbuildCache = {};
|
|
137
137
|
const plusFilesAll = await getPlusFilesAll(userRootDir, esbuildCache);
|
|
138
|
-
assertKnownConfigs(plusFilesAll)
|
|
138
|
+
// assertKnownConfigs(plusFilesAll)
|
|
139
139
|
const configDefinitionsResolved = await resolveConfigDefinitions(plusFilesAll, userRootDir, esbuildCache);
|
|
140
140
|
const { pageConfigGlobal, pageConfigs } = getPageConfigsBuildTime(configDefinitionsResolved, plusFilesAll, userRootDir);
|
|
141
141
|
// interop vike(options) in vite.config.js
|
|
@@ -229,10 +229,9 @@ function assertPageConfigGlobal(pageConfigGlobal, plusFilesAll) {
|
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
231
|
function assertGlobalConfigLocation(configName, sources, plusFilesAll, configDefinitionsGlobal) {
|
|
232
|
-
const locationIdsAll = objectKeys(plusFilesAll);
|
|
233
232
|
// Determine existing global +config.js files
|
|
234
233
|
const configFilePathsGlobal = [];
|
|
235
|
-
const plusFilesGlobal = Object.values(objectFromEntries(objectEntries(plusFilesAll).filter(([locationId]) => isGlobalLocation(locationId,
|
|
234
|
+
const plusFilesGlobal = Object.values(objectFromEntries(objectEntries(plusFilesAll).filter(([locationId]) => isGlobalLocation(locationId, plusFilesAll)))).flat();
|
|
236
235
|
plusFilesGlobal
|
|
237
236
|
.filter((i) => i.isConfigFile)
|
|
238
237
|
.forEach((plusFile) => {
|
|
@@ -251,7 +250,7 @@ function assertGlobalConfigLocation(configName, sources, plusFilesAll, configDef
|
|
|
251
250
|
if (!filePathAbsoluteUserRootDir)
|
|
252
251
|
return;
|
|
253
252
|
assert(!plusFile.isExtensionConfig);
|
|
254
|
-
if (!isGlobalLocation(source.locationId,
|
|
253
|
+
if (!isGlobalLocation(source.locationId, plusFilesAll)) {
|
|
255
254
|
const configDef = configDefinitionsGlobal[configName];
|
|
256
255
|
assert(configDef);
|
|
257
256
|
const isConditionallyGlobal = isCallable(configDef.global);
|
|
@@ -354,7 +353,7 @@ function sortForGlobal(plusFilesAll) {
|
|
|
354
353
|
const locationIdsAll = objectKeys(plusFilesAll);
|
|
355
354
|
const plusFilesAllSorted = Object.fromEntries(objectEntries(plusFilesAll)
|
|
356
355
|
.sort(lowerFirst(([locationId]) => locationId.split('/').length))
|
|
357
|
-
.sort(makeFirst(([locationId]) => isGlobalLocation(locationId,
|
|
356
|
+
.sort(makeFirst(([locationId]) => isGlobalLocation(locationId, plusFilesAll))));
|
|
358
357
|
return plusFilesAllSorted;
|
|
359
358
|
}
|
|
360
359
|
function resolveConfigValueSources(configName, configDef, plusFilesRelevant, userRootDir, isGlobal) {
|
|
@@ -926,3 +925,10 @@ function resolveConfigEnv(configEnv, filePath) {
|
|
|
926
925
|
}
|
|
927
926
|
return configEnvResolved;
|
|
928
927
|
}
|
|
928
|
+
/** Whether configs defined in `locationId` apply to every page */
|
|
929
|
+
function isGlobalLocation(locationId, plusFilesAll) {
|
|
930
|
+
const locationIdsPage = objectEntries(plusFilesAll)
|
|
931
|
+
.filter(([_locationId, plusFiles]) => isDefiningPage(plusFiles))
|
|
932
|
+
.map(([locationId]) => locationId);
|
|
933
|
+
return locationIdsPage.every((locId) => isInherited(locationId, locId));
|
|
934
|
+
}
|
|
@@ -12,7 +12,7 @@ async function loadUserFilesServerSide(pageContext) {
|
|
|
12
12
|
const pageConfig = findPageConfig(pageContext._pageConfigs, pageContext.pageId); // Make pageConfig globally available as pageContext._pageConfig?
|
|
13
13
|
const globalContext = pageContext._globalContext;
|
|
14
14
|
const [{ pageFilesLoaded, pageContextExports }] = await Promise.all([
|
|
15
|
-
loadPageUserFiles(pageContext._pageFilesAll, pageConfig, pageContext.pageId, !globalContext.isProduction),
|
|
15
|
+
loadPageUserFiles(pageContext._pageFilesAll, pageConfig, globalContext.pageConfigGlobal, pageContext.pageId, !globalContext.isProduction),
|
|
16
16
|
analyzePageClientSideInit(pageContext._pageFilesAll, pageContext.pageId, { sharedPageFilesAlreadyLoaded: true })
|
|
17
17
|
]);
|
|
18
18
|
const { isHtmlOnly, isClientRouting, clientEntries, clientDependencies, pageFilesClientSide, pageFilesServerSide } = await analyzePage(pageContext._pageFilesAll, pageConfig, pageContext.pageId, globalContext);
|
|
@@ -96,11 +96,11 @@ async function loadUserFilesServerSide(pageContext) {
|
|
|
96
96
|
}
|
|
97
97
|
return pageContextAddendum;
|
|
98
98
|
}
|
|
99
|
-
async function loadPageUserFiles(pageFilesAll, pageConfig, pageId, isDev) {
|
|
99
|
+
async function loadPageUserFiles(pageFilesAll, pageConfig, pageConfigGlobal, pageId, isDev) {
|
|
100
100
|
const pageFilesServerSide = getPageFilesServerSide(pageFilesAll, pageId);
|
|
101
101
|
const pageConfigLoaded = !pageConfig ? null : await loadConfigValues(pageConfig, isDev);
|
|
102
102
|
await Promise.all(pageFilesServerSide.map((p) => p.loadFile?.()));
|
|
103
|
-
const pageContextExports = getPageConfigUserFriendlyOld(pageFilesServerSide, pageConfigLoaded);
|
|
103
|
+
const pageContextExports = getPageConfigUserFriendlyOld(pageFilesServerSide, pageConfigLoaded, pageConfigGlobal);
|
|
104
104
|
return {
|
|
105
105
|
pageContextExports,
|
|
106
106
|
pageFilesLoaded: pageFilesServerSide
|
|
@@ -9,7 +9,7 @@ export type { ExportsAll };
|
|
|
9
9
|
export type { ConfigEntries };
|
|
10
10
|
import type { FileType } from '../getPageFiles/fileTypes.js';
|
|
11
11
|
import type { PageFile } from '../getPageFiles/getPageFileObject.js';
|
|
12
|
-
import type { ConfigValues, PageConfigRuntimeLoaded } from './PageConfig.js';
|
|
12
|
+
import type { ConfigValues, PageConfigGlobalRuntime, PageConfigRuntimeLoaded } from './PageConfig.js';
|
|
13
13
|
import { type ConfigDefinedAtOptional } from './getConfigDefinedAt.js';
|
|
14
14
|
import type { ConfigResolved } from './Config/PageContextConfig.js';
|
|
15
15
|
type ExportsAll = Record<string, {
|
|
@@ -82,4 +82,4 @@ type ConfigUserFriendly = {
|
|
|
82
82
|
declare function getPageConfigUserFriendlyNew(pageConfig: {
|
|
83
83
|
configValues: ConfigValues;
|
|
84
84
|
}): ConfigUserFriendly;
|
|
85
|
-
declare function getPageConfigUserFriendlyOld(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null): PageConfigUserFriendly;
|
|
85
|
+
declare function getPageConfigUserFriendlyOld(pageFiles: PageFile[], pageConfig: PageConfigRuntimeLoaded | null, pageConfigGlobal: PageConfigGlobalRuntime): PageConfigUserFriendly;
|
|
@@ -14,7 +14,7 @@ function getPageConfigUserFriendlyNew(pageConfig) {
|
|
|
14
14
|
_from: res.from
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
17
|
+
function getPageConfigUserFriendlyOld(pageFiles, pageConfig, pageConfigGlobal) {
|
|
18
18
|
const config = {};
|
|
19
19
|
const configEntries = {}; // TODO/v1-release: remove
|
|
20
20
|
const exportsAll = {}; // TODO/v1-release: remove
|
|
@@ -39,7 +39,9 @@ function getPageConfigUserFriendlyOld(pageFiles, pageConfig) {
|
|
|
39
39
|
let sources;
|
|
40
40
|
let from;
|
|
41
41
|
if (pageConfig) {
|
|
42
|
-
const res = getPageConfigUserFriendlyV1Desin(
|
|
42
|
+
const res = getPageConfigUserFriendlyV1Desin({
|
|
43
|
+
configValues: { ...pageConfigGlobal.configValues, ...pageConfig.configValues }
|
|
44
|
+
});
|
|
43
45
|
source = res.source;
|
|
44
46
|
sources = res.sources;
|
|
45
47
|
from = res.from;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.221-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.221-commit-937dbfb";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.221-commit-
|
|
2
|
+
export const PROJECT_VERSION = '0.4.221-commit-937dbfb';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createDebugger };
|
|
2
2
|
export { isDebugActivated };
|
|
3
3
|
export type { Debug };
|
|
4
|
-
declare const flags: readonly ["vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
4
|
+
declare const flags: readonly ["vike:crawl", "vike:error", "vike:esbuild-resolve", "vike:extractAssets", "vike:extractExportNames", "vike:glob", "vike:globalContext", "vike:log", "vike:optimizeDeps", "vike:outDir", "vike:pageFiles", "vike:pointer-imports", "vike:routing", "vike:setup", "vike:stream", "vike:virtual-files"];
|
|
5
5
|
type Flag = (typeof flags)[number];
|
|
6
6
|
type Debug = ReturnType<typeof createDebugger>;
|
|
7
7
|
type Options = {
|
package/dist/esm/utils/debug.js
CHANGED