vike 0.4.144-commit-756f5d7 → 0.4.144-commit-6aef8a6
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/importBuild/index.js +3 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js +12 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +140 -127
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
- package/dist/cjs/node/runtime/renderPage/log404/index.js +27 -17
- package/dist/cjs/shared/page-configs/getExportPath.js +3 -3
- package/dist/cjs/shared/page-configs/loadConfigValues.js +2 -2
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +8 -9
- package/dist/cjs/shared/page-configs/utils.js +8 -15
- package/dist/cjs/shared/route/abort.js +1 -1
- package/dist/cjs/shared/route/loadPageRoutes.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/truncateString.js +12 -7
- package/dist/esm/node/plugin/plugins/importBuild/index.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +2 -1
- 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 +12 -12
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +140 -127
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +2 -4
- package/dist/esm/node/runtime/renderPage/log404/index.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/log404/index.js +27 -16
- package/dist/esm/shared/page-configs/PageConfig.d.ts +51 -21
- package/dist/esm/shared/page-configs/getExportPath.d.ts +1 -1
- package/dist/esm/shared/page-configs/getExportPath.js +3 -3
- package/dist/esm/shared/page-configs/loadConfigValues.js +2 -2
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +4 -4
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +1 -1
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +8 -9
- package/dist/esm/shared/page-configs/utils.d.ts +3 -3
- package/dist/esm/shared/page-configs/utils.js +8 -15
- package/dist/esm/shared/route/abort.js +1 -1
- package/dist/esm/shared/route/loadPageRoutes.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/truncateString.d.ts +2 -1
- package/dist/esm/utils/truncateString.js +10 -7
- package/package.json +1 -1
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -16
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +0 -24
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.js +0 -13
|
@@ -13,7 +13,6 @@ const utils_js_1 = require("../../../utils.js");
|
|
|
13
13
|
const replaceImportStatements_js_1 = require("./replaceImportStatements.js");
|
|
14
14
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
15
15
|
require("source-map-support/register.js");
|
|
16
|
-
const getFilePathToShowToUser_js_1 = require("./getFilePathToShowToUser.js");
|
|
17
16
|
const assertExports_js_1 = require("../../../../../shared/page-configs/assertExports.js");
|
|
18
17
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
19
18
|
async function transpileAndExecuteFile(filePath, isValueFile, userRootDir) {
|
|
@@ -39,14 +38,13 @@ async function transpileFile(filePath, isValueFile, userRootDir) {
|
|
|
39
38
|
}
|
|
40
39
|
function transpileImports(codeOriginal, filePath, isValueFile) {
|
|
41
40
|
// Do we need to remove the imports?
|
|
42
|
-
const { filePathAbsoluteFilesystem } = filePath;
|
|
41
|
+
const { filePathAbsoluteFilesystem, filePathToShowToUser } = filePath;
|
|
43
42
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
44
43
|
const isHeader = isHeaderFile(filePathAbsoluteFilesystem);
|
|
45
44
|
const isPageConfigFile = !isValueFile;
|
|
46
45
|
if (!isHeader && !isPageConfigFile) {
|
|
47
46
|
return null;
|
|
48
47
|
}
|
|
49
|
-
const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(filePath);
|
|
50
48
|
(0, utils_js_1.assertWarning)(isPageConfigFile, `${filePathToShowToUser} is a JavaScript header file (.h.js), but JavaScript header files should only be used for +config.h.js, see https://vike.dev/header-file`, { onlyOnce: true });
|
|
51
49
|
// Remove the imports
|
|
52
50
|
const res = (0, replaceImportStatements_js_1.replaceImportStatements)(codeOriginal, filePathToShowToUser);
|
|
@@ -279,7 +277,7 @@ function triggerPrepareStackTrace(err) {
|
|
|
279
277
|
function getErrIntroMsg(operation, filePath) {
|
|
280
278
|
const msg = [
|
|
281
279
|
picocolors_1.default.red(`Failed to ${operation}`),
|
|
282
|
-
picocolors_1.default.bold(picocolors_1.default.red(
|
|
280
|
+
picocolors_1.default.bold(picocolors_1.default.red(filePath.filePathToShowToUser)),
|
|
283
281
|
picocolors_1.default.red(`because:`)
|
|
284
282
|
].join(' ');
|
|
285
283
|
return msg;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getRoutesInfo = exports.log404 = void 0;
|
|
7
7
|
const globalContext_js_1 = require("../../globalContext.js");
|
|
8
8
|
const utils_js_1 = require("../../utils.js");
|
|
9
9
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
@@ -17,15 +17,20 @@ async function log404(pageContext) {
|
|
|
17
17
|
);
|
|
18
18
|
const globalContext = (0, globalContext_js_1.getGlobalContext)();
|
|
19
19
|
if (!globalContext.isProduction && !isFileRequest(urlPathname) && !pageContext.isClientSideNavigation) {
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const routesInfo = getRoutesInfo(pageRoutes);
|
|
21
|
+
let msg = `URL ${picocolors_1.default.cyan(urlPathname)} doesn't match the route of any of your pages`;
|
|
22
|
+
const outro = 'See https://vike.dev/routing for more information about routing.';
|
|
23
|
+
if (!routesInfo) {
|
|
24
|
+
msg = `${msg}. ${picocolors_1.default.dim(outro)}`;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
msg = `${msg}:\n${routesInfo}\n${outro}`;
|
|
28
|
+
}
|
|
29
|
+
(0, utils_js_1.assertInfo)(false, msg, { onlyOnce: false });
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
exports.log404 = log404;
|
|
28
|
-
function
|
|
33
|
+
function getRoutesInfo(pageRoutes) {
|
|
29
34
|
const entries = pageRoutes
|
|
30
35
|
.map((pageRoute) => {
|
|
31
36
|
let routeStr;
|
|
@@ -74,19 +79,24 @@ function getPagesAndRoutesInfo(pageRoutes) {
|
|
|
74
79
|
const terminalWidth = (0, utils_js_1.getTerminalWidth)() || 134;
|
|
75
80
|
let width2 = Math.max(...linesContent.map(({ routeTypeSrc }) => (0, utils_js_1.stripAnsi)(routeTypeSrc).length));
|
|
76
81
|
let width3 = Math.max(...linesContent.map(({ routeDefinedBy }) => (0, utils_js_1.stripAnsi)(routeDefinedBy).length));
|
|
77
|
-
|
|
82
|
+
const width1_max = terminalWidth -
|
|
83
|
+
width3 -
|
|
84
|
+
width2 -
|
|
85
|
+
// Total width of table border & padding
|
|
86
|
+
10;
|
|
87
|
+
if (width1_max < 10)
|
|
88
|
+
return null;
|
|
78
89
|
linesContent.forEach((lineContent) => {
|
|
79
90
|
let { routeStr } = lineContent;
|
|
80
|
-
if (lineContent.routeTypeSrc
|
|
81
|
-
routeStr = (
|
|
82
|
-
|
|
83
|
-
else {
|
|
84
|
-
routeStr = truncateRouteFunction(routeStr, width1);
|
|
91
|
+
if (lineContent.routeTypeSrc === 'Route Function') {
|
|
92
|
+
routeStr = truncateRouteFunction(routeStr, width1_max);
|
|
93
|
+
(0, utils_js_1.assert)((0, utils_js_1.stripAnsi)(routeStr).length <= width1_max);
|
|
85
94
|
}
|
|
86
|
-
(0, utils_js_1.assert)((0, utils_js_1.stripAnsi)(routeStr).length <= width1);
|
|
87
95
|
lineContent.routeStr = routeStr;
|
|
88
96
|
});
|
|
89
|
-
width1 = Math.max(...linesContent.map(({ routeStr }) => (0, utils_js_1.stripAnsi)(routeStr).length));
|
|
97
|
+
let width1 = Math.max(...linesContent.map(({ routeStr }) => (0, utils_js_1.stripAnsi)(routeStr).length));
|
|
98
|
+
if (width1 > width1_max)
|
|
99
|
+
return null;
|
|
90
100
|
let lines = linesContent.map(({ routeStr, routeTypeSrc, routeDefinedBy }, i) => {
|
|
91
101
|
let cell1 = padEnd(routeStr, width1 + ((0, utils_js_1.stripAnsi)(routeStr).length - (0, utils_js_1.stripAnsi)(routeStr).length));
|
|
92
102
|
let cell2 = padEnd(routeTypeSrc, width2);
|
|
@@ -117,12 +127,12 @@ function getPagesAndRoutesInfo(pageRoutes) {
|
|
|
117
127
|
});
|
|
118
128
|
return lines.join('\n');
|
|
119
129
|
}
|
|
120
|
-
exports.
|
|
130
|
+
exports.getRoutesInfo = getRoutesInfo;
|
|
121
131
|
function truncateRouteFunction(routeStr, lenMax) {
|
|
122
132
|
routeStr = (0, utils_js_1.stripAnsi)(routeStr);
|
|
123
133
|
routeStr = removeNonAscii(routeStr);
|
|
124
134
|
routeStr = routeStr.split(/\s/).filter(Boolean).join(' ');
|
|
125
|
-
routeStr = (0, utils_js_1.truncateString)(routeStr, lenMax
|
|
135
|
+
routeStr = (0, utils_js_1.truncateString)(routeStr, lenMax);
|
|
126
136
|
return routeStr;
|
|
127
137
|
}
|
|
128
138
|
/** Same as String.prototype.padEnd but with stripAnsi() */
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExportPath = void 0;
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
|
-
function getExportPath(
|
|
6
|
-
if (!
|
|
5
|
+
function getExportPath(fileExportPathToShowToUser, configName) {
|
|
6
|
+
if (!fileExportPathToShowToUser)
|
|
7
7
|
return null;
|
|
8
|
-
let [exportName, ...exportObjectPath] =
|
|
8
|
+
let [exportName, ...exportObjectPath] = fileExportPathToShowToUser;
|
|
9
9
|
if (!exportName)
|
|
10
10
|
return null;
|
|
11
11
|
if (exportObjectPath.length === 0 && ['*', 'default', configName].includes(exportName))
|
|
@@ -4,7 +4,7 @@ exports.loadConfigValues = void 0;
|
|
|
4
4
|
const utils_js_1 = require("../utils.js");
|
|
5
5
|
const parseConfigValuesImported_js_1 = require("./serialize/parseConfigValuesImported.js");
|
|
6
6
|
async function loadConfigValues(pageConfig, isDev) {
|
|
7
|
-
if ('
|
|
7
|
+
if ('isAllLoaded' in pageConfig &&
|
|
8
8
|
// We don't need to cache in dev, since Vite already caches the virtual module
|
|
9
9
|
!isDev) {
|
|
10
10
|
return pageConfig;
|
|
@@ -12,7 +12,7 @@ async function loadConfigValues(pageConfig, isDev) {
|
|
|
12
12
|
const configValuesImported = await pageConfig.loadConfigValuesAll();
|
|
13
13
|
const configValuesAddendum = (0, parseConfigValuesImported_js_1.parseConfigValuesImported)(configValuesImported);
|
|
14
14
|
Object.assign(pageConfig.configValues, configValuesAddendum);
|
|
15
|
-
(0, utils_js_1.objectAssign)(pageConfig, {
|
|
15
|
+
(0, utils_js_1.objectAssign)(pageConfig, { isAllLoaded: true });
|
|
16
16
|
return pageConfig;
|
|
17
17
|
}
|
|
18
18
|
exports.loadConfigValues = loadConfigValues;
|
|
@@ -16,7 +16,7 @@ function parseConfigValuesImported(configValuesImported) {
|
|
|
16
16
|
file: {
|
|
17
17
|
// importPath cannot be relative to the current file, since the current file is a virtual file
|
|
18
18
|
filePathToShowToUser: importPath,
|
|
19
|
-
|
|
19
|
+
fileExportPathToShowToUser: [configName, 'default'].includes(exportName)
|
|
20
20
|
? []
|
|
21
21
|
: // Side-effect config
|
|
22
22
|
[exportName]
|
|
@@ -30,27 +30,26 @@ function serializeConfigValueImported(configValueSource, configName, whitespace,
|
|
|
30
30
|
(0, utils_js_1.assert)(whitespace.replaceAll(' ', '').length === 0);
|
|
31
31
|
const { valueIsImportedAtRuntime, definedAtInfo } = configValueSource;
|
|
32
32
|
(0, utils_js_1.assert)(valueIsImportedAtRuntime);
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const fileName = path_1.default.posix.basename(importPath);
|
|
33
|
+
const { filePathAbsoluteVite, fileExportName } = definedAtInfo;
|
|
34
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteVite);
|
|
35
|
+
const fileName = path_1.default.posix.basename(filePathAbsoluteVite);
|
|
37
36
|
const isValueFile = fileName.startsWith('+');
|
|
38
37
|
if (isValueFile)
|
|
39
|
-
(0, utils_js_1.assert)(
|
|
40
|
-
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(
|
|
38
|
+
(0, utils_js_1.assert)(fileExportName === undefined);
|
|
39
|
+
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(filePathAbsoluteVite, varCounterContainer.varCounter++, fileExportName);
|
|
41
40
|
importStatements.push(importStatement);
|
|
42
41
|
const lines = [];
|
|
43
42
|
lines.push(` {`);
|
|
44
43
|
lines.push(` configName: '${configName}',`);
|
|
45
|
-
lines.push(` importPath: '${
|
|
44
|
+
lines.push(` importPath: '${filePathAbsoluteVite}',`);
|
|
46
45
|
lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
|
|
47
46
|
if (isValueFile) {
|
|
48
47
|
lines.push(` exportValues: ${importName},`);
|
|
49
48
|
}
|
|
50
49
|
else {
|
|
51
50
|
lines.push(` exportValue: ${importName},`);
|
|
52
|
-
(0, utils_js_1.assert)(
|
|
53
|
-
lines.push(` exportName: ${JSON.stringify(
|
|
51
|
+
(0, utils_js_1.assert)(fileExportName);
|
|
52
|
+
lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
|
|
54
53
|
}
|
|
55
54
|
lines.push(` },`);
|
|
56
55
|
return lines;
|
|
@@ -45,11 +45,13 @@ function getPageConfig(pageId, pageConfigs) {
|
|
|
45
45
|
}
|
|
46
46
|
exports.getPageConfig = getPageConfig;
|
|
47
47
|
function getConfigDefinedAtString(configName, { definedAt }, sentenceBegin) {
|
|
48
|
-
const
|
|
48
|
+
const definedAtString = getDefinedAtString(definedAt, configName);
|
|
49
|
+
const definedAtStr = definedAtString === 'internally' ? definedAtString : `at ${definedAtString}`;
|
|
50
|
+
const configDefinedAt = `${sentenceBegin ? `Config` : `config`} ${picocolors_1.default.cyan(configName)} defined ${definedAtStr}`;
|
|
49
51
|
return configDefinedAt;
|
|
50
52
|
}
|
|
51
53
|
exports.getConfigDefinedAtString = getConfigDefinedAtString;
|
|
52
|
-
function
|
|
54
|
+
function getDefinedAtString(definedAt, configName) {
|
|
53
55
|
if (definedAt.isComputed) {
|
|
54
56
|
return 'internally';
|
|
55
57
|
}
|
|
@@ -61,27 +63,18 @@ function getSourceString(definedAt, configName) {
|
|
|
61
63
|
files = [definedAt.file];
|
|
62
64
|
}
|
|
63
65
|
(0, utils_js_1.assert)(files.length >= 1);
|
|
64
|
-
const
|
|
66
|
+
const definedAtString = files
|
|
65
67
|
.map((source) => {
|
|
66
|
-
const { filePathToShowToUser,
|
|
68
|
+
const { filePathToShowToUser, fileExportPathToShowToUser } = source;
|
|
67
69
|
let s = filePathToShowToUser;
|
|
68
|
-
const exportPath = (0, getExportPath_js_1.getExportPath)(
|
|
70
|
+
const exportPath = (0, getExportPath_js_1.getExportPath)(fileExportPathToShowToUser, configName);
|
|
69
71
|
if (exportPath) {
|
|
70
72
|
s = `${s} > ${picocolors_1.default.cyan(exportPath)}`;
|
|
71
73
|
}
|
|
72
|
-
if (definedAt.isEffect) {
|
|
73
|
-
s = `${s} > (${picocolors_1.default.blue('effect')})`;
|
|
74
|
-
}
|
|
75
74
|
return s;
|
|
76
75
|
})
|
|
77
76
|
.join(' / ');
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
function getDefinedAtString(configValue, configName) {
|
|
81
|
-
let sourceString = getSourceString(configValue.definedAt, configName);
|
|
82
|
-
if (sourceString.startsWith('at '))
|
|
83
|
-
sourceString = sourceString.slice('at '.length);
|
|
84
|
-
return sourceString;
|
|
77
|
+
return definedAtString;
|
|
85
78
|
}
|
|
86
79
|
exports.getDefinedAtString = getDefinedAtString;
|
|
87
80
|
function getConfigValueFilePathToShowToUser({ definedAt }) {
|
|
@@ -39,7 +39,7 @@ exports.redirect = redirect;
|
|
|
39
39
|
function render(value, abortReason) {
|
|
40
40
|
const args = [typeof value === 'number' ? String(value) : JSON.stringify(value)];
|
|
41
41
|
if (abortReason !== undefined)
|
|
42
|
-
args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30
|
|
42
|
+
args.push((0, utils_js_1.truncateString)(JSON.stringify(abortReason), 30));
|
|
43
43
|
const abortCaller = 'throw render()';
|
|
44
44
|
const abortCall = `throw render(${args.join(', ')})`;
|
|
45
45
|
return render_(value, abortReason, abortCall, abortCaller);
|
|
@@ -34,7 +34,7 @@ function getPageRoutes(filesystemRoots, pageFilesAll, pageConfigs, allPageIds) {
|
|
|
34
34
|
const configValue = (0, utils_js_3.getConfigValue)(pageConfig, configName);
|
|
35
35
|
if (configValue) {
|
|
36
36
|
const route = configValue.value;
|
|
37
|
-
const definedAt = (0, utils_js_3.getDefinedAtString)(configValue, configName);
|
|
37
|
+
const definedAt = (0, utils_js_3.getDefinedAtString)(configValue.definedAt, configName);
|
|
38
38
|
if (typeof route === 'string') {
|
|
39
39
|
pageRoute = {
|
|
40
40
|
pageId,
|
|
@@ -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-6aef8a6';
|
|
6
6
|
const projectInfo = {
|
|
7
7
|
projectName: 'Vike',
|
|
8
8
|
projectVersion: PROJECT_VERSION,
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.truncateString = void 0;
|
|
4
|
-
|
|
7
|
+
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
8
|
+
const assert_js_1 = require("./assert.js");
|
|
9
|
+
function truncateString(str, lenMax) {
|
|
10
|
+
const lenMaxReal = lenMax - 3;
|
|
11
|
+
(0, assert_js_1.assert)(lenMaxReal >= 1); // Show at least one character before the ellipsis
|
|
5
12
|
if (str.length < lenMax) {
|
|
6
13
|
return str;
|
|
7
14
|
}
|
|
8
15
|
else {
|
|
9
|
-
//
|
|
10
|
-
// - So far, the str we pass to truncateString(str)
|
|
11
|
-
str = str.substring(0,
|
|
12
|
-
|
|
13
|
-
if (dim)
|
|
14
|
-
ellipsis = dim(ellipsis);
|
|
16
|
+
// Breaks ANSI codes.
|
|
17
|
+
// - So far, the `str` we pass to truncateString(str) is always expected to not contain any ANSI code
|
|
18
|
+
str = str.substring(0, lenMaxReal);
|
|
19
|
+
const ellipsis = picocolors_1.default.dim('...');
|
|
15
20
|
str = str + ellipsis;
|
|
16
21
|
return str;
|
|
17
22
|
}
|
|
@@ -26,15 +26,15 @@ function importBuild() {
|
|
|
26
26
|
];
|
|
27
27
|
}
|
|
28
28
|
function getImporterCode(config, pageFilesEntry) {
|
|
29
|
-
const
|
|
29
|
+
const filePathAbsolute = toPosixPath(
|
|
30
30
|
// [RELATIVE_PATH_FROM_DIST] Current file: node_modules/vike/dist/esm/node/plugin/plugins/importBuild/index.js
|
|
31
31
|
require_.resolve(`../../../../../../dist/esm/node/runtime/globalContext/loadImportBuild.js`));
|
|
32
32
|
const { outDirServer } = getOutDirs(config);
|
|
33
|
-
const
|
|
33
|
+
const filePathRelative = path.posix.relative(outDirServer, filePathAbsolute);
|
|
34
34
|
// The only reason we went for using CJS require() instead of ESM import() is because import() doesn't support .json files
|
|
35
35
|
const importerCode = [
|
|
36
36
|
'(async () => {',
|
|
37
|
-
` const { setImportBuildGetters } = await import('${
|
|
37
|
+
` const { setImportBuildGetters } = await import('${filePathRelative}');`,
|
|
38
38
|
' setImportBuildGetters({',
|
|
39
39
|
` pageFiles: () => import('./${pageFilesEntry}'),`,
|
|
40
40
|
" clientManifest: () => require('../assets.json'),",
|
|
@@ -4,7 +4,7 @@ export type { ConfigDefinition };
|
|
|
4
4
|
export type { ConfigDefinitionInternal };
|
|
5
5
|
export type { ConfigNameGlobal };
|
|
6
6
|
export type { ConfigEffect };
|
|
7
|
-
import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
7
|
+
import type { ConfigEnvInternal, ConfigEnv, ConfigValueSources, DefinedAtFileInfo } from '../../../../../../shared/page-configs/PageConfig.js';
|
|
8
8
|
import type { Config, ConfigNameBuiltIn } from '../../../../../../shared/page-configs/Config.js';
|
|
9
9
|
/** The meta definition of a config.
|
|
10
10
|
*
|
|
@@ -46,6 +46,7 @@ type ConfigEffect = (config: {
|
|
|
46
46
|
type ConfigDefinitionInternal = Omit<ConfigDefinition, 'env'> & {
|
|
47
47
|
_computed?: (configValueSources: ConfigValueSources) => unknown;
|
|
48
48
|
_valueIsFilePath?: true;
|
|
49
|
+
_userEffectDefinedAt?: DefinedAtFileInfo;
|
|
49
50
|
env: ConfigEnvInternal;
|
|
50
51
|
};
|
|
51
52
|
type ConfigDefinitionsBuiltIn = Record<ConfigNameBuiltIn, ConfigDefinitionInternal>;
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { getLogicalPath };
|
|
|
11
11
|
* getLocationId('/pages/some-page') => '/pages/some-page'
|
|
12
12
|
* getLocationId('/renderer/+config.js') => '/renderer'
|
|
13
13
|
*/
|
|
14
|
-
declare function getLocationId(
|
|
14
|
+
declare function getLocationId(filePathAbsoluteVite: string): string;
|
|
15
15
|
/** Get URL determined by filesystem path */
|
|
16
16
|
declare function getFilesystemRouteString(locationId: string): string;
|
|
17
17
|
/**
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.js
CHANGED
|
@@ -13,8 +13,8 @@ import { assert, assertPosixPath, getNpmPackageImportPath, isNpmPackageImport, h
|
|
|
13
13
|
* getLocationId('/pages/some-page') => '/pages/some-page'
|
|
14
14
|
* getLocationId('/renderer/+config.js') => '/renderer'
|
|
15
15
|
*/
|
|
16
|
-
function getLocationId(
|
|
17
|
-
const locationId = removeFilename(
|
|
16
|
+
function getLocationId(filePathAbsoluteVite) {
|
|
17
|
+
const locationId = removeFilename(filePathAbsoluteVite, true);
|
|
18
18
|
assertLocationId(locationId);
|
|
19
19
|
return locationId;
|
|
20
20
|
}
|
|
@@ -110,21 +110,21 @@ function removeDirectories(somePath, removeDirs) {
|
|
|
110
110
|
somePath = '/';
|
|
111
111
|
return somePath;
|
|
112
112
|
}
|
|
113
|
-
function removeFilename(
|
|
114
|
-
assertPosixPath(
|
|
115
|
-
assert(
|
|
113
|
+
function removeFilename(filePathAbsoluteVite, optional) {
|
|
114
|
+
assertPosixPath(filePathAbsoluteVite);
|
|
115
|
+
assert(filePathAbsoluteVite.startsWith('/') || isNpmPackageImport(filePathAbsoluteVite));
|
|
116
116
|
{
|
|
117
|
-
const filename =
|
|
117
|
+
const filename = filePathAbsoluteVite.split('/').slice(-1)[0];
|
|
118
118
|
if (!filename.includes('.')) {
|
|
119
119
|
assert(optional);
|
|
120
|
-
return
|
|
120
|
+
return filePathAbsoluteVite;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
assertLocationId(
|
|
127
|
-
return
|
|
123
|
+
let locationId = filePathAbsoluteVite.split('/').slice(0, -1).join('/');
|
|
124
|
+
if (locationId === '')
|
|
125
|
+
locationId = '/';
|
|
126
|
+
assertLocationId(locationId);
|
|
127
|
+
return locationId;
|
|
128
128
|
}
|
|
129
129
|
function getFilesystemRouteDefinedBy(locationId) {
|
|
130
130
|
if (locationId === '/')
|