vike 0.4.165-commit-b3cc3cb → 0.4.165-commit-8eba585
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/baseUrls.js +1 -1
- package/dist/cjs/node/plugin/plugins/buildConfig/fixServerAssets.js +6 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +1 -1
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +12 -0
- package/dist/cjs/node/plugin/plugins/config/index.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
- package/dist/cjs/node/plugin/plugins/envVars.js +1 -1
- package/dist/cjs/node/plugin/plugins/fileEnv.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +1 -1
- 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/getFilePath.js +90 -0
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +5 -24
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +15 -22
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +11 -20
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +21 -20
- package/dist/cjs/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +1 -1
- package/dist/cjs/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/cjs/node/runtime/renderPage/getPageAssets/getManifestEntry.js +26 -24
- package/dist/cjs/node/runtime/renderPage.js +34 -21
- package/dist/cjs/shared/page-configs/FilePath.js +2 -0
- package/dist/cjs/utils/assert.js +2 -0
- package/dist/cjs/utils/assertSingleInstance.js +6 -5
- package/dist/cjs/utils/assertVersion.js +4 -1
- package/dist/cjs/utils/getFilePathAbsolute.js +11 -11
- package/dist/cjs/utils/getGlobalObject.js +21 -6
- package/dist/cjs/utils/isNpmPackage.js +1 -4
- package/dist/cjs/utils/parseUrl.js +1 -1
- package/dist/cjs/utils/projectInfo.js +1 -4
- 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.js +2 -2
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +12 -0
- package/dist/esm/node/plugin/plugins/config/index.js +1 -1
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +3 -3
- package/dist/esm/node/plugin/plugins/envVars.js +2 -2
- package/dist/esm/node/plugin/plugins/fileEnv.js +3 -3
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +2 -2
- 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/getFilePath.d.ts +20 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/getFilePath.js +84 -0
- 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 +6 -25
- 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 +15 -22
- 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 +11 -20
- 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 +21 -20
- package/dist/esm/node/plugin/shared/loggerNotProd/errorWithCodeSnippet.js +2 -2
- package/dist/esm/node/runtime/html/injectAssets/getHtmlTags.js +1 -0
- package/dist/esm/node/runtime/renderPage/getPageAssets/getManifestEntry.js +26 -24
- package/dist/esm/node/runtime/renderPage.js +34 -21
- package/dist/esm/shared/page-configs/FilePath.d.ts +52 -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/utils/assert.js +2 -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/getFilePathAbsolute.d.ts +4 -4
- package/dist/esm/utils/getFilePathAbsolute.js +10 -10
- package/dist/esm/utils/getGlobalObject.d.ts +6 -1
- package/dist/esm/utils/getGlobalObject.js +22 -6
- package/dist/esm/utils/isNpmPackage.d.ts +0 -6
- package/dist/esm/utils/isNpmPackage.js +5 -3
- package/dist/esm/utils/parseUrl.js +1 -1
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -4
- package/package.json +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveFilePath.js +0 -33
- 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
|
@@ -20,7 +20,7 @@ const crawlPlusFiles_js_1 = require("./getVikeConfig/crawlPlusFiles.js");
|
|
|
20
20
|
const getConfigFileExport_js_1 = require("./getConfigFileExport.js");
|
|
21
21
|
const loadFileAtConfigTime_js_1 = require("./getVikeConfig/loadFileAtConfigTime.js");
|
|
22
22
|
const resolveImportPath_js_1 = require("./getVikeConfig/resolveImportPath.js");
|
|
23
|
-
const
|
|
23
|
+
const getFilePath_js_1 = require("./getVikeConfig/getFilePath.js");
|
|
24
24
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
25
|
let devServerIsCorrupt = false;
|
|
26
26
|
let wasConfigInvalid = null;
|
|
@@ -65,7 +65,7 @@ async function handleReloadSideEffects() {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
async function getVikeConfig(config, isDev, tolerateInvalidConfig
|
|
68
|
+
async function getVikeConfig(config, isDev, tolerateInvalidConfig) {
|
|
69
69
|
const { outDirRoot } = (0, utils_js_1.getOutDirs)(config);
|
|
70
70
|
const userRootDir = config.root;
|
|
71
71
|
if (!vikeConfigPromise) {
|
|
@@ -97,11 +97,11 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
97
97
|
await Promise.all([
|
|
98
98
|
// Config files
|
|
99
99
|
...configFiles.map(async (filePath) => {
|
|
100
|
-
const {
|
|
101
|
-
(0, utils_js_1.assert)(
|
|
100
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
101
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
102
102
|
const { configFile, extendsConfigs } = await (0, loadFileAtConfigTime_js_1.loadConfigFile)(filePath, userRootDir, [], false);
|
|
103
|
-
(0, utils_js_1.assert)(filePath.
|
|
104
|
-
const locationId = (0, filesystemRouting_js_1.getLocationId)(
|
|
103
|
+
(0, utils_js_1.assert)(filePath.filePathAbsoluteUserRootDir);
|
|
104
|
+
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
105
105
|
const interfaceFile = getInterfaceFileFromConfigFile(configFile, false, locationId);
|
|
106
106
|
interfaceFilesByLocationId[locationId] = interfaceFilesByLocationId[locationId] ?? [];
|
|
107
107
|
interfaceFilesByLocationId[locationId].push(interfaceFile);
|
|
@@ -150,11 +150,11 @@ async function loadInterfaceFiles(userRootDir, outDirRoot, isDev) {
|
|
|
150
150
|
}),
|
|
151
151
|
// Value files
|
|
152
152
|
...valueFiles.map(async (filePath) => {
|
|
153
|
-
const {
|
|
154
|
-
(0, utils_js_1.assert)(
|
|
155
|
-
const configName = getConfigName(
|
|
153
|
+
const { filePathAbsoluteUserRootDir } = filePath;
|
|
154
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
155
|
+
const configName = getConfigName(filePathAbsoluteUserRootDir);
|
|
156
156
|
(0, utils_js_1.assert)(configName);
|
|
157
|
-
const locationId = (0, filesystemRouting_js_1.getLocationId)(
|
|
157
|
+
const locationId = (0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir);
|
|
158
158
|
const interfaceFile = {
|
|
159
159
|
locationId,
|
|
160
160
|
filePath,
|
|
@@ -353,9 +353,9 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
353
353
|
const interfaceFilesGlobalPaths = [];
|
|
354
354
|
(0, utils_js_1.objectEntries)(interfaceFilesGlobal).forEach(([locationId, interfaceFiles]) => {
|
|
355
355
|
(0, utils_js_1.assert)((0, filesystemRouting_js_1.isGlobalLocation)(locationId, locationIds));
|
|
356
|
-
interfaceFiles.forEach(({ filePath: {
|
|
357
|
-
if (
|
|
358
|
-
interfaceFilesGlobalPaths.push(
|
|
356
|
+
interfaceFiles.forEach(({ filePath: { filePathAbsoluteUserRootDir } }) => {
|
|
357
|
+
if (filePathAbsoluteUserRootDir) {
|
|
358
|
+
interfaceFilesGlobalPaths.push(filePathAbsoluteUserRootDir);
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
});
|
|
@@ -464,10 +464,10 @@ async function resolveConfigValueSources(configName, configDef, interfaceFilesRe
|
|
|
464
464
|
}
|
|
465
465
|
function makeOrderDeterministic(interfaceFile1, interfaceFile2) {
|
|
466
466
|
return (0, utils_js_1.lowerFirst)((interfaceFile) => {
|
|
467
|
-
const {
|
|
467
|
+
const { filePathAbsoluteUserRootDir } = interfaceFile.filePath;
|
|
468
468
|
(0, utils_js_1.assert)(isInterfaceFileUserLand(interfaceFile));
|
|
469
|
-
(0, utils_js_1.assert)(
|
|
470
|
-
return
|
|
469
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
470
|
+
return filePathAbsoluteUserRootDir.length;
|
|
471
471
|
})(interfaceFile1, interfaceFile2);
|
|
472
472
|
}
|
|
473
473
|
function warnOverridenConfigValues(interfaceFileWinner, interfaceFilesOverriden, configName) {
|
|
@@ -541,6 +541,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
541
541
|
configName !== 'extends') {
|
|
542
542
|
if (import_.filePathAbsoluteFilesystem) {
|
|
543
543
|
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(import_, 'filePathAbsoluteFilesystem', 'string')); // Help TS
|
|
544
|
+
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(import_, 'filePathToShowToUserResolved', 'string')); // Help TS
|
|
544
545
|
const fileExport = await (0, loadFileAtConfigTime_js_1.loadImportedFile)(import_, userRootDir, importedFilesLoaded);
|
|
545
546
|
configValueSource.value = fileExport;
|
|
546
547
|
}
|
|
@@ -744,7 +745,7 @@ function getComputed(configValueSources, configDefinitions) {
|
|
|
744
745
|
}
|
|
745
746
|
async function findPlusFiles(userRootDir, outDirRoot, isDev) {
|
|
746
747
|
const files = await (0, crawlPlusFiles_js_1.crawlPlusFiles)(userRootDir, outDirRoot, isDev);
|
|
747
|
-
const plusFiles = files.map(({
|
|
748
|
+
const plusFiles = files.map(({ filePathAbsoluteUserRootDir }) => (0, getFilePath_js_1.getFilePathResolved)({ filePathAbsoluteUserRootDir, userRootDir, importPathAbsolute: null }));
|
|
748
749
|
return plusFiles;
|
|
749
750
|
}
|
|
750
751
|
function getConfigName(filePath) {
|
|
@@ -834,9 +835,9 @@ function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName)
|
|
|
834
835
|
const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configFilesystemRoutingRoot);
|
|
835
836
|
(0, utils_js_1.assertUsage)(typeof value === 'string', `${configDefinedAt} should be a string`);
|
|
836
837
|
(0, utils_js_1.assertUsage)(value.startsWith('/'), `${configDefinedAt} is ${picocolors_1.default.cyan(value)} but it should start with a leading slash ${picocolors_1.default.cyan('/')}`);
|
|
837
|
-
const {
|
|
838
|
-
(0, utils_js_1.assert)(
|
|
839
|
-
const before = (0, filesystemRouting_js_1.getFilesystemRouteString)((0, filesystemRouting_js_1.getLocationId)(
|
|
838
|
+
const { filePathAbsoluteUserRootDir } = configFilesystemRoutingRoot.definedAt;
|
|
839
|
+
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
840
|
+
const before = (0, filesystemRouting_js_1.getFilesystemRouteString)((0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir));
|
|
840
841
|
const after = value;
|
|
841
842
|
const filesystemRoutingRootEffect = { before, after };
|
|
842
843
|
return { filesystemRoutingRootEffect, filesystemRoutingRootDefinedAt: configDefinedAt };
|
|
@@ -48,7 +48,7 @@ function getPrettyErrorWithCodeSnippet(err, userRootDir) {
|
|
|
48
48
|
let { id, frame } = err;
|
|
49
49
|
const msgFirstLine = [
|
|
50
50
|
picocolors_1.default.red('Failed to transpile'),
|
|
51
|
-
picocolors_1.default.bold(picocolors_1.default.red((0, utils_js_1.
|
|
51
|
+
picocolors_1.default.bold(picocolors_1.default.red((0, utils_js_1.getFilePathAbsoluteUserRootDir)(normalizeId(id), userRootDir))),
|
|
52
52
|
picocolors_1.default.red('because:')
|
|
53
53
|
].join(' ');
|
|
54
54
|
const errMsg = getPrettyErrMessage(err);
|
|
@@ -144,6 +144,7 @@ async function mergeScriptEntries(pageAssets, isProduction) {
|
|
|
144
144
|
function getPageContextJsonScriptTag(pageContext) {
|
|
145
145
|
const pageContextSerialized = (0, sanitizeJson_js_1.sanitizeJson)((0, serializePageContextClientSide_js_1.serializePageContextClientSide)(pageContext));
|
|
146
146
|
const htmlTag = `<script id="vike_pageContext" type="application/json">${pageContextSerialized}</script>`;
|
|
147
|
+
// Used by contra.com https://github.com/gajus
|
|
147
148
|
// @ts-expect-error
|
|
148
149
|
pageContext._pageContextHtmlTag = htmlTag;
|
|
149
150
|
return htmlTag;
|
|
@@ -50,35 +50,37 @@ function getManifestEntry(id, assetsManifest) {
|
|
|
50
50
|
const [manifestKey, manifestEntry] = found;
|
|
51
51
|
return { manifestEntry, manifestKey };
|
|
52
52
|
}
|
|
53
|
+
/* Can we remove this?
|
|
53
54
|
// extensions[number].pageConfigsSrcDir
|
|
54
55
|
if (id.startsWith('/node_modules/') || id.startsWith('/../')) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
{
|
|
67
|
-
(0, utils_js_1.assert)(manifestKeyEnd.startsWith('/'), debugInfo);
|
|
68
|
-
const dirS = manifestKeyEnd.split('/');
|
|
69
|
-
(0, utils_js_1.assert)(dirS[0] === '', debugInfo);
|
|
70
|
-
manifestKeyEnd = '/' + dirS.slice(2).join('/');
|
|
71
|
-
(0, utils_js_1.assert)(manifestKeyEnd.startsWith('/'), debugInfo);
|
|
56
|
+
let manifestKeyEnd = id.split('/node_modules/').slice(-1)[0]
|
|
57
|
+
assert(manifestKeyEnd, debugInfo)
|
|
58
|
+
assert(!manifestKeyEnd.startsWith('/'), debugInfo)
|
|
59
|
+
manifestKeyEnd = '/' + manifestKeyEnd
|
|
60
|
+
{
|
|
61
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id)
|
|
62
|
+
if (manifestEntry) {
|
|
63
|
+
assert(manifestKey, debugInfo)
|
|
64
|
+
return { manifestEntry, manifestKey }
|
|
72
65
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
}
|
|
67
|
+
{
|
|
68
|
+
assert(manifestKeyEnd.startsWith('/'), debugInfo)
|
|
69
|
+
const dirS = manifestKeyEnd.split('/')
|
|
70
|
+
assert(dirS[0] === '', debugInfo)
|
|
71
|
+
manifestKeyEnd = '/' + dirS.slice(2).join('/')
|
|
72
|
+
assert(manifestKeyEnd.startsWith('/'), debugInfo)
|
|
73
|
+
}
|
|
74
|
+
{
|
|
75
|
+
const { manifestEntry, manifestKey } = findEntryWithKeyEnd(manifestKeyEnd, assetsManifest, id)
|
|
76
|
+
if (manifestEntry) {
|
|
77
|
+
assert(manifestKey, debugInfo)
|
|
78
|
+
return { manifestEntry, manifestKey }
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
}
|
|
81
|
+
assert(false, debugInfo)
|
|
81
82
|
}
|
|
83
|
+
*/
|
|
82
84
|
(0, utils_js_1.assert)(false, debugInfo);
|
|
83
85
|
}
|
|
84
86
|
exports.getManifestEntry = getManifestEntry;
|
|
@@ -57,7 +57,7 @@ exports.renderPage = renderPage;
|
|
|
57
57
|
async function renderPageAndPrepare(pageContextInit, httpRequestId) {
|
|
58
58
|
// Invalid config
|
|
59
59
|
const handleInvalidConfig = () => {
|
|
60
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(picocolors_1.default.bold(picocolors_1.default.red(
|
|
60
|
+
(0, loggerRuntime_js_1.logRuntimeInfo)?.(picocolors_1.default.bold(picocolors_1.default.red('Error while loading a Vike config file, see error above.')), httpRequestId, 'error');
|
|
61
61
|
const pageContextHttpResponseNull = getPageContextHttpResponseNull(pageContextInit);
|
|
62
62
|
return pageContextHttpResponseNull;
|
|
63
63
|
};
|
|
@@ -209,29 +209,42 @@ function getRequestInfoMessage(urlOriginal) {
|
|
|
209
209
|
}
|
|
210
210
|
function logHttpResponse(urlOriginal, httpRequestId, pageContextReturn) {
|
|
211
211
|
const statusCode = pageContextReturn.httpResponse?.statusCode ?? null;
|
|
212
|
+
let msg;
|
|
213
|
+
let isNominal;
|
|
212
214
|
{
|
|
213
|
-
// If URL doesn't include Base URL
|
|
214
215
|
const { errorWhileRendering } = pageContextReturn;
|
|
215
|
-
const isSkipped = statusCode === null &&
|
|
216
|
-
if (isSkipped)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
216
|
+
const isSkipped = statusCode === null && !errorWhileRendering;
|
|
217
|
+
if (isSkipped) {
|
|
218
|
+
// - URL doesn't include Base URL
|
|
219
|
+
// - Can we abort earlier so that `logHttpResponse()` and `logHttpRequest()` aren't even called?
|
|
220
|
+
// - Error loading a Vike config file
|
|
221
|
+
// - We should show `HTTP response ${urlOriginal} ERR` instead.
|
|
222
|
+
// - Maybe we can/should make the error available at pageContext.errorWhileRendering
|
|
223
|
+
(0, utils_js_1.assert)(errorWhileRendering === null || errorWhileRendering === undefined);
|
|
224
|
+
msg = `HTTP response ${picocolors_1.default.bold(urlOriginal)} ${picocolors_1.default.dim('null')}`;
|
|
225
|
+
// Erroneous value (it shoud sometimes be `false`) but it's fine as it doesn't seem to have much of an impact.
|
|
226
|
+
isNominal = true;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
const isSuccess = statusCode !== null && statusCode >= 200 && statusCode <= 399;
|
|
230
|
+
isNominal = isSuccess || statusCode === 404;
|
|
231
|
+
const color = (s) => picocolors_1.default.bold(isSuccess ? picocolors_1.default.green(String(s)) : picocolors_1.default.red(String(s)));
|
|
232
|
+
const isRedirect = statusCode && 300 <= statusCode && statusCode <= 399;
|
|
233
|
+
const type = isRedirect ? 'redirect' : 'response';
|
|
234
|
+
if (isRedirect) {
|
|
235
|
+
(0, utils_js_1.assert)(pageContextReturn.httpResponse);
|
|
236
|
+
const headerRedirect = pageContextReturn.httpResponse.headers
|
|
237
|
+
.slice()
|
|
238
|
+
.reverse()
|
|
239
|
+
.find((header) => header[0] === 'Location');
|
|
240
|
+
(0, utils_js_1.assert)(headerRedirect);
|
|
241
|
+
const urlRedirect = headerRedirect[1];
|
|
242
|
+
urlOriginal = urlRedirect;
|
|
243
|
+
}
|
|
244
|
+
msg = `HTTP ${type} ${picocolors_1.default.bold(urlOriginal)} ${color(statusCode ?? 'ERR')}`;
|
|
245
|
+
}
|
|
233
246
|
}
|
|
234
|
-
(0, loggerRuntime_js_1.logRuntimeInfo)?.(
|
|
247
|
+
(0, loggerRuntime_js_1.logRuntimeInfo)?.(msg, httpRequestId, isNominal ? 'info' : 'error');
|
|
235
248
|
}
|
|
236
249
|
function getPageContextHttpResponseNullWithError(err, pageContextInit) {
|
|
237
250
|
const pageContextHttpResponseNull = {};
|
package/dist/cjs/utils/assert.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isBug = exports.overwriteAssertProductionLogger = exports.getAssertErrMsg = exports.addOnBeforeLogHook = exports.getProjectError = exports.assertInfo = exports.assertWarning = exports.assertUsage = exports.assert = void 0;
|
|
7
|
+
const assertSingleInstance_js_1 = require("./assertSingleInstance.js");
|
|
7
8
|
const createErrorWithCleanStackTrace_js_1 = require("./createErrorWithCleanStackTrace.js");
|
|
8
9
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
9
10
|
const isObject_js_1 = require("./isObject.js");
|
|
@@ -22,6 +23,7 @@ const globalObject = (0, getGlobalObject_js_1.getGlobalObject)('utils/assert.ts'
|
|
|
22
23
|
},
|
|
23
24
|
showStackTraceList: new WeakSet()
|
|
24
25
|
});
|
|
26
|
+
(0, assertSingleInstance_js_1.onAssertModuleLoad)();
|
|
25
27
|
const projectTag = `[vike]`;
|
|
26
28
|
const projectTagWithVersion = `[vike@${projectInfo_js_1.projectInfo.projectVersion}]`;
|
|
27
29
|
const numberOfStackTraceLinesToRemove = 2;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.onAssertModuleLoad = exports.onClientEntry_ClientRouting = exports.onClientEntry_ServerRouting = void 0;
|
|
4
4
|
// - Throw error if there are two different versions of vike loaded
|
|
5
5
|
// - Show warning if entry of Client Routing and entry of Server Routing are both loaded
|
|
6
6
|
// - Show warning if vike is loaded twice
|
|
7
7
|
const unique_js_1 = require("./unique.js");
|
|
8
8
|
const getGlobalObject_js_1 = require("./getGlobalObject.js");
|
|
9
|
+
const projectInfo_js_1 = require("./projectInfo.js");
|
|
9
10
|
/* Use original assertUsage() & assertWarning() after all CJS is removed from node_modules/vike/dist/
|
|
10
11
|
import { assertUsage, assertWarning } from './assert.js'
|
|
11
12
|
*/
|
|
@@ -60,12 +61,12 @@ function onClientEntry_ClientRouting(isProduction) {
|
|
|
60
61
|
assertSingleInstance();
|
|
61
62
|
}
|
|
62
63
|
exports.onClientEntry_ClientRouting = onClientEntry_ClientRouting;
|
|
63
|
-
// Called by utils/
|
|
64
|
-
function
|
|
65
|
-
globalObject.instances.push(projectVersion);
|
|
64
|
+
// Called by utils/assert.ts which is (most certainly) loaded by all entries. That way we don't have to call a callback for every entry. (There are a lot of entries: `client/router/`, `client/`, `node/runtime/`, `node/plugin/`, `node/cli`.)
|
|
65
|
+
function onAssertModuleLoad() {
|
|
66
|
+
globalObject.instances.push(projectInfo_js_1.projectInfo.projectVersion);
|
|
66
67
|
assertSingleInstance();
|
|
67
68
|
}
|
|
68
|
-
exports.
|
|
69
|
+
exports.onAssertModuleLoad = onAssertModuleLoad;
|
|
69
70
|
function assertUsage(condition, errorMessage) {
|
|
70
71
|
if (condition) {
|
|
71
72
|
return;
|
|
@@ -25,9 +25,12 @@ exports.isVersionOrAbove = isVersionOrAbove;
|
|
|
25
25
|
function parseVersion(version) {
|
|
26
26
|
// Remove pre-release tag
|
|
27
27
|
version = version.split('-')[0];
|
|
28
|
+
let partsStr = version.split('.');
|
|
29
|
+
// Git seems to be using a fourth number: https://github.com/git/git/tree/master/Documentation/RelNotes
|
|
30
|
+
partsStr = partsStr.slice(0, 3);
|
|
28
31
|
// major.minor.patch
|
|
29
|
-
const partsStr = version.split('.');
|
|
30
32
|
(0, assert_js_1.assert)(partsStr.length === 3);
|
|
33
|
+
(0, assert_js_1.assert)(partsStr.every((s) => s.length > 0));
|
|
31
34
|
const parts = partsStr.map((s) => parseInt(s, 10));
|
|
32
35
|
return parts;
|
|
33
36
|
}
|
|
@@ -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.getFilePathAbsoluteUserRootDir = exports.getFilePathAbsoluteFilesystem = void 0;
|
|
7
7
|
const filesystemPathHandling_js_1 = require("./filesystemPathHandling.js");
|
|
8
8
|
const assert_js_1 = require("./assert.js");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -18,7 +18,7 @@ const require_ = (0, module_1.createRequire)(importMetaUrl);
|
|
|
18
18
|
// Vite handles paths such as /pages/index.page.js which are relative to `config.root`.
|
|
19
19
|
// Make them absolute starting from the filesystem root.
|
|
20
20
|
// Also resolve plus files living in npm packages such as restack/renderer/+onRenderHtml.js
|
|
21
|
-
function
|
|
21
|
+
function getFilePathAbsoluteFilesystem(filePath, config) {
|
|
22
22
|
(0, filesystemPathHandling_js_1.assertPosixPath)(filePath);
|
|
23
23
|
if (filePath.startsWith('/@fs/')) {
|
|
24
24
|
return filePath;
|
|
@@ -46,25 +46,25 @@ function getFilePathAbsolute(filePath, config) {
|
|
|
46
46
|
(0, assertPathIsFilesystemAbsolute_js_1.assertPathIsFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
47
47
|
return filePathAbsoluteFilesystem;
|
|
48
48
|
}
|
|
49
|
-
exports.
|
|
50
|
-
function
|
|
49
|
+
exports.getFilePathAbsoluteFilesystem = getFilePathAbsoluteFilesystem;
|
|
50
|
+
function getFilePathAbsoluteUserRootDir(filePathAbsoluteFilesystem, userRootDir, alwaysRelative = false) {
|
|
51
51
|
(0, filesystemPathHandling_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
52
52
|
(0, filesystemPathHandling_js_1.assertPosixPath)(userRootDir);
|
|
53
|
-
let
|
|
53
|
+
let filePathAbsoluteUserRootDir = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
54
54
|
if (filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
55
|
-
(0, assert_js_1.assert)(!
|
|
55
|
+
(0, assert_js_1.assert)(!filePathAbsoluteUserRootDir.startsWith('.') && !filePathAbsoluteUserRootDir.startsWith('/'),
|
|
56
56
|
// Surprinsingly, this assertion seem to fail sometimes: https://github.com/vikejs/vike/issues/1139
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
return
|
|
57
|
+
{ filePathAbsoluteUserRootDir, filePathAbsoluteFilesystem, userRootDir });
|
|
58
|
+
filePathAbsoluteUserRootDir = `/${filePathAbsoluteUserRootDir}`;
|
|
59
|
+
return filePathAbsoluteUserRootDir;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
if (alwaysRelative) {
|
|
63
|
-
return
|
|
63
|
+
return filePathAbsoluteUserRootDir;
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
return filePathAbsoluteFilesystem;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
exports.
|
|
70
|
+
exports.getFilePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir;
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGlobalObject = void 0;
|
|
3
|
+
exports.assertIsSingleModuleInstance = exports.getGlobalObject = void 0;
|
|
4
|
+
const assert_js_1 = require("./assert.js");
|
|
5
|
+
const projectInfo_js_1 = require("./projectInfo.js");
|
|
6
|
+
const projectKey = `_${projectInfo_js_1.projectInfo.projectName.toLowerCase()}`;
|
|
7
|
+
/** Share information across module instances. */
|
|
4
8
|
function getGlobalObject(
|
|
5
|
-
// We use the filename as key
|
|
9
|
+
// We use the filename (or file path) as key. There should be only one getGlobalObject() usage per file. Thus the key should be unique, assuming the filename (or file path) is unique.
|
|
6
10
|
key, defaultValue) {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const globalObject = (globalObjectsAll[key] = globalObjectsAll[key] || defaultValue);
|
|
11
|
+
const globalObjects = getGlobalObjects();
|
|
12
|
+
const globalObject = (globalObjects[key] = globalObjects[key] || defaultValue);
|
|
10
13
|
return globalObject;
|
|
11
14
|
}
|
|
12
15
|
exports.getGlobalObject = getGlobalObject;
|
|
13
|
-
|
|
16
|
+
/** Assert that the module is instantiated only once. */
|
|
17
|
+
function assertIsSingleModuleInstance(
|
|
18
|
+
// We use the filename (or file path) as key.
|
|
19
|
+
key) {
|
|
20
|
+
const globalObjects = getGlobalObjects();
|
|
21
|
+
(0, assert_js_1.assert)(!(key in globalObjects));
|
|
22
|
+
}
|
|
23
|
+
exports.assertIsSingleModuleInstance = assertIsSingleModuleInstance;
|
|
24
|
+
function getGlobalObjects() {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
const globalObjects = (globalThis[projectKey] = globalThis[projectKey] || {});
|
|
27
|
+
return globalObjects;
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isDistinguishable = exports.parse = exports.isValidPathAlias = exports.
|
|
3
|
+
exports.isDistinguishable = exports.parse = exports.isValidPathAlias = exports.isNpmPackageImport = void 0;
|
|
4
4
|
const assert_js_1 = require("./assert.js");
|
|
5
5
|
const assertIsNotBrowser_js_1 = require("./assertIsNotBrowser.js");
|
|
6
6
|
(0, assertIsNotBrowser_js_1.assertIsNotBrowser)();
|
|
@@ -13,21 +13,18 @@ function isNpmPackageName(str) {
|
|
|
13
13
|
const res = parse(str);
|
|
14
14
|
return res !== null && res.importPath === null;
|
|
15
15
|
}
|
|
16
|
-
exports.isNpmPackageName = isNpmPackageName;
|
|
17
16
|
function getNpmPackageName(str) {
|
|
18
17
|
const res = parse(str);
|
|
19
18
|
if (!res)
|
|
20
19
|
return null;
|
|
21
20
|
return res.pkgName;
|
|
22
21
|
}
|
|
23
|
-
exports.getNpmPackageName = getNpmPackageName;
|
|
24
22
|
function getNpmPackageImportPath(str) {
|
|
25
23
|
const res = parse(str);
|
|
26
24
|
if (!res)
|
|
27
25
|
return null;
|
|
28
26
|
return res.importPath;
|
|
29
27
|
}
|
|
30
|
-
exports.getNpmPackageImportPath = getNpmPackageImportPath;
|
|
31
28
|
function isValidPathAlias(alias) {
|
|
32
29
|
// Cannot be distinguished from npm package names
|
|
33
30
|
if (!isDistinguishable(alias))
|
|
@@ -10,7 +10,7 @@ exports.isUriWithProtocol = exports.createUrlFromComponents = exports.assertUrlC
|
|
|
10
10
|
const slice_js_1 = require("./slice.js");
|
|
11
11
|
const assert_js_1 = require("./assert.js");
|
|
12
12
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
13
|
-
const PROTOCOLS = ['http://', 'https://', 'tauri://'];
|
|
13
|
+
const PROTOCOLS = ['http://', 'https://', 'tauri://', 'file://'];
|
|
14
14
|
function isParsable(url) {
|
|
15
15
|
// `parseUrl()` works with these URLs
|
|
16
16
|
return (PROTOCOLS.some((p) => url.startsWith(p)) ||
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROJECT_VERSION = exports.projectInfo = void 0;
|
|
4
|
-
const
|
|
5
|
-
const PROJECT_VERSION = '0.4.165-commit-b3cc3cb';
|
|
4
|
+
const PROJECT_VERSION = '0.4.165-commit-8eba585';
|
|
6
5
|
exports.PROJECT_VERSION = PROJECT_VERSION;
|
|
7
6
|
const projectInfo = {
|
|
8
7
|
projectName: 'Vike',
|
|
9
8
|
projectVersion: PROJECT_VERSION
|
|
10
9
|
};
|
|
11
10
|
exports.projectInfo = projectInfo;
|
|
12
|
-
// Trick: since `utils/asserts.ts` depends on this file (`utils/projectInfo.ts`), we can have confidence that this file is always instantiated. So that we don't have to initialize this code snippet at every possible entry. (There are a *lot* of entries: `client/router/`, `client/`, `node/`, `node/plugin/`, `node/cli`, etc.)
|
|
13
|
-
(0, assertSingleInstance_js_1.onProjectInfo)(projectInfo.projectVersion);
|
|
@@ -8,7 +8,7 @@ function baseUrls(configVike) {
|
|
|
8
8
|
return {
|
|
9
9
|
name: 'vike:baseUrls',
|
|
10
10
|
enforce: 'post',
|
|
11
|
-
config
|
|
11
|
+
async config(config) {
|
|
12
12
|
const bases = resolveBaseFromUserConfig(config, configVike);
|
|
13
13
|
baseServer = bases.baseServer;
|
|
14
14
|
baseAssets = bases.baseAssets;
|
|
@@ -43,10 +43,14 @@ async function copyAssets(filesToCopy, config) {
|
|
|
43
43
|
return;
|
|
44
44
|
assert(existsSync(assetsDirServer));
|
|
45
45
|
const concurrencyLimit = pLimit(10);
|
|
46
|
-
await Promise.all(filesToCopy.map((file) => concurrencyLimit(() =>
|
|
46
|
+
await Promise.all(filesToCopy.map((file) => concurrencyLimit(() =>
|
|
47
|
+
// TODO: move instead of copying
|
|
48
|
+
fs.cp(path.posix.join(outDirServer, file), path.posix.join(outDirClient, file), {
|
|
47
49
|
recursive: true
|
|
48
50
|
}))));
|
|
49
|
-
|
|
51
|
+
/* We cannot do that because, with some edge case Rollup settings (outputing JavaScript chunks and static assets to the same directoy), this removes JavaScript chunks, see https://github.com/vikejs/vike/issues/1154#issuecomment-1975762404
|
|
52
|
+
await fs.rm(assetsDirServer, { recursive: true })
|
|
53
|
+
*/
|
|
50
54
|
}
|
|
51
55
|
// Add serverManifest resources to clientManifest
|
|
52
56
|
function addServerAssets(clientManifest, serverManifest) {
|
|
@@ -2,7 +2,7 @@ export { buildConfig };
|
|
|
2
2
|
export { assertRollupInput };
|
|
3
3
|
export { analyzeClientEntries };
|
|
4
4
|
export { manifestTempFile };
|
|
5
|
-
import { assert, resolveOutDir, viteIsSSR,
|
|
5
|
+
import { assert, resolveOutDir, viteIsSSR, getFilePathAbsoluteFilesystem, addOnBeforeLogHook, removeFileExtention, unique, assertPosixPath, assertUsage, injectRollupInputs, normalizeRollupInput, getOutDirs, isNpmPackageImport, assertNodeEnv_build } from '../utils.js';
|
|
6
6
|
import { getVikeConfig, isV1Design } from './importUserCode/v1-design/getVikeConfig.js';
|
|
7
7
|
import { getConfigValue } from '../../../shared/page-configs/helpers.js';
|
|
8
8
|
import { findPageFiles } from '../shared/findPageFiles.js';
|
|
@@ -208,7 +208,7 @@ function getEntryFromClientEntry(clientEntry, config, addExtractAssetsQuery) {
|
|
|
208
208
|
const filePath = clientEntry;
|
|
209
209
|
assertPosixPath(filePath);
|
|
210
210
|
assert(filePath.startsWith('/'));
|
|
211
|
-
let entryTarget =
|
|
211
|
+
let entryTarget = getFilePathAbsoluteFilesystem(filePath, config);
|
|
212
212
|
if (addExtractAssetsQuery)
|
|
213
213
|
entryTarget = extractAssetsAddQuery(entryTarget);
|
|
214
214
|
let entryName = filePath;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export { assertResolveAlias };
|
|
2
2
|
import { assert, assertUsage, assertWarning, isValidPathAlias } from '../../utils.js';
|
|
3
3
|
import pc from '@brillout/picocolors';
|
|
4
|
+
// Recommend users to avoid un-distinguishable path aliases.
|
|
5
|
+
// There are a lot of libraries that don't or cannot follow that recommendation, for example:
|
|
6
|
+
// - Nx
|
|
7
|
+
// - Not sure why, but Nx seems to add a path alias for each monorepo package
|
|
8
|
+
// - https://github.com/vikejs/vike/discussions/1134
|
|
9
|
+
// - MUI
|
|
10
|
+
// - https://mui.com/material-ui/guides/minimizing-bundle-size/#how-to-use-custom-bundles
|
|
11
|
+
// - https://github.com/vikejs/vike/discussions/1549#discussioncomment-8789002
|
|
12
|
+
// - @preact/preset-vite
|
|
13
|
+
// - Aliases react imports
|
|
14
|
+
// - @vitejs/plugin-vue2
|
|
15
|
+
// - https://github.com/vikejs/vike/issues/1329
|
|
4
16
|
// TODO/v1-release: replace assertWarning() with assertUsage()
|
|
5
17
|
function assertResolveAlias(config) {
|
|
6
18
|
const aliases = getAliases(config);
|
|
@@ -20,7 +20,7 @@ async function getConfigVikPromise(vikeConfig, config) {
|
|
|
20
20
|
const fromPluginOptions = (vikeConfig ?? {});
|
|
21
21
|
const fromViteConfig = (config.vike ?? {});
|
|
22
22
|
const configs = [fromPluginOptions, fromViteConfig];
|
|
23
|
-
const { globalVikeConfig: fromPlusConfigFile } = await getVikeConfig(config, isDev2(config)
|
|
23
|
+
const { globalVikeConfig: fromPlusConfigFile } = await getVikeConfig(config, isDev2(config));
|
|
24
24
|
configs.push(fromPlusConfigFile);
|
|
25
25
|
assertVikeConfig(fromPlusConfigFile, ({ prop, errMsg }) => {
|
|
26
26
|
// TODO: add config file path ?
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { determineOptimizeDeps };
|
|
2
2
|
import { findPageFiles } from '../../shared/findPageFiles.js';
|
|
3
|
-
import { assert,
|
|
3
|
+
import { assert, getFilePathAbsoluteFilesystem, isNpmPackageImport, unique } from '../../utils.js';
|
|
4
4
|
import { getVikeConfig } from '../importUserCode/v1-design/getVikeConfig.js';
|
|
5
5
|
import { getConfigValueSourcesNotOverriden } from '../../shared/getConfigValueSourcesNotOverriden.js';
|
|
6
6
|
import { analyzeClientEntries } from '../buildConfig.js';
|
|
@@ -35,7 +35,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
35
35
|
const { definedAt, configEnv } = configValueSource;
|
|
36
36
|
if (!configEnv.client)
|
|
37
37
|
return;
|
|
38
|
-
if (definedAt.
|
|
38
|
+
if (definedAt.filePathAbsoluteUserRootDir !== null) {
|
|
39
39
|
const { filePathAbsoluteFilesystem } = definedAt;
|
|
40
40
|
assert(filePathAbsoluteFilesystem);
|
|
41
41
|
// Surprisingly Vite expects entries to be absolute paths
|
|
@@ -70,7 +70,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
70
70
|
{
|
|
71
71
|
const pageFiles = await findPageFiles(config, ['.page', '.page.client'], isDev);
|
|
72
72
|
pageFiles.forEach((filePath) => {
|
|
73
|
-
const entry =
|
|
73
|
+
const entry = getFilePathAbsoluteFilesystem(filePath, config);
|
|
74
74
|
entries.push(entry);
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -2,7 +2,7 @@ export { envVarsPlugin };
|
|
|
2
2
|
// For ./envVars.spec.ts
|
|
3
3
|
export { applyEnvVar };
|
|
4
4
|
import { loadEnv } from 'vite';
|
|
5
|
-
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex,
|
|
5
|
+
import { assert, assertPosixPath, assertUsage, assertWarning, escapeRegex, getFilePathAbsoluteUserRootDir, lowerFirst } from '../utils.js';
|
|
6
6
|
import { sourceMapPassthrough } from '../shared/rollupSourceMap.js';
|
|
7
7
|
function envVarsPlugin() {
|
|
8
8
|
let envsAll;
|
|
@@ -45,7 +45,7 @@ function envVarsPlugin() {
|
|
|
45
45
|
if (isPrivate && isClientSide) {
|
|
46
46
|
if (!code.includes(envStatement))
|
|
47
47
|
return;
|
|
48
|
-
const filePathToShowToUser =
|
|
48
|
+
const filePathToShowToUser = getFilePathAbsoluteUserRootDir(id, config.root);
|
|
49
49
|
const errMsgAddendum = isBuild ? '' : ' (Vike will prevent your app from building for production)';
|
|
50
50
|
const keyPublic = `${publicPrefix}${envName}`;
|
|
51
51
|
const errMsg = `${envStatement} is used in client-side file ${filePathToShowToUser} which means that the environment variable ${envName} will be included in client-side bundles and, therefore, ${envName} will be publicly exposed which can be a security leak${errMsgAddendum}. Use ${envStatement} only in server-side files, or rename ${envName} to ${keyPublic}, see https://vike.dev/env`;
|