vike 0.4.144-commit-e40e9b1 → 0.4.144-commit-68c730d
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/devConfig/determineOptimizeDeps.js +4 -4
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +47 -47
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +12 -12
- package/dist/cjs/utils/getFilePathAbsolute.js +11 -11
- package/dist/cjs/utils/parseUrl.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +4 -4
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +47 -47
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +12 -12
- package/dist/esm/shared/page-configs/PageConfig.d.ts +2 -2
- package/dist/esm/utils/getFilePathAbsolute.d.ts +1 -1
- package/dist/esm/utils/getFilePathAbsolute.js +11 -11
- package/dist/esm/utils/parseUrl.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -2
|
@@ -41,13 +41,13 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
41
41
|
if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
|
|
42
42
|
return;
|
|
43
43
|
if (definedAtInfo.filePathRelativeToUserRootDir !== null) {
|
|
44
|
-
const {
|
|
45
|
-
(0, utils_js_1.assert)(
|
|
44
|
+
const { filePathAbsoluteFilesystem } = definedAtInfo;
|
|
45
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
46
46
|
// Surprisingly Vite expects entries to be absolute paths
|
|
47
|
-
entries.push(
|
|
47
|
+
entries.push(filePathAbsoluteFilesystem);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
// Adding definedAtInfo.
|
|
50
|
+
// Adding definedAtInfo.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
51
51
|
const { importPathAbsolute } = definedAtInfo;
|
|
52
52
|
(0, utils_js_1.assert)(importPathAbsolute);
|
|
53
53
|
// We need to differentiate between npm package imports and path aliases.
|
|
@@ -117,8 +117,8 @@ function handleHotUpdate(ctx, config, configVike) {
|
|
|
117
117
|
return virtualModules;
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
-
function isVikeConfigModule(
|
|
121
|
-
return getVikeConfig_js_1.vikeConfigDependencies.has(
|
|
120
|
+
function isVikeConfigModule(filePathAbsoluteFilesystem) {
|
|
121
|
+
return getVikeConfig_js_1.vikeConfigDependencies.has(filePathAbsoluteFilesystem);
|
|
122
122
|
}
|
|
123
123
|
function reloadConfig(filePath, config, configVike, op) {
|
|
124
124
|
{
|
|
@@ -9,7 +9,7 @@ if (f.filePathRelativeToUserRootDir === null) {
|
|
|
9
9
|
}
|
|
10
10
|
//*/
|
|
11
11
|
function getFilePathToShowToUser(filePath) {
|
|
12
|
-
const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.
|
|
12
|
+
const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsoluteFilesystem;
|
|
13
13
|
(0, utils_js_1.assert)(filePathToShowToUser);
|
|
14
14
|
return filePathToShowToUser;
|
|
15
15
|
}
|
|
@@ -86,9 +86,9 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
86
86
|
});
|
|
87
87
|
let interfaceFilesByLocationId = {};
|
|
88
88
|
// Config files
|
|
89
|
-
await Promise.all(configFiles.map(async ({
|
|
89
|
+
await Promise.all(configFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
|
|
90
90
|
const configFilePath = {
|
|
91
|
-
|
|
91
|
+
filePathAbsoluteFilesystem: filePathAbsoluteFilesystem,
|
|
92
92
|
filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
|
|
93
93
|
importPathAbsolute: null
|
|
94
94
|
};
|
|
@@ -103,13 +103,13 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
103
103
|
});
|
|
104
104
|
}));
|
|
105
105
|
// Value files
|
|
106
|
-
await Promise.all(valueFiles.map(async ({
|
|
106
|
+
await Promise.all(valueFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
|
|
107
107
|
const configName = getConfigName(filePathRelativeToUserRootDir);
|
|
108
108
|
(0, utils_js_1.assert)(configName);
|
|
109
109
|
const interfaceFile = {
|
|
110
110
|
filePath: {
|
|
111
111
|
filePathRelativeToUserRootDir,
|
|
112
|
-
|
|
112
|
+
filePathAbsoluteFilesystem,
|
|
113
113
|
importPathAbsolute: null
|
|
114
114
|
},
|
|
115
115
|
configMap: {
|
|
@@ -551,20 +551,20 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
551
551
|
if (!importData)
|
|
552
552
|
return null;
|
|
553
553
|
const { importPath, exportName } = importData;
|
|
554
|
-
const
|
|
555
|
-
assertFileEnv(
|
|
554
|
+
const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
|
|
555
|
+
assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
|
|
556
556
|
const fileExportPath = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
557
557
|
if (importPath.startsWith('.')) {
|
|
558
558
|
// We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
|
|
559
559
|
// ```
|
|
560
560
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
561
561
|
// ```
|
|
562
|
-
assertImportPath(
|
|
563
|
-
const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(
|
|
562
|
+
assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
|
|
563
|
+
const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
|
|
564
564
|
return {
|
|
565
565
|
exportName,
|
|
566
566
|
fileExportPath,
|
|
567
|
-
|
|
567
|
+
filePathAbsoluteFilesystem,
|
|
568
568
|
filePathRelativeToUserRootDir,
|
|
569
569
|
importPathAbsolute: null
|
|
570
570
|
};
|
|
@@ -576,26 +576,26 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
576
576
|
return {
|
|
577
577
|
exportName,
|
|
578
578
|
fileExportPath,
|
|
579
|
-
|
|
579
|
+
filePathAbsoluteFilesystem,
|
|
580
580
|
filePathRelativeToUserRootDir: null,
|
|
581
581
|
importPathAbsolute: importPath
|
|
582
582
|
};
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
|
-
function resolveImportPath_relativeToUserRootDir(
|
|
585
|
+
function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
|
|
586
586
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
587
587
|
let filePathRelativeToUserRootDir;
|
|
588
|
-
if (
|
|
589
|
-
filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(
|
|
588
|
+
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
589
|
+
filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
|
|
590
590
|
}
|
|
591
591
|
else {
|
|
592
592
|
(0, utils_js_1.assertUsage)(false, `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath)} imports from a relative path ${picocolors_1.default.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`);
|
|
593
593
|
// None of the following works. Seems to be a Vite bug?
|
|
594
594
|
// /*
|
|
595
|
-
// assert(
|
|
596
|
-
// filePath = `/@fs${
|
|
595
|
+
// assert(filePathAbsoluteFilesystem.startsWith('/'))
|
|
596
|
+
// filePath = `/@fs${filePathAbsoluteFilesystem}`
|
|
597
597
|
// /*/
|
|
598
|
-
// filePathRelativeToUserRootDir = path.posix.relative(userRootDir,
|
|
598
|
+
// filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
|
|
599
599
|
// assert(filePathRelativeToUserRootDir.startsWith('../'))
|
|
600
600
|
// filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir
|
|
601
601
|
// //*/
|
|
@@ -604,11 +604,11 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, c
|
|
|
604
604
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir.startsWith('/'));
|
|
605
605
|
return filePathRelativeToUserRootDir;
|
|
606
606
|
}
|
|
607
|
-
function getVitePathFromAbsolutePath(
|
|
608
|
-
(0, utils_js_1.assertPosixPath)(
|
|
607
|
+
function getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, root) {
|
|
608
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
609
609
|
(0, utils_js_1.assertPosixPath)(root);
|
|
610
|
-
(0, utils_js_1.assert)(
|
|
611
|
-
let vitePath = path_1.default.posix.relative(root,
|
|
610
|
+
(0, utils_js_1.assert)(filePathAbsoluteFilesystem.startsWith(root));
|
|
611
|
+
let vitePath = path_1.default.posix.relative(root, filePathAbsoluteFilesystem);
|
|
612
612
|
(0, utils_js_1.assert)(!vitePath.startsWith('/') && !vitePath.startsWith('.'));
|
|
613
613
|
vitePath = '/' + vitePath;
|
|
614
614
|
return vitePath;
|
|
@@ -761,8 +761,8 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
|
|
|
761
761
|
const plusFiles = result.map((p) => {
|
|
762
762
|
p = (0, utils_js_1.toPosixPath)(p);
|
|
763
763
|
const filePathRelativeToUserRootDir = path_1.default.posix.join('/', p);
|
|
764
|
-
const
|
|
765
|
-
return { filePathRelativeToUserRootDir,
|
|
764
|
+
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, p);
|
|
765
|
+
return { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem };
|
|
766
766
|
});
|
|
767
767
|
extensions.forEach((extension) => {
|
|
768
768
|
extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
|
|
@@ -774,7 +774,7 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
|
|
|
774
774
|
const { importPath, filePath } = pageConfigDistFile;
|
|
775
775
|
plusFiles.push({
|
|
776
776
|
filePathRelativeToUserRootDir: importPath,
|
|
777
|
-
|
|
777
|
+
filePathAbsoluteFilesystem: filePath
|
|
778
778
|
});
|
|
779
779
|
});
|
|
780
780
|
});
|
|
@@ -804,12 +804,12 @@ function assertNoUnexpectedPlusSign(filePath, fileName) {
|
|
|
804
804
|
(0, utils_js_1.assertUsage)(!fileName.slice(1).includes('+'), `Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`);
|
|
805
805
|
}
|
|
806
806
|
async function loadConfigFile(configFilePath, userRootDir, visited) {
|
|
807
|
-
const {
|
|
808
|
-
assertNoInfiniteLoop(visited,
|
|
807
|
+
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
808
|
+
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
809
809
|
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(configFilePath, false, userRootDir);
|
|
810
810
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
|
|
811
811
|
...visited,
|
|
812
|
-
|
|
812
|
+
filePathAbsoluteFilesystem
|
|
813
813
|
]);
|
|
814
814
|
const configFile = {
|
|
815
815
|
fileExports,
|
|
@@ -818,13 +818,13 @@ async function loadConfigFile(configFilePath, userRootDir, visited) {
|
|
|
818
818
|
};
|
|
819
819
|
return { configFile, extendsConfigs };
|
|
820
820
|
}
|
|
821
|
-
function assertNoInfiniteLoop(visited,
|
|
822
|
-
const idx = visited.indexOf(
|
|
821
|
+
function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
|
|
822
|
+
const idx = visited.indexOf(filePathAbsoluteFilesystem);
|
|
823
823
|
if (idx === -1)
|
|
824
824
|
return;
|
|
825
825
|
const loop = visited.slice(idx);
|
|
826
|
-
(0, utils_js_1.assert)(loop[0] ===
|
|
827
|
-
(0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop,
|
|
826
|
+
(0, utils_js_1.assert)(loop[0] === filePathAbsoluteFilesystem);
|
|
827
|
+
(0, utils_js_1.assertUsage)(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
|
|
828
828
|
}
|
|
829
829
|
async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
|
|
830
830
|
const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
|
|
@@ -833,14 +833,14 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
833
833
|
const { importPath: importPath } = importData;
|
|
834
834
|
// TODO
|
|
835
835
|
// - validate extends configs
|
|
836
|
-
const
|
|
837
|
-
assertImportPath(
|
|
838
|
-
assertExtendsImportPath(importPath,
|
|
836
|
+
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
837
|
+
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
838
|
+
assertExtendsImportPath(importPath, filePathAbsoluteFilesystem, configFilePath);
|
|
839
839
|
// - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
|
|
840
|
-
// - Using importPath would be visually nicer but it's ambigous => we rather pick
|
|
841
|
-
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(
|
|
840
|
+
// - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
|
|
841
|
+
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
|
|
842
842
|
extendsConfigFiles.push({
|
|
843
|
-
|
|
843
|
+
filePathAbsoluteFilesystem,
|
|
844
844
|
// TODO: fix type cast
|
|
845
845
|
filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
|
|
846
846
|
importPathAbsolute: importPath
|
|
@@ -852,16 +852,16 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
852
852
|
extendsConfigs.push(result.configFile);
|
|
853
853
|
extendsConfigs.push(...result.extendsConfigs);
|
|
854
854
|
}));
|
|
855
|
-
const extendsFilePaths = extendsConfigFiles.map((f) => f.
|
|
855
|
+
const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
|
|
856
856
|
return { extendsConfigs, extendsFilePaths };
|
|
857
857
|
}
|
|
858
|
-
function determineFilePathRelativeToUserDir(
|
|
859
|
-
(0, utils_js_1.assertPosixPath)(
|
|
858
|
+
function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir) {
|
|
859
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
860
860
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
861
|
-
if (!
|
|
861
|
+
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
862
862
|
return null;
|
|
863
863
|
}
|
|
864
|
-
let filePathRelativeToUserRootDir =
|
|
864
|
+
let filePathRelativeToUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
865
865
|
if (!filePathRelativeToUserRootDir.startsWith('/'))
|
|
866
866
|
filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
|
|
867
867
|
return filePathRelativeToUserRootDir;
|
|
@@ -1021,17 +1021,17 @@ function determineIsErrorPage(routeFilesystem) {
|
|
|
1021
1021
|
return routeFilesystem.split('/').includes('_error');
|
|
1022
1022
|
}
|
|
1023
1023
|
function resolveImportPath(importData, importerFilePath) {
|
|
1024
|
-
const importerFilePathAbsolute = importerFilePath.
|
|
1024
|
+
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
1025
1025
|
(0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
|
|
1026
1026
|
const cwd = path_1.default.posix.dirname(importerFilePathAbsolute);
|
|
1027
|
-
//
|
|
1028
|
-
const
|
|
1029
|
-
return
|
|
1027
|
+
// filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
|
|
1028
|
+
const filePathAbsoluteFilesystem = (0, utils_js_1.requireResolve)(importData.importPath, cwd);
|
|
1029
|
+
return filePathAbsoluteFilesystem;
|
|
1030
1030
|
}
|
|
1031
|
-
function assertImportPath(
|
|
1031
|
+
function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath) {
|
|
1032
1032
|
const { importPath: importPath, importStringWasGenerated, importString } = importData;
|
|
1033
1033
|
const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(importerFilePath);
|
|
1034
|
-
if (!
|
|
1034
|
+
if (!filePathAbsoluteFilesystem) {
|
|
1035
1035
|
const importPathString = picocolors_1.default.cyan(`'${importPath}'`);
|
|
1036
1036
|
const errIntro = importStringWasGenerated
|
|
1037
1037
|
? `The import path ${importPathString} in ${filePathToShowToUser}`
|
|
@@ -23,9 +23,9 @@ async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
|
|
|
23
23
|
}
|
|
24
24
|
exports.transpileAndExecuteFile = transpileAndExecuteFile;
|
|
25
25
|
async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
26
|
-
const {
|
|
27
|
-
(0, utils_js_1.assertPosixPath)(
|
|
28
|
-
getVikeConfig_js_1.vikeConfigDependencies.add(
|
|
26
|
+
const { filePathAbsoluteFilesystem } = filePath;
|
|
27
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
28
|
+
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
29
29
|
let code = await transpileWithEsbuild(filePath, isValueFile, userRootDir);
|
|
30
30
|
let fileImports = null;
|
|
31
31
|
{
|
|
@@ -39,9 +39,9 @@ async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
|
39
39
|
}
|
|
40
40
|
function transpileImports(codeOriginal, filePath, isValueFile) {
|
|
41
41
|
// Do we need to remove the imports?
|
|
42
|
-
const {
|
|
43
|
-
(0, utils_js_1.assertPosixPath)(
|
|
44
|
-
const isHeader = isHeaderFile(
|
|
42
|
+
const { filePathAbsoluteFilesystem } = filePath;
|
|
43
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
44
|
+
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
45
45
|
const isPageConfigFile = !isValueFile;
|
|
46
46
|
if (!isHeader && !isPageConfigFile) {
|
|
47
47
|
return null;
|
|
@@ -63,7 +63,7 @@ function transpileImports(codeOriginal, filePath, isValueFile) {
|
|
|
63
63
|
return { code, fileImports };
|
|
64
64
|
}
|
|
65
65
|
async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
66
|
-
const entryFilePath = filePath.
|
|
66
|
+
const entryFilePath = filePath.filePathAbsoluteFilesystem;
|
|
67
67
|
const entryFileDir = path_1.default.posix.dirname(entryFilePath);
|
|
68
68
|
const options = {
|
|
69
69
|
platform: 'node',
|
|
@@ -128,8 +128,8 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
128
128
|
Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
|
|
129
129
|
filePathRelative = (0, utils_js_1.toPosixPath)(filePathRelative);
|
|
130
130
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
131
|
-
const
|
|
132
|
-
getVikeConfig_js_1.vikeConfigDependencies.add(
|
|
131
|
+
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathRelative);
|
|
132
|
+
getVikeConfig_js_1.vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
const code = result.outputFiles[0].text;
|
|
@@ -137,10 +137,10 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
137
137
|
return code;
|
|
138
138
|
}
|
|
139
139
|
async function executeFile(filePath, code, fileImports, isValueFile) {
|
|
140
|
-
const {
|
|
140
|
+
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
141
141
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
142
142
|
// - But seems to break source maps, so I don't think it's worth it
|
|
143
|
-
const filePathTmp = getFilePathTmp(
|
|
143
|
+
const filePathTmp = getFilePathTmp(filePathAbsoluteFilesystem);
|
|
144
144
|
fs_1.default.writeFileSync(filePathTmp, code);
|
|
145
145
|
const clean = () => fs_1.default.unlinkSync(filePathTmp);
|
|
146
146
|
let fileExports = {};
|
|
@@ -163,7 +163,7 @@ async function executeFile(filePath, code, fileImports, isValueFile) {
|
|
|
163
163
|
fileExports = { ...fileExports };
|
|
164
164
|
if (fileImports && !isValueFile) {
|
|
165
165
|
(0, utils_js_1.assert)(filePathRelativeToUserRootDir !== undefined);
|
|
166
|
-
const filePathToShowToUser = filePathRelativeToUserRootDir ??
|
|
166
|
+
const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsoluteFilesystem;
|
|
167
167
|
assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser);
|
|
168
168
|
}
|
|
169
169
|
return { fileExports };
|
|
@@ -34,27 +34,27 @@ function getFilePathAbsolute(filePath, config) {
|
|
|
34
34
|
filePathUnresolved = path_1.default.posix.join(root, filePath);
|
|
35
35
|
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathUnresolved);
|
|
36
36
|
}
|
|
37
|
-
let
|
|
37
|
+
let filePathAbsoluteFilesystem;
|
|
38
38
|
try {
|
|
39
|
-
|
|
39
|
+
filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
|
|
40
40
|
}
|
|
41
41
|
catch (err) {
|
|
42
42
|
console.error(err);
|
|
43
43
|
(0, assert_js_1.assert)(false);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(
|
|
47
|
-
return
|
|
45
|
+
filePathAbsoluteFilesystem = (0, filesystemPathHandling_js_1.toPosixPath)(filePathAbsoluteFilesystem);
|
|
46
|
+
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
47
|
+
return filePathAbsoluteFilesystem;
|
|
48
48
|
}
|
|
49
49
|
exports.getFilePathAbsolute = getFilePathAbsolute;
|
|
50
|
-
function getFilePathRelativeToUserRootDir(
|
|
51
|
-
(0, filesystemPathHandling_js_1.assertPosixPath)(
|
|
50
|
+
function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
|
|
51
|
+
(0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
52
52
|
(0, filesystemPathHandling_js_1.assertPosixPath)(userRootDir);
|
|
53
|
-
let filePathRelativeToUserRootDir = path_1.default.posix.relative(userRootDir,
|
|
54
|
-
if (
|
|
53
|
+
let filePathRelativeToUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
54
|
+
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
55
55
|
(0, assert_js_1.assert)(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
|
|
56
56
|
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
57
|
-
{ filePathRelativeToUserRootDir,
|
|
57
|
+
{ filePathRelativeToUserRootDir, filePathAbsoluteFilesystem, userRootDir });
|
|
58
58
|
filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
|
|
59
59
|
return filePathRelativeToUserRootDir;
|
|
60
60
|
}
|
|
@@ -63,7 +63,7 @@ function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysR
|
|
|
63
63
|
return filePathRelativeToUserRootDir;
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
return
|
|
66
|
+
return filePathAbsoluteFilesystem;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -52,7 +52,7 @@ function parseUrl(url, baseServer) {
|
|
|
52
52
|
const searchAll = {};
|
|
53
53
|
Array.from(new URLSearchParams(searchOriginal || '')).forEach(([key, val]) => {
|
|
54
54
|
search[key] = val;
|
|
55
|
-
searchAll[key] = [...(searchAll[key]
|
|
55
|
+
searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
|
|
56
56
|
});
|
|
57
57
|
// Origin + pathname
|
|
58
58
|
const { origin, pathname: pathnameResolved } = parsePathname(urlWithoutHashNorSearch, baseServer);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectInfo = void 0;
|
|
4
4
|
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
5
|
-
const PROJECT_VERSION = '0.4.144-commit-
|
|
5
|
+
const PROJECT_VERSION = '0.4.144-commit-68c730d';
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
8
8
|
projectVersion: PROJECT_VERSION,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { buildConfig };
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
|
-
import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, getOutDirs
|
|
4
|
+
import { assert, resolveOutDir, isObject, viteIsSSR, getFilePathAbsolute, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, getOutDirs } from '../utils.js';
|
|
5
5
|
import { virtualFileIdImportUserCodeServer } from '../../shared/virtual-files/virtualFileImportUserCode.js';
|
|
6
6
|
import { getVikeConfig } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
import { getConfigValue } from '../../../shared/page-configs/utils.js';
|
|
@@ -38,13 +38,13 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
38
38
|
if (configEnv !== 'client-only' && configEnv !== 'server-and-client')
|
|
39
39
|
return;
|
|
40
40
|
if (definedAtInfo.filePathRelativeToUserRootDir !== null) {
|
|
41
|
-
const {
|
|
42
|
-
assert(
|
|
41
|
+
const { filePathAbsoluteFilesystem } = definedAtInfo;
|
|
42
|
+
assert(filePathAbsoluteFilesystem);
|
|
43
43
|
// Surprisingly Vite expects entries to be absolute paths
|
|
44
|
-
entries.push(
|
|
44
|
+
entries.push(filePathAbsoluteFilesystem);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
// Adding definedAtInfo.
|
|
47
|
+
// Adding definedAtInfo.filePathAbsoluteFilesystem doesn't work for npm packages, I guess because of Vite's config.server.fs.allow
|
|
48
48
|
const { importPathAbsolute } = definedAtInfo;
|
|
49
49
|
assert(importPathAbsolute);
|
|
50
50
|
// We need to differentiate between npm package imports and path aliases.
|
|
@@ -111,8 +111,8 @@ function handleHotUpdate(ctx, config, configVike) {
|
|
|
111
111
|
return virtualModules;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function isVikeConfigModule(
|
|
115
|
-
return vikeConfigDependencies.has(
|
|
114
|
+
function isVikeConfigModule(filePathAbsoluteFilesystem) {
|
|
115
|
+
return vikeConfigDependencies.has(filePathAbsoluteFilesystem);
|
|
116
116
|
}
|
|
117
117
|
function reloadConfig(filePath, config, configVike, op) {
|
|
118
118
|
{
|
|
@@ -7,7 +7,7 @@ if (f.filePathRelativeToUserRootDir === null) {
|
|
|
7
7
|
}
|
|
8
8
|
//*/
|
|
9
9
|
function getFilePathToShowToUser(filePath) {
|
|
10
|
-
const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.
|
|
10
|
+
const filePathToShowToUser = filePath.filePathRelativeToUserRootDir ?? filePath.filePathAbsoluteFilesystem;
|
|
11
11
|
assert(filePathToShowToUser);
|
|
12
12
|
return filePathToShowToUser;
|
|
13
13
|
}
|
|
@@ -81,9 +81,9 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
81
81
|
});
|
|
82
82
|
let interfaceFilesByLocationId = {};
|
|
83
83
|
// Config files
|
|
84
|
-
await Promise.all(configFiles.map(async ({
|
|
84
|
+
await Promise.all(configFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
|
|
85
85
|
const configFilePath = {
|
|
86
|
-
|
|
86
|
+
filePathAbsoluteFilesystem: filePathAbsoluteFilesystem,
|
|
87
87
|
filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
|
|
88
88
|
importPathAbsolute: null
|
|
89
89
|
};
|
|
@@ -98,13 +98,13 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev, extensions) {
|
|
|
98
98
|
});
|
|
99
99
|
}));
|
|
100
100
|
// Value files
|
|
101
|
-
await Promise.all(valueFiles.map(async ({
|
|
101
|
+
await Promise.all(valueFiles.map(async ({ filePathAbsoluteFilesystem, filePathRelativeToUserRootDir }) => {
|
|
102
102
|
const configName = getConfigName(filePathRelativeToUserRootDir);
|
|
103
103
|
assert(configName);
|
|
104
104
|
const interfaceFile = {
|
|
105
105
|
filePath: {
|
|
106
106
|
filePathRelativeToUserRootDir,
|
|
107
|
-
|
|
107
|
+
filePathAbsoluteFilesystem,
|
|
108
108
|
importPathAbsolute: null
|
|
109
109
|
},
|
|
110
110
|
configMap: {
|
|
@@ -546,20 +546,20 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
546
546
|
if (!importData)
|
|
547
547
|
return null;
|
|
548
548
|
const { importPath, exportName } = importData;
|
|
549
|
-
const
|
|
550
|
-
assertFileEnv(
|
|
549
|
+
const filePathAbsoluteFilesystem = resolveImportPath(importData, importerFilePath);
|
|
550
|
+
assertFileEnv(filePathAbsoluteFilesystem ?? importPath, configEnv, configName);
|
|
551
551
|
const fileExportPath = exportName === 'default' || exportName === configName ? [] : [exportName];
|
|
552
552
|
if (importPath.startsWith('.')) {
|
|
553
553
|
// We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
|
|
554
554
|
// ```
|
|
555
555
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
556
556
|
// ```
|
|
557
|
-
assertImportPath(
|
|
558
|
-
const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(
|
|
557
|
+
assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath);
|
|
558
|
+
const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, importerFilePath, userRootDir);
|
|
559
559
|
return {
|
|
560
560
|
exportName,
|
|
561
561
|
fileExportPath,
|
|
562
|
-
|
|
562
|
+
filePathAbsoluteFilesystem,
|
|
563
563
|
filePathRelativeToUserRootDir,
|
|
564
564
|
importPathAbsolute: null
|
|
565
565
|
};
|
|
@@ -571,26 +571,26 @@ function resolveImport(configValue, importerFilePath, userRootDir, configEnv, co
|
|
|
571
571
|
return {
|
|
572
572
|
exportName,
|
|
573
573
|
fileExportPath,
|
|
574
|
-
|
|
574
|
+
filePathAbsoluteFilesystem,
|
|
575
575
|
filePathRelativeToUserRootDir: null,
|
|
576
576
|
importPathAbsolute: importPath
|
|
577
577
|
};
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
|
-
function resolveImportPath_relativeToUserRootDir(
|
|
580
|
+
function resolveImportPath_relativeToUserRootDir(filePathAbsoluteFilesystem, importData, configFilePath, userRootDir) {
|
|
581
581
|
assertPosixPath(userRootDir);
|
|
582
582
|
let filePathRelativeToUserRootDir;
|
|
583
|
-
if (
|
|
584
|
-
filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(
|
|
583
|
+
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
584
|
+
filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, userRootDir);
|
|
585
585
|
}
|
|
586
586
|
else {
|
|
587
587
|
assertUsage(false, `${getFilePathToShowToUser(configFilePath)} 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`);
|
|
588
588
|
// None of the following works. Seems to be a Vite bug?
|
|
589
589
|
// /*
|
|
590
|
-
// assert(
|
|
591
|
-
// filePath = `/@fs${
|
|
590
|
+
// assert(filePathAbsoluteFilesystem.startsWith('/'))
|
|
591
|
+
// filePath = `/@fs${filePathAbsoluteFilesystem}`
|
|
592
592
|
// /*/
|
|
593
|
-
// filePathRelativeToUserRootDir = path.posix.relative(userRootDir,
|
|
593
|
+
// filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem)
|
|
594
594
|
// assert(filePathRelativeToUserRootDir.startsWith('../'))
|
|
595
595
|
// filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir
|
|
596
596
|
// //*/
|
|
@@ -599,11 +599,11 @@ function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, c
|
|
|
599
599
|
assert(filePathRelativeToUserRootDir.startsWith('/'));
|
|
600
600
|
return filePathRelativeToUserRootDir;
|
|
601
601
|
}
|
|
602
|
-
function getVitePathFromAbsolutePath(
|
|
603
|
-
assertPosixPath(
|
|
602
|
+
function getVitePathFromAbsolutePath(filePathAbsoluteFilesystem, root) {
|
|
603
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
604
604
|
assertPosixPath(root);
|
|
605
|
-
assert(
|
|
606
|
-
let vitePath = path.posix.relative(root,
|
|
605
|
+
assert(filePathAbsoluteFilesystem.startsWith(root));
|
|
606
|
+
let vitePath = path.posix.relative(root, filePathAbsoluteFilesystem);
|
|
607
607
|
assert(!vitePath.startsWith('/') && !vitePath.startsWith('.'));
|
|
608
608
|
vitePath = '/' + vitePath;
|
|
609
609
|
return vitePath;
|
|
@@ -756,8 +756,8 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
|
|
|
756
756
|
const plusFiles = result.map((p) => {
|
|
757
757
|
p = toPosixPath(p);
|
|
758
758
|
const filePathRelativeToUserRootDir = path.posix.join('/', p);
|
|
759
|
-
const
|
|
760
|
-
return { filePathRelativeToUserRootDir,
|
|
759
|
+
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, p);
|
|
760
|
+
return { filePathRelativeToUserRootDir, filePathAbsoluteFilesystem };
|
|
761
761
|
});
|
|
762
762
|
extensions.forEach((extension) => {
|
|
763
763
|
extension.pageConfigsDistFiles?.forEach((pageConfigDistFile) => {
|
|
@@ -769,7 +769,7 @@ async function findPlusFiles(userRootDir, ignoreDirs, isDev, extensions) {
|
|
|
769
769
|
const { importPath, filePath } = pageConfigDistFile;
|
|
770
770
|
plusFiles.push({
|
|
771
771
|
filePathRelativeToUserRootDir: importPath,
|
|
772
|
-
|
|
772
|
+
filePathAbsoluteFilesystem: filePath
|
|
773
773
|
});
|
|
774
774
|
});
|
|
775
775
|
});
|
|
@@ -799,12 +799,12 @@ function assertNoUnexpectedPlusSign(filePath, fileName) {
|
|
|
799
799
|
assertUsage(!fileName.slice(1).includes('+'), `Character '+' is only allowed at the beginning of filenames: make sure ${filePath} doesn't contain any '+' in its filename other than its first letter`);
|
|
800
800
|
}
|
|
801
801
|
async function loadConfigFile(configFilePath, userRootDir, visited) {
|
|
802
|
-
const {
|
|
803
|
-
assertNoInfiniteLoop(visited,
|
|
802
|
+
const { filePathAbsoluteFilesystem } = configFilePath;
|
|
803
|
+
assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem);
|
|
804
804
|
const { fileExports } = await transpileAndExecuteFile(configFilePath, false, userRootDir);
|
|
805
805
|
const { extendsConfigs, extendsFilePaths } = await loadExtendsConfigs(fileExports, configFilePath, userRootDir, [
|
|
806
806
|
...visited,
|
|
807
|
-
|
|
807
|
+
filePathAbsoluteFilesystem
|
|
808
808
|
]);
|
|
809
809
|
const configFile = {
|
|
810
810
|
fileExports,
|
|
@@ -813,13 +813,13 @@ async function loadConfigFile(configFilePath, userRootDir, visited) {
|
|
|
813
813
|
};
|
|
814
814
|
return { configFile, extendsConfigs };
|
|
815
815
|
}
|
|
816
|
-
function assertNoInfiniteLoop(visited,
|
|
817
|
-
const idx = visited.indexOf(
|
|
816
|
+
function assertNoInfiniteLoop(visited, filePathAbsoluteFilesystem) {
|
|
817
|
+
const idx = visited.indexOf(filePathAbsoluteFilesystem);
|
|
818
818
|
if (idx === -1)
|
|
819
819
|
return;
|
|
820
820
|
const loop = visited.slice(idx);
|
|
821
|
-
assert(loop[0] ===
|
|
822
|
-
assertUsage(idx === -1, `Infinite extends loop ${[...loop,
|
|
821
|
+
assert(loop[0] === filePathAbsoluteFilesystem);
|
|
822
|
+
assertUsage(idx === -1, `Infinite extends loop ${[...loop, filePathAbsoluteFilesystem].join('>')}`);
|
|
823
823
|
}
|
|
824
824
|
async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir, visited) {
|
|
825
825
|
const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
|
|
@@ -828,14 +828,14 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
828
828
|
const { importPath: importPath } = importData;
|
|
829
829
|
// TODO
|
|
830
830
|
// - validate extends configs
|
|
831
|
-
const
|
|
832
|
-
assertImportPath(
|
|
833
|
-
assertExtendsImportPath(importPath,
|
|
831
|
+
const filePathAbsoluteFilesystem = resolveImportPath(importData, configFilePath);
|
|
832
|
+
assertImportPath(filePathAbsoluteFilesystem, importData, configFilePath);
|
|
833
|
+
assertExtendsImportPath(importPath, filePathAbsoluteFilesystem, configFilePath);
|
|
834
834
|
// - filePathRelativeToUserRootDir has no functionality beyond nicer error messages for user
|
|
835
|
-
// - Using importPath would be visually nicer but it's ambigous => we rather pick
|
|
836
|
-
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(
|
|
835
|
+
// - Using importPath would be visually nicer but it's ambigous => we rather pick filePathAbsoluteFilesystem for added clarity
|
|
836
|
+
const filePathRelativeToUserRootDir = determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir);
|
|
837
837
|
extendsConfigFiles.push({
|
|
838
|
-
|
|
838
|
+
filePathAbsoluteFilesystem,
|
|
839
839
|
// TODO: fix type cast
|
|
840
840
|
filePathRelativeToUserRootDir: filePathRelativeToUserRootDir,
|
|
841
841
|
importPathAbsolute: importPath
|
|
@@ -847,16 +847,16 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
847
847
|
extendsConfigs.push(result.configFile);
|
|
848
848
|
extendsConfigs.push(...result.extendsConfigs);
|
|
849
849
|
}));
|
|
850
|
-
const extendsFilePaths = extendsConfigFiles.map((f) => f.
|
|
850
|
+
const extendsFilePaths = extendsConfigFiles.map((f) => f.filePathAbsoluteFilesystem);
|
|
851
851
|
return { extendsConfigs, extendsFilePaths };
|
|
852
852
|
}
|
|
853
|
-
function determineFilePathRelativeToUserDir(
|
|
854
|
-
assertPosixPath(
|
|
853
|
+
function determineFilePathRelativeToUserDir(filePathAbsoluteFilesystem, userRootDir) {
|
|
854
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
855
855
|
assertPosixPath(userRootDir);
|
|
856
|
-
if (!
|
|
856
|
+
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
857
857
|
return null;
|
|
858
858
|
}
|
|
859
|
-
let filePathRelativeToUserRootDir =
|
|
859
|
+
let filePathRelativeToUserRootDir = filePathAbsoluteFilesystem.slice(userRootDir.length);
|
|
860
860
|
if (!filePathRelativeToUserRootDir.startsWith('/'))
|
|
861
861
|
filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir;
|
|
862
862
|
return filePathRelativeToUserRootDir;
|
|
@@ -1016,17 +1016,17 @@ function determineIsErrorPage(routeFilesystem) {
|
|
|
1016
1016
|
return routeFilesystem.split('/').includes('_error');
|
|
1017
1017
|
}
|
|
1018
1018
|
function resolveImportPath(importData, importerFilePath) {
|
|
1019
|
-
const importerFilePathAbsolute = importerFilePath.
|
|
1019
|
+
const importerFilePathAbsolute = importerFilePath.filePathAbsoluteFilesystem;
|
|
1020
1020
|
assertPosixPath(importerFilePathAbsolute);
|
|
1021
1021
|
const cwd = path.posix.dirname(importerFilePathAbsolute);
|
|
1022
|
-
//
|
|
1023
|
-
const
|
|
1024
|
-
return
|
|
1022
|
+
// filePathAbsoluteFilesystem is expected to be null when importData.importPath is a Vite path alias
|
|
1023
|
+
const filePathAbsoluteFilesystem = requireResolve(importData.importPath, cwd);
|
|
1024
|
+
return filePathAbsoluteFilesystem;
|
|
1025
1025
|
}
|
|
1026
|
-
function assertImportPath(
|
|
1026
|
+
function assertImportPath(filePathAbsoluteFilesystem, importData, importerFilePath) {
|
|
1027
1027
|
const { importPath: importPath, importStringWasGenerated, importString } = importData;
|
|
1028
1028
|
const filePathToShowToUser = getFilePathToShowToUser(importerFilePath);
|
|
1029
|
-
if (!
|
|
1029
|
+
if (!filePathAbsoluteFilesystem) {
|
|
1030
1030
|
const importPathString = pc.cyan(`'${importPath}'`);
|
|
1031
1031
|
const errIntro = importStringWasGenerated
|
|
1032
1032
|
? `The import path ${importPathString} in ${filePathToShowToUser}`
|
|
@@ -20,9 +20,9 @@ async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
|
|
|
20
20
|
return { fileExports };
|
|
21
21
|
}
|
|
22
22
|
async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
23
|
-
const {
|
|
24
|
-
assertPosixPath(
|
|
25
|
-
vikeConfigDependencies.add(
|
|
23
|
+
const { filePathAbsoluteFilesystem } = filePath;
|
|
24
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
25
|
+
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
26
26
|
let code = await transpileWithEsbuild(filePath, isValueFile, userRootDir);
|
|
27
27
|
let fileImports = null;
|
|
28
28
|
{
|
|
@@ -36,9 +36,9 @@ async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
|
36
36
|
}
|
|
37
37
|
function transpileImports(codeOriginal, filePath, isValueFile) {
|
|
38
38
|
// Do we need to remove the imports?
|
|
39
|
-
const {
|
|
40
|
-
assertPosixPath(
|
|
41
|
-
const isHeader = isHeaderFile(
|
|
39
|
+
const { filePathAbsoluteFilesystem } = filePath;
|
|
40
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
41
|
+
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
42
42
|
const isPageConfigFile = !isValueFile;
|
|
43
43
|
if (!isHeader && !isPageConfigFile) {
|
|
44
44
|
return null;
|
|
@@ -60,7 +60,7 @@ function transpileImports(codeOriginal, filePath, isValueFile) {
|
|
|
60
60
|
return { code, fileImports };
|
|
61
61
|
}
|
|
62
62
|
async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
63
|
-
const entryFilePath = filePath.
|
|
63
|
+
const entryFilePath = filePath.filePathAbsoluteFilesystem;
|
|
64
64
|
const entryFileDir = path.posix.dirname(entryFilePath);
|
|
65
65
|
const options = {
|
|
66
66
|
platform: 'node',
|
|
@@ -125,8 +125,8 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
125
125
|
Object.keys(result.metafile.inputs).forEach((filePathRelative) => {
|
|
126
126
|
filePathRelative = toPosixPath(filePathRelative);
|
|
127
127
|
assertPosixPath(userRootDir);
|
|
128
|
-
const
|
|
129
|
-
vikeConfigDependencies.add(
|
|
128
|
+
const filePathAbsoluteFilesystem = path.posix.join(userRootDir, filePathRelative);
|
|
129
|
+
vikeConfigDependencies.add(filePathAbsoluteFilesystem);
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
const code = result.outputFiles[0].text;
|
|
@@ -134,10 +134,10 @@ async function transpileWithEsbuild(filePath, bundle, userRootDir) {
|
|
|
134
134
|
return code;
|
|
135
135
|
}
|
|
136
136
|
async function executeFile(filePath, code, fileImports, isValueFile) {
|
|
137
|
-
const {
|
|
137
|
+
const { filePathAbsoluteFilesystem, filePathRelativeToUserRootDir } = filePath;
|
|
138
138
|
// Alternative to using a temporary file: https://github.com/vitejs/vite/pull/13269
|
|
139
139
|
// - But seems to break source maps, so I don't think it's worth it
|
|
140
|
-
const filePathTmp = getFilePathTmp(
|
|
140
|
+
const filePathTmp = getFilePathTmp(filePathAbsoluteFilesystem);
|
|
141
141
|
fs.writeFileSync(filePathTmp, code);
|
|
142
142
|
const clean = () => fs.unlinkSync(filePathTmp);
|
|
143
143
|
let fileExports = {};
|
|
@@ -160,7 +160,7 @@ async function executeFile(filePath, code, fileImports, isValueFile) {
|
|
|
160
160
|
fileExports = { ...fileExports };
|
|
161
161
|
if (fileImports && !isValueFile) {
|
|
162
162
|
assert(filePathRelativeToUserRootDir !== undefined);
|
|
163
|
-
const filePathToShowToUser = filePathRelativeToUserRootDir ??
|
|
163
|
+
const filePathToShowToUser = filePathRelativeToUserRootDir ?? filePathAbsoluteFilesystem;
|
|
164
164
|
assertImportsAreReExported(fileImports, fileExports, filePathToShowToUser);
|
|
165
165
|
}
|
|
166
166
|
return { fileExports };
|
|
@@ -93,11 +93,11 @@ type DefinedAtFile = {
|
|
|
93
93
|
type DefinedAtFileInfo = // TODO: replace filePathRelativeToUserRootDir and importPathAbsolute with following?
|
|
94
94
|
({
|
|
95
95
|
filePathRelativeToUserRootDir: string;
|
|
96
|
-
|
|
96
|
+
filePathAbsoluteFilesystem: string;
|
|
97
97
|
importPathAbsolute: null;
|
|
98
98
|
} | {
|
|
99
99
|
filePathRelativeToUserRootDir: null;
|
|
100
|
-
|
|
100
|
+
filePathAbsoluteFilesystem: string | null;
|
|
101
101
|
importPathAbsolute: string;
|
|
102
102
|
}) & {
|
|
103
103
|
exportName?: string;
|
|
@@ -2,4 +2,4 @@ export { getFilePathAbsolute };
|
|
|
2
2
|
export { getFilePathRelativeToUserRootDir };
|
|
3
3
|
import type { ResolvedConfig } from 'vite';
|
|
4
4
|
declare function getFilePathAbsolute(filePath: string, config: ResolvedConfig): string;
|
|
5
|
-
declare function getFilePathRelativeToUserRootDir(
|
|
5
|
+
declare function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem: string, userRootDir: string, alwaysRelative?: boolean): string;
|
|
@@ -30,26 +30,26 @@ function getFilePathAbsolute(filePath, config) {
|
|
|
30
30
|
filePathUnresolved = path.posix.join(root, filePath);
|
|
31
31
|
assertPathIsFilesystemAbsolute(filePathUnresolved);
|
|
32
32
|
}
|
|
33
|
-
let
|
|
33
|
+
let filePathAbsoluteFilesystem;
|
|
34
34
|
try {
|
|
35
|
-
|
|
35
|
+
filePathAbsoluteFilesystem = require_.resolve(filePathUnresolved, { paths: [config.root] });
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
38
38
|
console.error(err);
|
|
39
39
|
assert(false);
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
assertPathIsFilesystemAbsolute(
|
|
43
|
-
return
|
|
41
|
+
filePathAbsoluteFilesystem = toPosixPath(filePathAbsoluteFilesystem);
|
|
42
|
+
assertPathIsFilesystemAbsolute(filePathAbsoluteFilesystem);
|
|
43
|
+
return filePathAbsoluteFilesystem;
|
|
44
44
|
}
|
|
45
|
-
function getFilePathRelativeToUserRootDir(
|
|
46
|
-
assertPosixPath(
|
|
45
|
+
function getFilePathRelativeToUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
|
|
46
|
+
assertPosixPath(filePathAbsoluteFilesystem);
|
|
47
47
|
assertPosixPath(userRootDir);
|
|
48
|
-
let filePathRelativeToUserRootDir = path.posix.relative(userRootDir,
|
|
49
|
-
if (
|
|
48
|
+
let filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
49
|
+
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
50
50
|
assert(!filePathRelativeToUserRootDir.startsWith('.') && !filePathRelativeToUserRootDir.startsWith('/'),
|
|
51
51
|
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
52
|
-
{ filePathRelativeToUserRootDir,
|
|
52
|
+
{ filePathRelativeToUserRootDir, filePathAbsoluteFilesystem, userRootDir });
|
|
53
53
|
filePathRelativeToUserRootDir = `/${filePathRelativeToUserRootDir}`;
|
|
54
54
|
return filePathRelativeToUserRootDir;
|
|
55
55
|
}
|
|
@@ -58,7 +58,7 @@ function getFilePathRelativeToUserRootDir(filePathAbsolute, userRootDir, alwaysR
|
|
|
58
58
|
return filePathRelativeToUserRootDir;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
return
|
|
61
|
+
return filePathAbsoluteFilesystem;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -51,7 +51,7 @@ function parseUrl(url, baseServer) {
|
|
|
51
51
|
const searchAll = {};
|
|
52
52
|
Array.from(new URLSearchParams(searchOriginal || '')).forEach(([key, val]) => {
|
|
53
53
|
search[key] = val;
|
|
54
|
-
searchAll[key] = [...(searchAll[key]
|
|
54
|
+
searchAll[key] = [...(searchAll.hasOwnProperty(key) ? searchAll[key] : []), val];
|
|
55
55
|
});
|
|
56
56
|
// Origin + pathname
|
|
57
57
|
const { origin, pathname: pathnameResolved } = parsePathname(urlWithoutHashNorSearch, baseServer);
|
|
@@ -5,7 +5,7 @@ type ProjectVersion = typeof projectInfo.projectVersion;
|
|
|
5
5
|
type ProjectTag = `[${PackageName}]` | `[${PackageName}@${ProjectVersion}]`;
|
|
6
6
|
declare const projectInfo: {
|
|
7
7
|
projectName: "Vike";
|
|
8
|
-
projectVersion: "0.4.144-commit-
|
|
8
|
+
projectVersion: "0.4.144-commit-68c730d";
|
|
9
9
|
npmPackageName: "vike";
|
|
10
10
|
githubRepository: "https://github.com/vikejs/vike";
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { projectInfo };
|
|
2
2
|
import { onProjectInfo } from './assertSingleInstance.js';
|
|
3
|
-
const PROJECT_VERSION = '0.4.144-commit-
|
|
3
|
+
const PROJECT_VERSION = '0.4.144-commit-68c730d';
|
|
4
4
|
const projectInfo = {
|
|
5
5
|
projectName: 'Vike',
|
|
6
6
|
projectVersion: PROJECT_VERSION,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike",
|
|
3
|
-
"version": "0.4.144-commit-
|
|
3
|
+
"version": "0.4.144-commit-68c730d",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "tsc --watch",
|
|
6
6
|
"build": "rimraf dist/ && pnpm run build:esm && pnpm run build:cjs",
|
|
@@ -162,7 +162,6 @@
|
|
|
162
162
|
"vike": "./node/cli/bin-entry.js"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
|
-
"@brillout/part-regex": "^0.1.2",
|
|
166
165
|
"@brillout/release-me": "^0.1.8",
|
|
167
166
|
"@types/estree": "^1.0.0",
|
|
168
167
|
"@types/jest": "^27.4.1",
|