vike 0.4.165 → 0.4.166-commit-a5e2596
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 +1 -1
- package/dist/cjs/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +78 -63
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +14 -1
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +18 -23
- package/dist/cjs/node/plugin/plugins/envVars.js +3 -2
- package/dist/cjs/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/cjs/node/plugin/plugins/fileEnv.js +6 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +6 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.js +0 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js +53 -24
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +10 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +32 -35
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +18 -26
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +26 -21
- package/dist/cjs/node/plugin/shared/getFilePath.js +142 -0
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +3 -8
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/cjs/node/plugin/utils.js +1 -1
- package/dist/cjs/node/prerender/runPrerender.js +6 -7
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/cjs/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/cjs/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +3 -3
- package/dist/cjs/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +31 -33
- package/dist/cjs/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/cjs/node/runtime/renderPage/getPageAssets.js +6 -12
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +5 -0
- package/dist/cjs/node/runtime/renderPage.js +34 -21
- package/dist/cjs/node/runtime/utils.js +0 -1
- package/dist/cjs/shared/page-configs/FilePath.js +2 -0
- package/dist/cjs/shared/route/abort.js +2 -1
- package/dist/cjs/shared/route/executeGuardHook.js +2 -1
- package/dist/cjs/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/cjs/shared/route/index.js +2 -3
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/utils/assert.js +2 -0
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/cjs/utils/assertSingleInstance.js +6 -5
- package/dist/cjs/utils/assertVersion.js +4 -1
- package/dist/cjs/utils/getGlobalObject.js +21 -6
- package/dist/cjs/utils/isNpmPackage.js +11 -5
- package/dist/cjs/utils/parseUrl.js +8 -1
- package/dist/cjs/utils/projectInfo.js +1 -4
- package/dist/esm/client/client-routing-runtime/history.d.ts +1 -1
- package/dist/esm/client/client-routing-runtime/history.js +5 -5
- package/dist/esm/client/client-routing-runtime/onBrowserHistoryNavigation.js +1 -1
- package/dist/esm/node/plugin/index.js +1 -1
- package/dist/esm/node/plugin/plugins/baseUrls.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/esm/node/plugin/plugins/buildConfig.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +79 -64
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +14 -1
- package/dist/esm/node/plugin/plugins/config/index.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -24
- package/dist/esm/node/plugin/plugins/envVars.js +4 -3
- package/dist/esm/node/plugin/plugins/extractAssetsPlugin.js +9 -9
- package/dist/esm/node/plugin/plugins/fileEnv.js +7 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +7 -3
- 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 +0 -1
- 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 +54 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +6 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +2 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +32 -35
- 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 +18 -26
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +3 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +26 -21
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +21 -0
- package/dist/esm/node/plugin/shared/getFilePath.js +136 -0
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +4 -9
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -1
- package/dist/esm/node/plugin/utils.d.ts +1 -1
- package/dist/esm/node/plugin/utils.js +1 -1
- package/dist/esm/node/prerender/runPrerender.js +2 -3
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/esm/node/runtime/html/injectAssets/injectHtmlTags.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnBeforeRenderAndDataHooks.js +1 -1
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js +2 -1
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +32 -34
- package/dist/esm/node/runtime/renderPage/getPageAssets/retrieveAssetsProd.js +9 -8
- package/dist/esm/node/runtime/renderPage/getPageAssets.js +7 -13
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -0
- package/dist/esm/node/runtime/renderPage.js +34 -21
- package/dist/esm/node/runtime/utils.d.ts +0 -1
- package/dist/esm/node/runtime/utils.js +0 -1
- package/dist/esm/shared/page-configs/Config/PageContextConfig.d.ts +1 -1
- package/dist/esm/shared/page-configs/FilePath.d.ts +64 -0
- package/dist/esm/shared/page-configs/FilePath.js +1 -0
- package/dist/esm/shared/page-configs/PageConfig.d.ts +1 -42
- package/dist/esm/shared/route/abort.js +2 -1
- package/dist/esm/shared/route/executeGuardHook.js +2 -1
- package/dist/esm/shared/route/executeOnBeforeRouteHook.js +2 -1
- package/dist/esm/shared/route/index.js +2 -3
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/utils/assert.js +2 -0
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +1 -0
- package/dist/esm/utils/assertSingleInstance.d.ts +2 -2
- package/dist/esm/utils/assertSingleInstance.js +5 -4
- package/dist/esm/utils/assertVersion.js +4 -1
- package/dist/esm/utils/debug.d.ts +1 -1
- package/dist/esm/utils/getGlobalObject.d.ts +6 -1
- package/dist/esm/utils/getGlobalObject.js +22 -6
- package/dist/esm/utils/isNpmPackage.d.ts +5 -7
- package/dist/esm/utils/isNpmPackage.js +15 -4
- package/dist/esm/utils/parseUrl.js +8 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -4
- package/package.json +26 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -33
- package/dist/cjs/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -19
- package/dist/cjs/utils/getFilePathAbsolute.js +0 -70
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.d.ts +0 -5
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -27
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.d.ts +0 -2
- package/dist/esm/node/runtime/renderPage/getPageAssets/assertClientEntryId.js +0 -16
- package/dist/esm/utils/getFilePathAbsolute.d.ts +0 -5
- package/dist/esm/utils/getFilePathAbsolute.js +0 -64
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/crawlPlusFiles.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { crawlPlusFiles };
|
|
2
|
-
import { assertPosixPath, assert, toPosixPath, assertWarning, scriptFileExtensionList, scriptFileExtensions,
|
|
2
|
+
import { assertPosixPath, assert, toPosixPath, assertWarning, scriptFileExtensionList, scriptFileExtensions, humanizeTime, assertIsSingleModuleInstance, assertIsNotProductionRuntime, isVersionOrAbove } from '../../../../utils.js';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import glob from 'fast-glob';
|
|
5
5
|
import { exec } from 'child_process';
|
|
6
6
|
import { promisify } from 'util';
|
|
7
7
|
import pc from '@brillout/picocolors';
|
|
8
8
|
const execA = promisify(exec);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
assertIsNotProductionRuntime();
|
|
10
|
+
assertIsSingleModuleInstance('crawlPlusFiles.ts');
|
|
11
|
+
let gitIsNotUsable = false;
|
|
12
12
|
async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
13
13
|
assertPosixPath(userRootDir);
|
|
14
14
|
assertPosixPath(outDirAbsoluteFilesystem);
|
|
@@ -43,14 +43,14 @@ async function crawlPlusFiles(userRootDir, outDirAbsoluteFilesystem, isDev) {
|
|
|
43
43
|
const plusFiles = files.map((p) => {
|
|
44
44
|
p = toPosixPath(p);
|
|
45
45
|
assert(!p.startsWith(userRootDir));
|
|
46
|
-
const
|
|
47
|
-
return {
|
|
46
|
+
const filePathAbsoluteUserRootDir = path.posix.join('/', p);
|
|
47
|
+
return { filePathAbsoluteUserRootDir };
|
|
48
48
|
});
|
|
49
49
|
return plusFiles;
|
|
50
50
|
}
|
|
51
51
|
// Same as fastGlob() but using `$ git ls-files`
|
|
52
52
|
async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
53
|
-
if (
|
|
53
|
+
if (gitIsNotUsable)
|
|
54
54
|
return null;
|
|
55
55
|
const ignoreAsPatterns = getIgnoreAsPatterns(outDirRelativeFromUserRootDir);
|
|
56
56
|
const ignoreAsFilterFn = getIgnoreAsFilterFn(outDirRelativeFromUserRootDir);
|
|
@@ -68,14 +68,14 @@ async function gitLsFiles(userRootDir, outDirRelativeFromUserRootDir) {
|
|
|
68
68
|
;
|
|
69
69
|
[files, filesDeleted] = await Promise.all([
|
|
70
70
|
// Main command
|
|
71
|
-
|
|
71
|
+
runCmd1(cmd, userRootDir),
|
|
72
72
|
// Get tracked by deleted files
|
|
73
|
-
|
|
73
|
+
runCmd1('git ls-files --deleted', userRootDir)
|
|
74
74
|
]);
|
|
75
75
|
}
|
|
76
76
|
catch (err) {
|
|
77
|
-
if (await
|
|
78
|
-
|
|
77
|
+
if (await isGitNotUsable(userRootDir)) {
|
|
78
|
+
gitIsNotUsable = true;
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
throw err;
|
|
@@ -119,24 +119,53 @@ function getIgnoreAsFilterFn(outDirRelativeFromUserRootDir) {
|
|
|
119
119
|
!file.includes('.telefunc.') &&
|
|
120
120
|
(outDirRelativeFromUserRootDir === null || !file.startsWith(`${outDirRelativeFromUserRootDir}/`));
|
|
121
121
|
}
|
|
122
|
-
// Whether Git is installed and whether
|
|
123
|
-
async function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
res = await
|
|
122
|
+
// Whether Git is installed and whether we can use it
|
|
123
|
+
async function isGitNotUsable(userRootDir) {
|
|
124
|
+
// Check Git version
|
|
125
|
+
{
|
|
126
|
+
const res = await runCmd2('git --version', userRootDir);
|
|
127
|
+
if ('err' in res)
|
|
128
|
+
return true;
|
|
129
|
+
let { stdout, stderr } = res;
|
|
130
|
+
assert(stderr === '');
|
|
131
|
+
const prefix = 'git version ';
|
|
132
|
+
assert(stdout.startsWith(prefix));
|
|
133
|
+
const gitVersion = stdout.slice(prefix.length);
|
|
134
|
+
// - Works with Git 2.43.1 but also (most certainly) with earlier versions.
|
|
135
|
+
// - We didn't bother test which is the earliest verision that works.
|
|
136
|
+
// - Git 2.32.0 doesn't seem to work: https://github.com/vikejs/vike/discussions/1549
|
|
137
|
+
// - Maybe it's because of StackBlitz: looking at the release notes, Git 2.32.0 should be working.
|
|
138
|
+
if (!isVersionOrAbove(gitVersion, '2.43.1'))
|
|
139
|
+
return true;
|
|
127
140
|
}
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
// Is userRootDir inside a Git repository?
|
|
142
|
+
{
|
|
143
|
+
const res = await runCmd2('git rev-parse --is-inside-work-tree', userRootDir);
|
|
144
|
+
if ('err' in res)
|
|
145
|
+
return true;
|
|
146
|
+
let { stdout, stderr } = res;
|
|
147
|
+
assert(stderr === '');
|
|
148
|
+
assert(stdout === 'true');
|
|
149
|
+
return false;
|
|
130
150
|
}
|
|
131
|
-
const { stdout, stderr } = res;
|
|
132
|
-
assert(stderr.toString().trim() === '');
|
|
133
|
-
assert(stdout.toString().trim() === 'true');
|
|
134
|
-
return false;
|
|
135
151
|
}
|
|
136
|
-
async function
|
|
137
|
-
const
|
|
152
|
+
async function runCmd1(cmd, cwd) {
|
|
153
|
+
const { stdout } = await execA(cmd, { cwd });
|
|
138
154
|
/* Not always true: https://github.com/vikejs/vike/issues/1440#issuecomment-1892831303
|
|
139
155
|
assert(res.stderr === '')
|
|
140
156
|
*/
|
|
141
|
-
return
|
|
157
|
+
return stdout.toString().split('\n').filter(Boolean);
|
|
158
|
+
}
|
|
159
|
+
async function runCmd2(cmd, cwd) {
|
|
160
|
+
let res;
|
|
161
|
+
try {
|
|
162
|
+
res = await execA(cmd, { cwd });
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
return { err };
|
|
166
|
+
}
|
|
167
|
+
let { stdout, stderr } = res;
|
|
168
|
+
stdout = stdout.toString().trim();
|
|
169
|
+
stderr = stderr.toString().trim();
|
|
170
|
+
return { stdout, stderr };
|
|
142
171
|
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ type LocationId = string & {
|
|
|
39
39
|
*
|
|
40
40
|
* The value `locationId` is always a user-land path, because Filesystem Routing/Inheritance only applies to the user-land (Vike never uses Filesystem Routing/Inheritance for `node_modules/**`).
|
|
41
41
|
*/
|
|
42
|
-
declare function getLocationId(
|
|
42
|
+
declare function getLocationId(filePathAbsoluteUserRootDir: string): LocationId;
|
|
43
43
|
/** Filesystem Routing: get the URL */
|
|
44
44
|
declare function getFilesystemRouteString(locationId: LocationId): string;
|
|
45
45
|
/**
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -16,10 +16,10 @@ import { assert, assertPosixPath, higherFirst } from '../../../../utils.js';
|
|
|
16
16
|
*/
|
|
17
17
|
function getLocationId(
|
|
18
18
|
// We always determine `locationId` from a real user-land file: the `locationId` for Vike extensions is the `locationId` of the the user's `+config.js` that extends the Vike extension.
|
|
19
|
-
|
|
20
|
-
assertPosixPath(
|
|
21
|
-
assert(
|
|
22
|
-
const locationId = removeFilename(
|
|
19
|
+
filePathAbsoluteUserRootDir) {
|
|
20
|
+
assertPosixPath(filePathAbsoluteUserRootDir);
|
|
21
|
+
assert(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
22
|
+
const locationId = removeFilename(filePathAbsoluteUserRootDir);
|
|
23
23
|
assertLocationId(locationId);
|
|
24
24
|
return locationId;
|
|
25
25
|
}
|
|
@@ -96,8 +96,8 @@ function removeDirectories(somePath, removeDirs) {
|
|
|
96
96
|
somePath = '/';
|
|
97
97
|
return somePath;
|
|
98
98
|
}
|
|
99
|
-
function removeFilename(
|
|
100
|
-
const filePathParts =
|
|
99
|
+
function removeFilename(filePathAbsoluteUserRootDir) {
|
|
100
|
+
const filePathParts = filePathAbsoluteUserRootDir.split('/');
|
|
101
101
|
{
|
|
102
102
|
const filename = filePathParts.slice(-1)[0];
|
|
103
103
|
assert(filename.includes('.'));
|
|
@@ -3,7 +3,7 @@ export { loadValueFile };
|
|
|
3
3
|
export { loadConfigFile };
|
|
4
4
|
export type { ImportedFilesLoaded };
|
|
5
5
|
export type { ConfigFile };
|
|
6
|
-
import type { FilePathResolved } from '../../../../../../shared/page-configs/
|
|
6
|
+
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
7
|
import type { InterfaceValueFile } from '../getVikeConfig.js';
|
|
8
8
|
type ImportedFilesLoaded = Record<string, Promise<Record<string, unknown>>>;
|
|
9
9
|
type ConfigFile = {
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
export { loadImportedFile };
|
|
3
3
|
export { loadValueFile };
|
|
4
4
|
export { loadConfigFile };
|
|
5
|
-
import {
|
|
5
|
+
import { assert, assertUsage, assertWarning, hasProp, assertIsNotProductionRuntime, isNpmPackageImport } from '../../../../utils.js';
|
|
6
6
|
import { transpileAndExecuteFile } from './transpileAndExecuteFile.js';
|
|
7
7
|
import { assertPlusFileExport } from '../../../../../../shared/page-configs/assertPlusFileExport.js';
|
|
8
8
|
import pc from '@brillout/picocolors';
|
|
9
9
|
import { parseImportData } from './transformFileImports.js';
|
|
10
10
|
import { getConfigFileExport } from '../getConfigFileExport.js';
|
|
11
11
|
import { assertImportPath, resolveImportPath } from './resolveImportPath.js';
|
|
12
|
+
import { getFilePathResolved } from '../../../../shared/getFilePath.js';
|
|
12
13
|
assertIsNotProductionRuntime();
|
|
13
14
|
// Load fake import
|
|
14
15
|
async function loadImportedFile(import_, userRootDir, importedFilesLoaded) {
|
|
@@ -58,21 +59,12 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
58
59
|
const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
|
|
59
60
|
const extendsConfigFiles = [];
|
|
60
61
|
extendsImportData.map((importData) => {
|
|
61
|
-
const { importPath:
|
|
62
|
+
const { importPath: importPathAbsolute } = importData;
|
|
62
63
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
63
64
|
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
64
|
-
warnUserLandExtension(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
|
|
68
|
-
const filePathAbsoluteVite = filePathRelativeToUserRootDir ?? importPath;
|
|
69
|
-
extendsConfigFiles.push({
|
|
70
|
-
filePathAbsoluteFilesystem,
|
|
71
|
-
filePathAbsoluteVite,
|
|
72
|
-
filePathRelativeToUserRootDir,
|
|
73
|
-
filePathToShowToUser: filePathAbsoluteVite,
|
|
74
|
-
importPathAbsolute: importPath
|
|
75
|
-
});
|
|
65
|
+
warnUserLandExtension(importPathAbsolute, configFilePath);
|
|
66
|
+
const filePath = getFilePathResolved({ filePathAbsoluteFilesystem, userRootDir, importPathAbsolute });
|
|
67
|
+
extendsConfigFiles.push(filePath);
|
|
76
68
|
});
|
|
77
69
|
const extendsConfigs = [];
|
|
78
70
|
await Promise.all(extendsConfigFiles.map(async (configFilePath) => {
|
|
@@ -83,19 +75,12 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
83
75
|
const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
|
|
84
76
|
return { extendsConfigs, extendsFilePaths };
|
|
85
77
|
}
|
|
86
|
-
function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir) {
|
|
87
|
-
assertPosixPath(filePathAbsoluteFilesystem);
|
|
88
|
-
assertPosixPath(userRootDir);
|
|
89
|
-
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
let filePathRelativeToUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
93
|
-
if (!filePathRelativeToUserRootDir.startsWith('/'))
|
|
94
|
-
filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
|
|
95
|
-
return filePathRelativeToUserRootDir;
|
|
96
|
-
}
|
|
97
78
|
function warnUserLandExtension(importPath, configFilePath) {
|
|
98
|
-
|
|
79
|
+
// We preserve this feature because we may need it for eject
|
|
80
|
+
assertWarning(isNpmPackageImport(importPath, {
|
|
81
|
+
// Vike config files don't support path aliases. (If they do one day, then Vike will/should be able to resolve path aliases.)
|
|
82
|
+
cannotBePathAlias: true
|
|
83
|
+
}) || importPath.includes('/node_modules/'), `${configFilePath.filePathToShowToUser} uses ${pc.cyan('extends')} to inherit from ${pc.cyan(importPath)} which is a user-land file: this is experimental and may be remove at any time. Reach out to a maintainer if you need this.`, { onlyOnce: true });
|
|
99
84
|
}
|
|
100
85
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
101
86
|
const { filePathToShowToUser } = configFilePath;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ export { resolveImport };
|
|
|
2
2
|
export { resolveImportPath };
|
|
3
3
|
export { assertImportPath };
|
|
4
4
|
export { clearFilesEnvMap };
|
|
5
|
-
import type { ConfigEnvInternal, DefinedAtFileFullInfo
|
|
5
|
+
import type { ConfigEnvInternal, DefinedAtFileFullInfo } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
6
6
|
import { type ImportData } from './transformFileImports.js';
|
|
7
|
+
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
8
|
declare function resolveImport(configValue: unknown, importerFilePath: FilePathResolved, userRootDir: string, configEnv: ConfigEnvInternal, configName: string): null | (DefinedAtFileFullInfo & {
|
|
8
9
|
fileExportName: string;
|
|
9
10
|
});
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js
CHANGED
|
@@ -6,6 +6,7 @@ import pc from '@brillout/picocolors';
|
|
|
6
6
|
import { assert, assertPosixPath, assertUsage, deepEqual, requireResolve } from '../../../../utils.js';
|
|
7
7
|
import { parseImportData } from './transformFileImports.js';
|
|
8
8
|
import path from 'path';
|
|
9
|
+
import { getFilePathResolved, getFilePathUnresolved } from '../../../../shared/getFilePath.js';
|
|
9
10
|
const filesEnvMap = new Map();
|
|
10
11
|
function resolveImport(configValue, importerFilePath, userRootDir, configEnv, configName) {
|
|
11
12
|
if (typeof configValue !== 'string')
|
|
@@ -17,49 +18,44 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
17
18
|
const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
|
|
18
19
|
assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
|
|
19
20
|
const fileExportPathToShowToUser = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
21
|
+
let filePath;
|
|
20
22
|
if (importPath.startsWith('.')) {
|
|
21
23
|
// We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
|
|
22
24
|
// ```
|
|
23
25
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
24
26
|
// ```
|
|
25
27
|
assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
filePathAbsoluteFilesystem,
|
|
29
|
-
filePathRelativeToUserRootDir,
|
|
30
|
-
filePathAbsoluteVite: filePathRelativeToUserRootDir,
|
|
31
|
-
filePathToShowToUser: filePathRelativeToUserRootDir,
|
|
32
|
-
importPathAbsolute: null
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
...filePath,
|
|
36
|
-
fileExportName: exportName,
|
|
37
|
-
fileExportPathToShowToUser
|
|
38
|
-
};
|
|
28
|
+
const filePathAbsoluteUserRootDir = resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
|
|
29
|
+
filePath = getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir });
|
|
39
30
|
}
|
|
40
31
|
else {
|
|
41
32
|
// importPath can be:
|
|
42
33
|
// - an npm package import
|
|
43
34
|
// - a path alias
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
35
|
+
if (filePathAbsoluteFilesystem) {
|
|
36
|
+
filePath = getFilePathResolved({
|
|
37
|
+
userRootDir,
|
|
38
|
+
filePathAbsoluteFilesystem,
|
|
39
|
+
importPathAbsolute: importPath
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
filePath = getFilePathUnresolved({
|
|
44
|
+
importPathAbsolute: importPath
|
|
45
|
+
});
|
|
46
|
+
}
|
|
56
47
|
}
|
|
48
|
+
return {
|
|
49
|
+
...filePath,
|
|
50
|
+
fileExportName: exportName,
|
|
51
|
+
fileExportPathToShowToUser
|
|
52
|
+
};
|
|
57
53
|
}
|
|
58
|
-
function
|
|
54
|
+
function resolveImportPath_absoluteUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
|
|
59
55
|
assertPosixPath(userRootDir);
|
|
60
|
-
let
|
|
56
|
+
let filePathAbsoluteUserRootDir;
|
|
61
57
|
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
62
|
-
|
|
58
|
+
filePathAbsoluteUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
|
|
63
59
|
}
|
|
64
60
|
else {
|
|
65
61
|
assertUsage(false, `${configFilePath.filePathToShowToUser} imports from a relative path ${pc.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
|
|
@@ -68,20 +64,21 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, imp
|
|
|
68
64
|
// assert(filePathAbsoluteFilesystem.startsWith('/'))
|
|
69
65
|
// filePath = `/@fs${filePathAbsoluteFilesystem}`
|
|
70
66
|
// /*/
|
|
71
|
-
//
|
|
72
|
-
// assert(
|
|
73
|
-
//
|
|
67
|
+
// filePathAbsoluteUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
|
|
68
|
+
// assert(filePathAbsoluteUserRootDir.startsWith('../'))
|
|
69
|
+
// filePathAbsoluteUserRootDir = '/' + filePathAbsoluteUserRootDir
|
|
74
70
|
// //*/
|
|
75
71
|
}
|
|
76
|
-
assertPosixPath(
|
|
77
|
-
assert(
|
|
78
|
-
return
|
|
72
|
+
assertPosixPath(filePathAbsoluteUserRootDir);
|
|
73
|
+
assert(filePathAbsoluteUserRootDir.startsWith('/'));
|
|
74
|
+
return filePathAbsoluteUserRootDir;
|
|
79
75
|
}
|
|
80
76
|
function resolveImportPath(importData, importerFilePath) {
|
|
81
77
|
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
82
78
|
assertPosixPath(importerFilePathAbsolute);
|
|
83
79
|
const cwd = path.posix.dirname(importerFilePathAbsolute);
|
|
84
|
-
// We can't use import.meta.resolve() as of Junary 2023 (and probably for a lot longer)
|
|
80
|
+
// We can't use import.meta.resolve() as of Junary 2023 (and probably for a lot longer)
|
|
81
|
+
// https://stackoverflow.com/questions/54977743/do-require-resolve-for-es-modules#comment137174954_62272600:~:text=But%20the%20argument%20parent%20(aka%20cwd)%20still%20requires%20a%20flag
|
|
85
82
|
// filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
|
|
86
83
|
const filePathAbsoluteFilesystem = requireResolve(importData.importPath, cwd);
|
|
87
84
|
return filePathAbsoluteFilesystem;
|
|
@@ -3,7 +3,7 @@ export { getConfigBuildErrorFormatted };
|
|
|
3
3
|
export { getConfigExecutionErrorIntroMsg };
|
|
4
4
|
export { isTmpFile };
|
|
5
5
|
import 'source-map-support/register.js';
|
|
6
|
-
import type { FilePathResolved } from '../../../../../../shared/page-configs/
|
|
6
|
+
import type { FilePathResolved } from '../../../../../../shared/page-configs/FilePath.js';
|
|
7
7
|
declare function transpileAndExecuteFile(filePath: FilePathResolved, userRootDir: string, isConfigFile: boolean | 'is-extension-config'): Promise<{
|
|
8
8
|
fileExports: Record<string, unknown>;
|
|
9
9
|
}>;
|
|
@@ -14,13 +14,12 @@ import 'source-map-support/register.js';
|
|
|
14
14
|
assertIsNotProductionRuntime();
|
|
15
15
|
const debug = createDebugger('vike:pointer-imports');
|
|
16
16
|
async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
17
|
-
const { filePathAbsoluteFilesystem } = filePath;
|
|
17
|
+
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
18
18
|
const fileExtension = getFileExtension(filePathAbsoluteFilesystem);
|
|
19
|
-
|
|
20
|
-
assertUsage(isJavaScriptFile(filePathAbsoluteFilesystem), `${filePathToShowToUser2} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
19
|
+
assertUsage(isJavaScriptFile(filePathAbsoluteFilesystem), `${filePathToShowToUserResolved} has file extension .${fileExtension} but a config file can only be a JavaScript/TypeScript file`);
|
|
21
20
|
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
22
21
|
if (isHeader) {
|
|
23
|
-
assertWarning(false, `${pc.cyan('.h.js')} files are deprecated: simply renaming ${
|
|
22
|
+
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 });
|
|
24
23
|
}
|
|
25
24
|
if (isConfigFile === 'is-extension-config' && !isHeader && fileExtension.endsWith('js')) {
|
|
26
25
|
// This doesn't track dependencies => we should never use this for user land configs
|
|
@@ -35,28 +34,27 @@ async function transpileAndExecuteFile(filePath, userRootDir, isConfigFile) {
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
async function transpileFile(filePath, transformImports, userRootDir) {
|
|
38
|
-
const
|
|
39
|
-
const { filePathAbsoluteFilesystem } = filePath;
|
|
37
|
+
const { filePathAbsoluteFilesystem, filePathToShowToUserResolved } = filePath;
|
|
40
38
|
assertPosixPath(filePathAbsoluteFilesystem);
|
|
41
39
|
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
42
40
|
if (debug.isEnabled)
|
|
43
|
-
debug('transpile',
|
|
41
|
+
debug('transpile', filePathToShowToUserResolved);
|
|
44
42
|
let { code, pointerImports } = await transpileWithEsbuild(filePath, userRootDir, transformImports);
|
|
45
43
|
if (debug.isEnabled)
|
|
46
|
-
debug(`code, post esbuild (${
|
|
44
|
+
debug(`code, post esbuild (${filePathToShowToUserResolved})`, code);
|
|
47
45
|
let isImportTransformed = false;
|
|
48
46
|
if (transformImports) {
|
|
49
|
-
const codeMod = transformFileImports(code,
|
|
47
|
+
const codeMod = transformFileImports(code, filePathToShowToUserResolved, pointerImports);
|
|
50
48
|
if (codeMod) {
|
|
51
49
|
code = codeMod;
|
|
52
50
|
isImportTransformed = true;
|
|
53
51
|
if (debug.isEnabled)
|
|
54
|
-
debug(`code, post transformImports() (${
|
|
52
|
+
debug(`code, post transformImports() (${filePathToShowToUserResolved})`, code);
|
|
55
53
|
}
|
|
56
54
|
}
|
|
57
55
|
if (!isImportTransformed) {
|
|
58
56
|
if (debug.isEnabled)
|
|
59
|
-
debug(`code, no transformImports() (${
|
|
57
|
+
debug(`code, no transformImports() (${filePathToShowToUserResolved})`);
|
|
60
58
|
}
|
|
61
59
|
return code;
|
|
62
60
|
}
|
|
@@ -72,7 +70,7 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
72
70
|
outfile: path.posix.join(
|
|
73
71
|
// Needed for correct inline source map
|
|
74
72
|
entryFileDir,
|
|
75
|
-
// `write: false` => no file is actually
|
|
73
|
+
// `write: false` => no file is actually emitted
|
|
76
74
|
'NEVER_EMITTED.js'),
|
|
77
75
|
logLevel: 'silent',
|
|
78
76
|
format: 'esm',
|
|
@@ -104,10 +102,10 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
104
102
|
return;
|
|
105
103
|
if (args.pluginData?.[useEsbuildResolver])
|
|
106
104
|
return;
|
|
107
|
-
const isImportAbsolute = !args.path.startsWith('.');
|
|
108
105
|
const { path, ...opts } = args;
|
|
109
106
|
opts.pluginData = { [useEsbuildResolver]: true };
|
|
110
107
|
const resolved = await build.resolve(path, opts);
|
|
108
|
+
resolved.path = toPosixPath(resolved.path);
|
|
111
109
|
// vike-{react,vue,solid} follow the convention that their config export resolves to a file named +config.js
|
|
112
110
|
// - This is temporary, see comment below.
|
|
113
111
|
const isVikeExtensionConfigImport = resolved.path.endsWith('+config.js');
|
|
@@ -122,14 +120,15 @@ async function transpileWithEsbuild(filePath, userRootDir, transformImports) {
|
|
|
122
120
|
// - For example if esbuild cannot resolve a path alias while Vite can.
|
|
123
121
|
// - When tsconfig.js#compilerOptions.paths is set, then esbuild is able to resolve the path alias.
|
|
124
122
|
resolved.errors.length > 0;
|
|
125
|
-
pointerImports_[
|
|
123
|
+
pointerImports_[resolved.path] = isPointerImport;
|
|
124
|
+
assertPosixPath(resolved.path);
|
|
126
125
|
const isExternal = isPointerImport ||
|
|
127
|
-
// npm package imports that aren't pointer imports (e.g. Vite plugin
|
|
128
|
-
|
|
126
|
+
// npm package imports that aren't pointer imports (e.g. importing a Vite plugin)
|
|
127
|
+
resolved.path.includes('/node_modules/');
|
|
129
128
|
if (debug.isEnabled)
|
|
130
129
|
debug('onResolved()', { args, resolved, isPointerImport, isExternal });
|
|
131
130
|
if (isExternal) {
|
|
132
|
-
return { external: true, path:
|
|
131
|
+
return { external: true, path: resolved.path };
|
|
133
132
|
}
|
|
134
133
|
else {
|
|
135
134
|
return resolved;
|
|
@@ -292,19 +291,12 @@ function triggerPrepareStackTrace(err) {
|
|
|
292
291
|
}
|
|
293
292
|
}
|
|
294
293
|
function getErrIntroMsg(operation, filePath) {
|
|
295
|
-
const
|
|
294
|
+
const { filePathToShowToUserResolved } = filePath;
|
|
296
295
|
const msg = [
|
|
297
296
|
// prettier ignore
|
|
298
297
|
pc.red(`Failed to ${operation}`),
|
|
299
|
-
pc.bold(pc.red(
|
|
298
|
+
pc.bold(pc.red(filePathToShowToUserResolved)),
|
|
300
299
|
pc.red(`because:`)
|
|
301
300
|
].join(' ');
|
|
302
301
|
return msg;
|
|
303
302
|
}
|
|
304
|
-
/** `filePath.filePathToShowToUser` may show the import path of a package, use `filePathToShowToUser2` instead always show a file path instead. */
|
|
305
|
-
function getFilePathToShowToUser2(filePath) {
|
|
306
|
-
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
307
|
-
const filePathToShowToUser2 = filePathRelativeToUserRootDir || filePathAbsoluteFilesystem;
|
|
308
|
-
assert(filePathToShowToUser2);
|
|
309
|
-
return filePathToShowToUser2;
|
|
310
|
-
}
|
|
@@ -5,9 +5,10 @@ export { isVikeConfigFile };
|
|
|
5
5
|
export { isV1Design };
|
|
6
6
|
export type { VikeConfigObject };
|
|
7
7
|
export type { InterfaceValueFile };
|
|
8
|
-
import type { PageConfigGlobalBuildTime, PageConfigBuildTime
|
|
8
|
+
import type { PageConfigGlobalBuildTime, PageConfigBuildTime } from '../../../../../shared/page-configs/PageConfig.js';
|
|
9
9
|
import { type LocationId } from './getVikeConfig/filesystemRouting.js';
|
|
10
10
|
import type { ResolvedConfig } from 'vite';
|
|
11
|
+
import type { FilePathResolved } from '../../../../../shared/page-configs/FilePath.js';
|
|
11
12
|
type InterfaceFileCommons = {
|
|
12
13
|
locationId: LocationId;
|
|
13
14
|
filePath: FilePathResolved;
|
|
@@ -28,6 +29,6 @@ type VikeConfigObject = {
|
|
|
28
29
|
};
|
|
29
30
|
declare const vikeConfigDependencies: Set<string>;
|
|
30
31
|
declare function reloadVikeConfig(userRootDir: string, outDirRoot: string): void;
|
|
31
|
-
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, tolerateInvalidConfig?:
|
|
32
|
+
declare function getVikeConfig(config: ResolvedConfig, isDev: boolean, tolerateInvalidConfig?: true): Promise<VikeConfigObject>;
|
|
32
33
|
declare function isV1Design(config: ResolvedConfig, isDev: boolean): Promise<boolean>;
|
|
33
34
|
declare function isVikeConfigFile(filePath: string): boolean;
|
|
@@ -19,7 +19,7 @@ import { crawlPlusFiles } from './getVikeConfig/crawlPlusFiles.js';
|
|
|
19
19
|
import { getConfigFileExport } from './getConfigFileExport.js';
|
|
20
20
|
import { loadConfigFile, loadImportedFile, loadValueFile } from './getVikeConfig/loadFileAtConfigTime.js';
|
|
21
21
|
import { clearFilesEnvMap, resolveImport } from './getVikeConfig/resolveImportPath.js';
|
|
22
|
-
import {
|
|
22
|
+
import { getFilePathResolved } from '../../../shared/getFilePath.js';
|
|
23
23
|
assertIsNotProductionRuntime();
|
|
24
24
|
let devServerIsCorrupt = false;
|
|
25
25
|
let wasConfigInvalid = null;
|
|
@@ -62,7 +62,7 @@ async function handleReloadSideEffects() {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
async function getVikeConfig(config, isDev, tolerateInvalidConfig
|
|
65
|
+
async function getVikeConfig(config, isDev, tolerateInvalidConfig) {
|
|
66
66
|
const { outDirRoot } = getOutDirs(config);
|
|
67
67
|
const userRootDir = config.root;
|
|
68
68
|
if (!vikeConfigPromise) {
|
|
@@ -92,11 +92,11 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
92
92
|
await Promise.all([
|
|
93
93
|
// Config files
|
|
94
94
|
...configFiles.map(async (filePath) => {
|
|
95
|
-
const {
|
|
96
|
-
assert(
|
|
95
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
96
|
+
assert(filePathAbsoluteUserRootDir);
|
|
97
97
|
const { configFile, extendsConfigs } = await loadConfigFile(filePath, userRootDir, [], false);
|
|
98
|
-
assert(filePath.
|
|
99
|
-
const locationId = getLocationId(
|
|
98
|
+
assert(filePath.filePathAbsoluteUserRootDir);
|
|
99
|
+
const locationId = getLocationId(filePathAbsoluteUserRootDir);
|
|
100
100
|
const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
|
|
101
101
|
interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
|
|
102
102
|
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
@@ -145,11 +145,11 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
145
145
|
}),
|
|
146
146
|
// Value files
|
|
147
147
|
...valueFiles.map(async (filePath) => {
|
|
148
|
-
const {
|
|
149
|
-
assert(
|
|
150
|
-
const configName = getConfigName(
|
|
148
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
149
|
+
assert(filePathAbsoluteUserRootDir);
|
|
150
|
+
const configName = getConfigName(filePathAbsoluteUserRootDir);
|
|
151
151
|
assert(configName);
|
|
152
|
-
const locationId = getLocationId(
|
|
152
|
+
const locationId = getLocationId(filePathAbsoluteUserRootDir);
|
|
153
153
|
const interfaceFile = {
|
|
154
154
|
locationId,
|
|
155
155
|
filePath,
|
|
@@ -348,9 +348,9 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
348
348
|
const interfaceFilesGlobalPaths = [];
|
|
349
349
|
objectEntries(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
350
350
|
assert(isGlobalLocation(locationId, locationIds));
|
|
351
|
-
interfaceFiles.forEach(({ filePath: {
|
|
352
|
-
if (
|
|
353
|
-
interfaceFilesGlobalPaths.push(
|
|
351
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
352
|
+
if (filePathAbsoluteUserRootDir) {
|
|
353
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
354
354
|
}
|
|
355
355
|
});
|
|
356
356
|
});
|
|
@@ -459,10 +459,10 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
|
|
|
459
459
|
}
|
|
460
460
|
function makeOrderDeterministic(interfaceFile1, interfaceFile2) {
|
|
461
461
|
return lowerFirst((interfaceFile) => {
|
|
462
|
-
const {
|
|
462
|
+
const { filePathAbsoluteUserRootDir } = interfaceFile.filePath;
|
|
463
463
|
assert(isInterfaceFileUserLand(interfaceFile));
|
|
464
|
-
assert(
|
|
465
|
-
return
|
|
464
|
+
assert(filePathAbsoluteUserRootDir);
|
|
465
|
+
return filePathAbsoluteUserRootDir.length;
|
|
466
466
|
})(interfaceFile1, interfaceFile2);
|
|
467
467
|
}
|
|
468
468
|
function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden, configName) {
|
|
@@ -536,6 +536,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
536
536
|
configName !== 'extends') {
|
|
537
537
|
if (import_.filePathAbsoluteFilesystem) {
|
|
538
538
|
assert(hasProp(import_, 'filePathAbsoluteFilesystem', 'string')); // Help TS
|
|
539
|
+
assert(hasProp(import_, 'filePathToShowToUserResolved', 'string')); // Help TS
|
|
539
540
|
const fileExport = await loadImportedFile(import_, userRootDir, importedFilesLoaded);
|
|
540
541
|
configValueSource.value = fileExport;
|
|
541
542
|
}
|
|
@@ -739,7 +740,7 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
739
740
|
}
|
|
740
741
|
async function findPlusFiles(userRootDir, outDirRoot, isDev) {
|
|
741
742
|
const files = await crawlPlusFiles(userRootDir, outDirRoot, isDev);
|
|
742
|
-
const plusFiles = files.map(({
|
|
743
|
+
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => getFilePathResolved({ filePathAbsoluteUserRootDir, userRootDir }));
|
|
743
744
|
return plusFiles;
|
|
744
745
|
}
|
|
745
746
|
function getConfigName(filePath) {
|
|
@@ -829,9 +830,9 @@ function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName)
|
|
|
829
830
|
const configDefinedAt = getConfigDefinedAtString('Config', configName, configFilesystemRoutingRoot);
|
|
830
831
|
assertUsage(typeof value === 'string', `${configDefinedAt} should be a string`);
|
|
831
832
|
assertUsage(value.startsWith('/'), `${configDefinedAt} is ${pc.cyan(value)} but it should start with a leading slash ${pc.cyan('/')}`);
|
|
832
|
-
const {
|
|
833
|
-
assert(
|
|
834
|
-
const before = getFilesystemRouteString(getLocationId(
|
|
833
|
+
const { filePathAbsoluteUserRootDir } = configFilesystemRoutingRoot.definedAt;
|
|
834
|
+
assert(filePathAbsoluteUserRootDir);
|
|
835
|
+
const before = getFilesystemRouteString(getLocationId(filePathAbsoluteUserRootDir));
|
|
835
836
|
const after = value;
|
|
836
837
|
const filesystemRoutingRootEffect = { before, after };
|
|
837
838
|
return { filesystemRoutingRootEffect, filesystemRoutingRootDefinedAt: configDefinedAt };
|
|
@@ -1006,7 +1007,11 @@ function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
|
1006
1007
|
// Sort after whether the config value was defined by an npm package
|
|
1007
1008
|
.sort(makeFirst(([, [source]]) => {
|
|
1008
1009
|
const { importPathAbsolute } = source.definedAt;
|
|
1009
|
-
return !!importPathAbsolute &&
|
|
1010
|
+
return (!!importPathAbsolute &&
|
|
1011
|
+
isNpmPackageImport(importPathAbsolute, {
|
|
1012
|
+
// Vike config files don't support path aliases. (If they do one day, then Vike will/should be able to resolve path aliases.)
|
|
1013
|
+
cannotBePathAlias: true
|
|
1014
|
+
}));
|
|
1010
1015
|
}))
|
|
1011
1016
|
// Sort after the filesystem inheritance of the config value
|
|
1012
1017
|
.sort(([, [source1]], [, [source2]]) => reverse(sortAfterInheritanceOrder(source1.locationId, source2.locationId, locationIdPage))));
|