vike 0.4.221-commit-8577456 → 0.4.221-commit-3310144
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/api/prepareViteApiCall.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +1 -1
- 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 +10 -4
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/cjs/utils/debug.js +1 -0
- package/dist/esm/node/api/prepareViteApiCall.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +1 -1
- 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 +11 -5
- 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
|
@@ -76,7 +76,7 @@ function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
|
76
76
|
viteConfigs.values.forEach((v) => {
|
|
77
77
|
(0, utils_js_1.assertUsage)((0, utils_js_1.isObject)(v.value), `${v.definedAt} should be an object`);
|
|
78
78
|
viteConfigEnhanced = (0, vite_1.mergeConfig)(viteConfigEnhanced ?? {}, v.value);
|
|
79
|
-
(0, utils_js_1.assertUsage)(findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
79
|
+
(0, utils_js_1.assertUsage)(!findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
80
80
|
});
|
|
81
81
|
return viteConfigEnhanced;
|
|
82
82
|
}
|
|
@@ -218,7 +218,7 @@ async function fixServerAssets_assertCssTarget(config) {
|
|
|
218
218
|
'The CSS browser target should be the same for both client and server, but we got:',
|
|
219
219
|
`Client: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
220
220
|
`Server: ${picocolors_1.default.cyan(JSON.stringify(targetCssResolvedServer))}`,
|
|
221
|
-
`Different targets
|
|
221
|
+
`Different targets lead to CSS duplication, see ${picocolors_1.default.underline('https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979')} for more information.`
|
|
222
222
|
].join('\n'), {
|
|
223
223
|
showStackTrace: true,
|
|
224
224
|
onlyOnce: 'different-css-target'
|
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);
|
|
@@ -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
|
+
}
|
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',
|
|
@@ -38,7 +38,7 @@ function addViteSettingsSetByVikeConfig(viteConfigEnhanced, vikeConfig) {
|
|
|
38
38
|
viteConfigs.values.forEach((v) => {
|
|
39
39
|
assertUsage(isObject(v.value), `${v.definedAt} should be an object`);
|
|
40
40
|
viteConfigEnhanced = mergeConfig(viteConfigEnhanced ?? {}, v.value);
|
|
41
|
-
assertUsage(findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
41
|
+
assertUsage(!findVikeVitePlugin(v.value), "Using the +vite setting to add Vike's Vite plugin is forbidden");
|
|
42
42
|
});
|
|
43
43
|
return viteConfigEnhanced;
|
|
44
44
|
}
|
|
@@ -213,7 +213,7 @@ async function fixServerAssets_assertCssTarget(config) {
|
|
|
213
213
|
'The CSS browser target should be the same for both client and server, but we got:',
|
|
214
214
|
`Client: ${pc.cyan(JSON.stringify(targetCssResolvedClient))}`,
|
|
215
215
|
`Server: ${pc.cyan(JSON.stringify(targetCssResolvedServer))}`,
|
|
216
|
-
`Different targets
|
|
216
|
+
`Different targets lead to CSS duplication, see ${pc.underline('https://github.com/vikejs/vike/issues/1815#issuecomment-2507002979')} for more information.`
|
|
217
217
|
].join('\n'), {
|
|
218
218
|
showStackTrace: true,
|
|
219
219
|
onlyOnce: 'different-css-target'
|
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';
|
|
@@ -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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.221-commit-
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.221-commit-3310144";
|
|
@@ -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-3310144';
|
|
@@ -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