vike 0.4.168-commit-ce94f5c → 0.4.168-commit-42406a9
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/buildConfig.js +10 -2
- package/dist/cjs/node/plugin/plugins/commonConfig/assertResolveAlias.js +1 -1
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +19 -16
- package/dist/cjs/node/plugin/plugins/distFileNames.js +7 -1
- package/dist/cjs/node/plugin/plugins/envVars.js +1 -5
- package/dist/cjs/node/plugin/plugins/importUserCode/index.js +7 -7
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +11 -14
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/{resolveImportPath.js → resolvePointerImport.js} +58 -44
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +8 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +52 -12
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +2 -2
- package/dist/cjs/node/plugin/shared/getFilePath.js +44 -48
- package/dist/cjs/node/plugin/utils.js +2 -2
- package/dist/cjs/node/prerender/runPrerender.js +6 -5
- package/dist/cjs/node/prerender/utils.js +2 -1
- package/dist/cjs/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/cjs/node/runtime/index-common.js +14 -3
- package/dist/cjs/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
- package/dist/cjs/node/runtime/renderPage/loadUserFilesServerSide.js +25 -14
- package/dist/cjs/node/runtime/renderPage/log404/index.js +2 -2
- package/dist/cjs/node/runtime/renderPage/logErrorHint.js +1 -1
- package/dist/cjs/node/runtime/utils.js +2 -1
- package/dist/cjs/node/shared/assertV1Design.js +1 -1
- package/dist/cjs/node/shared/getClientEntry.js +2 -2
- package/dist/cjs/node/shared/prependEntriesDir.js +1 -0
- package/dist/cjs/node/shared/utils.js +0 -1
- package/dist/cjs/shared/getPageFiles/analyzeClientSide.js +3 -3
- package/dist/cjs/shared/getPageFiles/getExports.js +8 -15
- package/dist/cjs/shared/getPageFiles.js +3 -6
- package/dist/cjs/shared/hooks/getHook.js +7 -6
- package/dist/cjs/shared/page-configs/getConfigDefinedAt.js +48 -0
- package/dist/cjs/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
- package/dist/cjs/shared/page-configs/helpers.js +6 -11
- package/dist/cjs/shared/page-configs/serialize/assertPageConfigsSerialized.js +1 -1
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
- package/dist/cjs/shared/page-configs/serialize/parseConfigValuesSerialized.js +11 -6
- package/dist/cjs/shared/page-configs/serialize/parsePageConfigs.js +4 -3
- package/dist/cjs/shared/page-configs/serialize/serializeConfigValue.js +3 -3
- package/dist/cjs/shared/route/index.js +2 -2
- package/dist/cjs/shared/route/loadPageRoutes.js +12 -10
- package/dist/cjs/shared/route/resolveRouteFunction.js +8 -9
- package/dist/cjs/shared/route/resolveRouteString.js +5 -16
- package/dist/cjs/shared/route/utils.js +0 -1
- package/dist/cjs/shared/utils.js +1 -0
- package/dist/cjs/utils/assertPathFilesystemAbsolute.js +39 -0
- package/dist/cjs/utils/createErrorWithCleanStackTrace.js +1 -7
- package/dist/cjs/utils/debug.js +2 -1
- package/dist/cjs/utils/findFile.js +2 -1
- package/dist/cjs/utils/hasProp.js +9 -5
- package/dist/cjs/utils/injectRollupInputs.js +2 -1
- package/dist/cjs/utils/isArray.js +8 -0
- package/dist/cjs/utils/isArrayOfStrings.js +8 -0
- package/dist/cjs/utils/isDev.js +12 -4
- package/dist/cjs/utils/isNpmPackage.js +1 -1
- package/dist/cjs/utils/isObjectOfStrings.js +8 -0
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.d.ts +3 -1
- package/dist/esm/client/client-routing-runtime/getPageContextFromHooks.js +2 -1
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -0
- package/dist/esm/client/shared/getPageContextSerializedInHtml.d.ts +1 -0
- package/dist/esm/client/shared/getPageContextSerializedInHtml.js +1 -0
- package/dist/esm/client/shared/loadUserFilesClientSide.js +3 -7
- package/dist/esm/node/plugin/plugins/buildConfig.js +9 -1
- package/dist/esm/node/plugin/plugins/commonConfig/assertResolveAlias.js +2 -2
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +20 -17
- package/dist/esm/node/plugin/plugins/distFileNames.js +8 -2
- package/dist/esm/node/plugin/plugins/envVars.js +2 -6
- package/dist/esm/node/plugin/plugins/importUserCode/index.js +9 -9
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getConfigValuesSerialized.js +14 -11
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/configDefinitionsBuiltIn.d.ts +4 -3
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/filesystemRouting.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/loadFileAtConfigTime.js +12 -15
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.d.ts +12 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolvePointerImport.js +123 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.d.ts +8 -8
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transformFileImports.js +7 -7
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/transpileAndExecuteFile.js +53 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +81 -106
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/node/plugin/shared/getFilePath.d.ts +11 -5
- package/dist/esm/node/plugin/shared/getFilePath.js +43 -47
- package/dist/esm/node/plugin/utils.d.ts +2 -2
- package/dist/esm/node/plugin/utils.js +2 -2
- package/dist/esm/node/prerender/runPrerender.js +6 -5
- package/dist/esm/node/prerender/utils.d.ts +2 -1
- package/dist/esm/node/prerender/utils.js +2 -1
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +1 -0
- package/dist/esm/node/runtime/html/serializePageContextClientSide.js +1 -0
- package/dist/esm/node/runtime/index-common.d.ts +0 -4
- package/dist/esm/node/runtime/index-common.js +14 -3
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject/getCacheControl.js +2 -1
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.d.ts +4 -4
- package/dist/esm/node/runtime/renderPage/loadUserFilesServerSide.js +27 -16
- package/dist/esm/node/runtime/renderPage/log404/index.js +2 -2
- package/dist/esm/node/runtime/renderPage/logErrorHint.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -7
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +16 -16
- package/dist/esm/node/runtime/utils.d.ts +2 -1
- package/dist/esm/node/runtime/utils.js +2 -1
- package/dist/esm/node/shared/assertV1Design.js +1 -1
- package/dist/esm/node/shared/getClientEntry.js +1 -1
- package/dist/esm/node/shared/prependEntriesDir.js +1 -0
- package/dist/esm/node/shared/utils.d.ts +0 -1
- package/dist/esm/node/shared/utils.js +0 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.js +1 -1
- package/dist/esm/shared/getPageFiles/getExports.d.ts +4 -5
- package/dist/esm/shared/getPageFiles/getExports.js +9 -16
- package/dist/esm/shared/getPageFiles.d.ts +1 -2
- package/dist/esm/shared/getPageFiles.js +1 -3
- package/dist/esm/shared/hooks/getHook.js +6 -5
- package/dist/esm/shared/page-configs/Config.d.ts +2 -2
- package/dist/esm/shared/page-configs/FilePath.d.ts +32 -22
- package/dist/esm/shared/page-configs/PageConfig.d.ts +27 -15
- package/dist/esm/shared/page-configs/getConfigDefinedAt.d.ts +11 -0
- package/dist/esm/shared/page-configs/getConfigDefinedAt.js +42 -0
- package/dist/esm/shared/page-configs/{helpers/getConfigValue.d.ts → getConfigValue.d.ts} +2 -2
- package/dist/esm/shared/page-configs/{helpers/getConfigValue.js → getConfigValue.js} +6 -8
- package/dist/esm/shared/page-configs/helpers.d.ts +3 -9
- package/dist/esm/shared/page-configs/helpers.js +6 -8
- package/dist/esm/shared/page-configs/serialize/PageConfigSerialized.d.ts +7 -4
- package/dist/esm/shared/page-configs/serialize/assertPageConfigsSerialized.js +2 -2
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesImported.js +2 -1
- package/dist/esm/shared/page-configs/serialize/parseConfigValuesSerialized.js +12 -7
- package/dist/esm/shared/page-configs/serialize/parsePageConfigs.js +5 -4
- package/dist/esm/shared/page-configs/serialize/serializeConfigValue.js +3 -3
- package/dist/esm/shared/route/index.js +2 -2
- package/dist/esm/shared/route/loadPageRoutes.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.js +10 -8
- package/dist/esm/shared/route/resolveRouteFunction.d.ts +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +9 -10
- package/dist/esm/shared/route/resolveRouteString.d.ts +0 -2
- package/dist/esm/shared/route/resolveRouteString.js +5 -16
- package/dist/esm/shared/route/utils.d.ts +0 -1
- package/dist/esm/shared/route/utils.js +0 -1
- package/dist/esm/shared/utils.d.ts +1 -0
- package/dist/esm/shared/utils.js +1 -0
- package/dist/esm/utils/assertPathFilesystemAbsolute.d.ts +6 -0
- package/dist/esm/utils/assertPathFilesystemAbsolute.js +33 -0
- package/dist/esm/utils/createErrorWithCleanStackTrace.js +1 -7
- package/dist/esm/utils/debug.js +2 -1
- package/dist/esm/utils/findFile.js +2 -1
- package/dist/esm/utils/hasProp.d.ts +1 -0
- package/dist/esm/utils/hasProp.js +9 -5
- package/dist/esm/utils/injectRollupInputs.js +2 -1
- package/dist/esm/utils/isArray.d.ts +1 -0
- package/dist/esm/utils/isArray.js +4 -0
- package/dist/esm/utils/isArrayOfStrings.d.ts +2 -0
- package/dist/esm/utils/isArrayOfStrings.js +5 -0
- package/dist/esm/utils/isDev.d.ts +3 -0
- package/dist/esm/utils/isDev.js +11 -3
- package/dist/esm/utils/isNpmPackage.js +1 -1
- package/dist/esm/utils/isObjectOfStrings.d.ts +2 -0
- package/dist/esm/utils/isObjectOfStrings.js +5 -0
- package/dist/esm/utils/projectInfo.d.ts +2 -2
- package/dist/esm/utils/projectInfo.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -43
- package/dist/cjs/utils/assertPathIsFilesystemAbsolute.js +0 -21
- package/dist/cjs/utils/isStringRecord.js +0 -7
- package/dist/cjs/utils/mergeCumulativeValues.js +0 -21
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.d.ts +0 -13
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig/resolveImportPath.js +0 -109
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.d.ts +0 -7
- package/dist/esm/shared/page-configs/helpers/getConfigDefinedAtString.js +0 -37
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.d.ts +0 -3
- package/dist/esm/utils/assertPathIsFilesystemAbsolute.js +0 -15
- package/dist/esm/utils/isStringRecord.d.ts +0 -1
- package/dist/esm/utils/isStringRecord.js +0 -3
- package/dist/esm/utils/mergeCumulativeValues.d.ts +0 -2
- package/dist/esm/utils/mergeCumulativeValues.js +0 -18
|
@@ -14,12 +14,12 @@ const globalContext_js_1 = require("../../../../runtime/globalContext.js");
|
|
|
14
14
|
const loggerNotProd_js_1 = require("../../../shared/loggerNotProd.js");
|
|
15
15
|
const removeSuperfluousViteLog_js_1 = require("../../../shared/loggerVite/removeSuperfluousViteLog.js");
|
|
16
16
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
17
|
-
const
|
|
17
|
+
const getConfigDefinedAt_js_1 = require("../../../../../shared/page-configs/getConfigDefinedAt.js");
|
|
18
18
|
const getConfigValuesSerialized_js_1 = require("./getConfigValuesSerialized.js");
|
|
19
19
|
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
|
-
const
|
|
22
|
+
const resolvePointerImport_js_1 = require("./getVikeConfig/resolvePointerImport.js");
|
|
23
23
|
const getFilePath_js_1 = require("../../../shared/getFilePath.js");
|
|
24
24
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
25
25
|
let devServerIsCorrupt = false;
|
|
@@ -29,7 +29,7 @@ const vikeConfigDependencies = new Set();
|
|
|
29
29
|
exports.vikeConfigDependencies = vikeConfigDependencies;
|
|
30
30
|
function reloadVikeConfig(userRootDir, outDirRoot) {
|
|
31
31
|
vikeConfigDependencies.clear();
|
|
32
|
-
(0,
|
|
32
|
+
(0, resolvePointerImport_js_1.clearFilesEnvMap)();
|
|
33
33
|
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, outDirRoot, true, true);
|
|
34
34
|
handleReloadSideEffects();
|
|
35
35
|
}
|
|
@@ -270,6 +270,7 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
270
270
|
if (isGlobalConfig(configName))
|
|
271
271
|
return;
|
|
272
272
|
const configDef = getConfigDefinition(configDefinitions, configName, interfaceFile.filePath.filePathToShowToUser);
|
|
273
|
+
configDef.env = deriveConfigEnvFromFileName(configDef.env, interfaceFile.filePath.fileName);
|
|
273
274
|
if (!isConfigEnv(configDef, configName))
|
|
274
275
|
return;
|
|
275
276
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
@@ -306,6 +307,22 @@ async function loadVikeConfig(userRootDir, outDirRoot, isDev) {
|
|
|
306
307
|
assertPageConfigs(pageConfigs);
|
|
307
308
|
return { pageConfigs, pageConfigGlobal, globalVikeConfig };
|
|
308
309
|
}
|
|
310
|
+
function deriveConfigEnvFromFileName(env, fileName) {
|
|
311
|
+
env = { ...env };
|
|
312
|
+
if (fileName.includes('.server.')) {
|
|
313
|
+
env.server = true;
|
|
314
|
+
env.client = false;
|
|
315
|
+
}
|
|
316
|
+
else if (fileName.includes('.client.')) {
|
|
317
|
+
env.client = true;
|
|
318
|
+
env.server = false;
|
|
319
|
+
}
|
|
320
|
+
else if (fileName.includes('.shared.')) {
|
|
321
|
+
env.server = true;
|
|
322
|
+
env.client = true;
|
|
323
|
+
}
|
|
324
|
+
return env;
|
|
325
|
+
}
|
|
309
326
|
function assertPageConfigs(pageConfigs) {
|
|
310
327
|
pageConfigs.forEach((pageConfig) => {
|
|
311
328
|
assertOnBeforeRenderEnv(pageConfig);
|
|
@@ -392,7 +409,7 @@ async function getGlobalConfigs(interfaceFilesByLocationId, userRootDir, importe
|
|
|
392
409
|
(0, utils_js_1.assert)('value' in configValueSource);
|
|
393
410
|
if (configName === 'prerender' && typeof configValueSource.value === 'boolean')
|
|
394
411
|
return;
|
|
395
|
-
const { filePathToShowToUser } = configValueSource.
|
|
412
|
+
const { filePathToShowToUser } = configValueSource.definedAtFilePath;
|
|
396
413
|
(0, utils_js_1.assertWarning)(false, `Being able to define config ${picocolors_1.default.cyan(configName)} in ${filePathToShowToUser} is experimental and will likely be removed. Define the config ${picocolors_1.default.cyan(configName)} in Vike's Vite plugin options instead.`, { onlyOnce: true });
|
|
397
414
|
globalVikeConfig[configName] = configValueSource.value;
|
|
398
415
|
}
|
|
@@ -486,26 +503,26 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
486
503
|
(0, utils_js_1.assert)(conf);
|
|
487
504
|
const configEnv = configDef.env;
|
|
488
505
|
const { locationId } = interfaceFile;
|
|
489
|
-
const
|
|
506
|
+
const definedAtFilePath_ = {
|
|
490
507
|
...interfaceFile.filePath,
|
|
491
508
|
fileExportPathToShowToUser: ['default', configName]
|
|
492
509
|
};
|
|
493
510
|
// +client.js
|
|
494
511
|
if (configDef._valueIsFilePath) {
|
|
495
|
-
let
|
|
512
|
+
let definedAtFilePath;
|
|
496
513
|
let valueFilePath;
|
|
497
514
|
if (interfaceFile.isConfigFile) {
|
|
498
515
|
const { configValue } = conf;
|
|
499
|
-
const
|
|
500
|
-
const configDefinedAt = (0,
|
|
501
|
-
(0, utils_js_1.assertUsage)(
|
|
502
|
-
valueFilePath =
|
|
503
|
-
|
|
516
|
+
const pointerImport = (0, resolvePointerImport_js_1.resolvePointerImportOfConfig)(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
517
|
+
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, definedAtFilePath_);
|
|
518
|
+
(0, utils_js_1.assertUsage)(pointerImport, `${configDefinedAt} should be an import`);
|
|
519
|
+
valueFilePath = pointerImport.filePathAbsoluteVite;
|
|
520
|
+
definedAtFilePath = pointerImport;
|
|
504
521
|
}
|
|
505
522
|
else {
|
|
506
523
|
(0, utils_js_1.assert)(interfaceFile.isValueFile);
|
|
507
524
|
valueFilePath = interfaceFile.filePath.filePathAbsoluteVite;
|
|
508
|
-
|
|
525
|
+
definedAtFilePath = {
|
|
509
526
|
...interfaceFile.filePath,
|
|
510
527
|
fileExportPathToShowToUser: []
|
|
511
528
|
};
|
|
@@ -517,7 +534,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
517
534
|
configEnv,
|
|
518
535
|
valueIsImportedAtRuntime: true,
|
|
519
536
|
valueIsDefinedByValueFile: false,
|
|
520
|
-
|
|
537
|
+
definedAtFilePath
|
|
521
538
|
};
|
|
522
539
|
return configValueSource;
|
|
523
540
|
}
|
|
@@ -525,28 +542,26 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
525
542
|
if (interfaceFile.isConfigFile) {
|
|
526
543
|
(0, utils_js_1.assert)('configValue' in conf);
|
|
527
544
|
const { configValue } = conf;
|
|
528
|
-
//
|
|
529
|
-
const
|
|
530
|
-
if (
|
|
545
|
+
// Pointer import
|
|
546
|
+
const pointerImport = (0, resolvePointerImport_js_1.resolvePointerImportOfConfig)(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
547
|
+
if (pointerImport) {
|
|
531
548
|
const configValueSource = {
|
|
532
549
|
locationId,
|
|
533
550
|
configEnv,
|
|
534
551
|
valueIsImportedAtRuntime: true,
|
|
535
552
|
valueIsDefinedByValueFile: false,
|
|
536
|
-
|
|
553
|
+
definedAtFilePath: pointerImport
|
|
537
554
|
};
|
|
538
555
|
// Load fake import
|
|
539
556
|
if (isConfigEnv(configDef, configName) &&
|
|
540
557
|
// The value of `extends` was already loaded and already used: we don't need the value of `extends` anymore
|
|
541
558
|
configName !== 'extends') {
|
|
542
|
-
if (
|
|
543
|
-
|
|
544
|
-
(0, utils_js_1.assert)((0, utils_js_1.hasProp)(import_, 'filePathToShowToUserResolved', 'string')); // Help TS
|
|
545
|
-
const fileExport = await (0, loadFileAtConfigTime_js_1.loadImportedFile)(import_, userRootDir, importedFilesLoaded);
|
|
559
|
+
if (pointerImport.filePathAbsoluteFilesystem) {
|
|
560
|
+
const fileExport = await (0, loadFileAtConfigTime_js_1.loadImportedFile)(pointerImport, userRootDir, importedFilesLoaded);
|
|
546
561
|
configValueSource.value = fileExport;
|
|
547
562
|
}
|
|
548
563
|
else {
|
|
549
|
-
const configDefinedAt = (0,
|
|
564
|
+
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, configValueSource.definedAtFilePath);
|
|
550
565
|
(0, utils_js_1.assertUsage)(!configDef.cumulative, `${configDefinedAt} cannot be defined over an aliased import`);
|
|
551
566
|
}
|
|
552
567
|
}
|
|
@@ -559,7 +574,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
559
574
|
configEnv,
|
|
560
575
|
valueIsImportedAtRuntime: false,
|
|
561
576
|
valueIsDefinedByValueFile: false,
|
|
562
|
-
|
|
577
|
+
definedAtFilePath: definedAtFilePath_
|
|
563
578
|
};
|
|
564
579
|
return configValueSource;
|
|
565
580
|
}
|
|
@@ -572,7 +587,7 @@ async function getConfigValueSource(configName, interfaceFile, configDef, userRo
|
|
|
572
587
|
configEnv,
|
|
573
588
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
574
589
|
valueIsDefinedByValueFile: true,
|
|
575
|
-
|
|
590
|
+
definedAtFilePath: {
|
|
576
591
|
...interfaceFile.filePath,
|
|
577
592
|
fileExportPathToShowToUser: configName === interfaceFile.configName
|
|
578
593
|
? []
|
|
@@ -610,12 +625,12 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
610
625
|
return;
|
|
611
626
|
const meta = configMeta.configValue;
|
|
612
627
|
assertMetaValue(meta, `Config ${picocolors_1.default.cyan('meta')} defined at ${interfaceFile.filePath.filePathToShowToUser}`);
|
|
613
|
-
// Set configDef.
|
|
628
|
+
// Set configDef._userEffectDefinedAtFilePath
|
|
614
629
|
Object.entries(meta).forEach(([configName, configDef]) => {
|
|
615
630
|
if (!configDef.effect)
|
|
616
631
|
return;
|
|
617
632
|
(0, utils_js_1.assert)(interfaceFile.isConfigFile);
|
|
618
|
-
configDef.
|
|
633
|
+
configDef._userEffectDefinedAtFilePath = {
|
|
619
634
|
...interfaceFile.filePath,
|
|
620
635
|
fileExportPathToShowToUser: ['default', 'meta', configName, 'effect']
|
|
621
636
|
};
|
|
@@ -632,24 +647,24 @@ function getConfigDefinitions(interfaceFilesRelevant) {
|
|
|
632
647
|
const configDefinitions = configDefinitionsMerged;
|
|
633
648
|
return configDefinitions;
|
|
634
649
|
}
|
|
635
|
-
function assertMetaValue(metaVal,
|
|
650
|
+
function assertMetaValue(metaVal, metaConfigDefinedAt) {
|
|
636
651
|
if (!(0, utils_js_1.isObject)(metaVal)) {
|
|
637
|
-
(0, utils_js_1.assert)(
|
|
638
|
-
(0, utils_js_1.assertUsage)(false, `${
|
|
652
|
+
(0, utils_js_1.assert)(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
653
|
+
(0, utils_js_1.assertUsage)(false, `${metaConfigDefinedAt} has an invalid type ${picocolors_1.default.cyan(typeof metaVal)}: it should be an object instead.`);
|
|
639
654
|
}
|
|
640
655
|
(0, utils_js_1.objectEntries)(metaVal).forEach(([configName, def]) => {
|
|
641
656
|
if (!(0, utils_js_1.isObject)(def)) {
|
|
642
|
-
(0, utils_js_1.assert)(
|
|
643
|
-
(0, utils_js_1.assertUsage)(false, `${
|
|
657
|
+
(0, utils_js_1.assert)(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
658
|
+
(0, utils_js_1.assertUsage)(false, `${metaConfigDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}`)} to a value with an invalid type ${picocolors_1.default.cyan(typeof def)}: it should be an object instead.`);
|
|
644
659
|
}
|
|
645
660
|
// env
|
|
646
661
|
let configEnv;
|
|
647
662
|
{
|
|
648
|
-
(0, utils_js_1.assert)(
|
|
663
|
+
(0, utils_js_1.assert)(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
649
664
|
if (!('env' in def)) {
|
|
650
|
-
(0, utils_js_1.assertUsage)(false, `${
|
|
665
|
+
(0, utils_js_1.assertUsage)(false, `${metaConfigDefinedAt} doesn't set ${picocolors_1.default.cyan(`meta.${configName}.env`)} but it's required.`);
|
|
651
666
|
}
|
|
652
|
-
configEnv = getConfigEnvValue(def.env, `${
|
|
667
|
+
configEnv = getConfigEnvValue(def.env, `${metaConfigDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.env`)} to`);
|
|
653
668
|
// Overwrite deprecated value with valid value
|
|
654
669
|
// TODO/v1-release: remove once support for the deprecated values is removed
|
|
655
670
|
if (typeof def.env === 'string')
|
|
@@ -658,12 +673,12 @@ function assertMetaValue(metaVal, configMetaDefinedAt) {
|
|
|
658
673
|
// effect
|
|
659
674
|
if ('effect' in def) {
|
|
660
675
|
if (!(0, utils_js_1.hasProp)(def, 'effect', 'function')) {
|
|
661
|
-
(0, utils_js_1.assert)(
|
|
662
|
-
(0, utils_js_1.assertUsage)(false, `${
|
|
676
|
+
(0, utils_js_1.assert)(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
677
|
+
(0, utils_js_1.assertUsage)(false, `${metaConfigDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.effect`)} to an invalid type ${picocolors_1.default.cyan(typeof def.effect)}: it should be a function instead`);
|
|
663
678
|
}
|
|
664
679
|
if (!configEnv.config) {
|
|
665
|
-
(0, utils_js_1.assert)(
|
|
666
|
-
(0, utils_js_1.assertUsage)(false, `${
|
|
680
|
+
(0, utils_js_1.assert)(metaConfigDefinedAt); // We expect internal effects to return a valid meta value
|
|
681
|
+
(0, utils_js_1.assertUsage)(false, `${metaConfigDefinedAt} sets ${picocolors_1.default.cyan(`meta.${configName}.effect`)} but it's only supported if meta.${configName}.env has ${picocolors_1.default.cyan('{ config: true }')} (but it's ${picocolors_1.default.cyan(JSON.stringify(configEnv))} instead)`);
|
|
667
682
|
}
|
|
668
683
|
}
|
|
669
684
|
});
|
|
@@ -685,7 +700,7 @@ function applyEffectsAll(configValueSources, configDefinitions) {
|
|
|
685
700
|
// Call effect
|
|
686
701
|
const configModFromEffect = configDef.effect({
|
|
687
702
|
configValue: source.value,
|
|
688
|
-
configDefinedAt: (0,
|
|
703
|
+
configDefinedAt: (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, source.definedAtFilePath)
|
|
689
704
|
});
|
|
690
705
|
if (!configModFromEffect)
|
|
691
706
|
return;
|
|
@@ -697,16 +712,14 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
697
712
|
const notSupported = `Effects currently only supports modifying the the ${picocolors_1.default.cyan('env')} of a config.`;
|
|
698
713
|
(0, utils_js_1.objectEntries)(configModFromEffect).forEach(([configName, configValue]) => {
|
|
699
714
|
if (configName === 'meta') {
|
|
700
|
-
let
|
|
701
|
-
if (configDefEffect.
|
|
702
|
-
|
|
703
|
-
definedAt: configDefEffect._userEffectDefinedAt
|
|
704
|
-
});
|
|
715
|
+
let configDefinedAt;
|
|
716
|
+
if (configDefEffect._userEffectDefinedAtFilePath) {
|
|
717
|
+
configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, configDefEffect._userEffectDefinedAtFilePath);
|
|
705
718
|
}
|
|
706
719
|
else {
|
|
707
|
-
|
|
720
|
+
configDefinedAt = null;
|
|
708
721
|
}
|
|
709
|
-
assertMetaValue(configValue,
|
|
722
|
+
assertMetaValue(configValue, configDefinedAt);
|
|
710
723
|
(0, utils_js_1.objectEntries)(configValue).forEach(([configTargetName, configTargetDef]) => {
|
|
711
724
|
{
|
|
712
725
|
const keys = Object.keys(configTargetDef);
|
|
@@ -724,7 +737,7 @@ function applyEffect(configModFromEffect, configValueSources, configDefEffect) {
|
|
|
724
737
|
else {
|
|
725
738
|
(0, utils_js_1.assertUsage)(false, notSupported);
|
|
726
739
|
// If we do end implementing being able to set the value of a config:
|
|
727
|
-
// - For setting
|
|
740
|
+
// - For setting definedAtFile: we could take the definedAtFile of the effect config while appending '(effect)' to definedAtFile.fileExportPathToShowToUser
|
|
728
741
|
}
|
|
729
742
|
});
|
|
730
743
|
}
|
|
@@ -832,11 +845,11 @@ function determineRouteFilesystem(locationId, configValueSources) {
|
|
|
832
845
|
if (configFilesystemRoutingRoot) {
|
|
833
846
|
const routingRoot = getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName);
|
|
834
847
|
if (routingRoot) {
|
|
835
|
-
const { filesystemRoutingRootEffect /*,
|
|
848
|
+
const { filesystemRoutingRootEffect /*, filesystemRoutingRootConfigDefinedAt*/ } = routingRoot;
|
|
836
849
|
const debugInfo = { locationId, routeFilesystem: filesystemRouteString, configFilesystemRoutingRoot };
|
|
837
850
|
(0, utils_js_1.assert)(filesystemRouteString.startsWith(filesystemRoutingRootEffect.before), debugInfo);
|
|
838
851
|
filesystemRouteString = (0, filesystemRouting_js_1.applyFilesystemRoutingRootEffect)(filesystemRouteString, filesystemRoutingRootEffect);
|
|
839
|
-
// filesystemRouteDefinedBy = `${filesystemRouteDefinedBy} (with ${
|
|
852
|
+
// filesystemRouteDefinedBy = `${filesystemRouteDefinedBy} (with ${filesystemRoutingRootConfigDefinedAt})`
|
|
840
853
|
}
|
|
841
854
|
}
|
|
842
855
|
(0, utils_js_1.assert)(filesystemRouteString.startsWith('/'));
|
|
@@ -851,15 +864,15 @@ function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName)
|
|
|
851
864
|
// Eagerly loaded since it's config-only
|
|
852
865
|
(0, utils_js_1.assert)('value' in configFilesystemRoutingRoot);
|
|
853
866
|
const { value } = configFilesystemRoutingRoot;
|
|
854
|
-
const configDefinedAt = (0,
|
|
867
|
+
const configDefinedAt = (0, getConfigDefinedAt_js_1.getConfigDefinedAt)('Config', configName, configFilesystemRoutingRoot.definedAtFilePath);
|
|
855
868
|
(0, utils_js_1.assertUsage)(typeof value === 'string', `${configDefinedAt} should be a string`);
|
|
856
869
|
(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('/')}`);
|
|
857
|
-
const { filePathAbsoluteUserRootDir } = configFilesystemRoutingRoot.
|
|
870
|
+
const { filePathAbsoluteUserRootDir } = configFilesystemRoutingRoot.definedAtFilePath;
|
|
858
871
|
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
859
872
|
const before = (0, filesystemRouting_js_1.getFilesystemRouteString)((0, filesystemRouting_js_1.getLocationId)(filePathAbsoluteUserRootDir));
|
|
860
873
|
const after = value;
|
|
861
874
|
const filesystemRoutingRootEffect = { before, after };
|
|
862
|
-
return { filesystemRoutingRootEffect,
|
|
875
|
+
return { filesystemRoutingRootEffect, filesystemRoutingRootConfigDefinedAt: configDefinedAt };
|
|
863
876
|
}
|
|
864
877
|
function determineIsErrorPage(routeFilesystem) {
|
|
865
878
|
(0, utils_js_1.assertPosixPath)(routeFilesystem);
|
|
@@ -873,8 +886,9 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
|
|
|
873
886
|
const configValues = {};
|
|
874
887
|
Object.entries(configValuesComputed).forEach(([configName, configValueComputed]) => {
|
|
875
888
|
configValues[configName] = {
|
|
889
|
+
type: 'computed',
|
|
876
890
|
value: configValueComputed.value,
|
|
877
|
-
|
|
891
|
+
definedAtData: null
|
|
878
892
|
};
|
|
879
893
|
});
|
|
880
894
|
Object.entries(configValueSources).forEach(([configName, sources]) => {
|
|
@@ -884,18 +898,20 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
|
|
|
884
898
|
const configValueSource = sources[0];
|
|
885
899
|
if ('value' in configValueSource) {
|
|
886
900
|
configValues[configName] = {
|
|
901
|
+
type: 'classic',
|
|
887
902
|
value: configValueSource.value,
|
|
888
|
-
|
|
903
|
+
definedAtData: getDefinedAtFile(configValueSource)
|
|
889
904
|
};
|
|
890
905
|
}
|
|
891
906
|
}
|
|
892
907
|
else {
|
|
893
908
|
const value = mergeCumulative(configName, sources);
|
|
909
|
+
const definedAtData = sources.map((source) => getDefinedAtFile(source));
|
|
910
|
+
(0, utils_js_1.assert)(value.length === definedAtData.length);
|
|
894
911
|
configValues[configName] = {
|
|
912
|
+
type: 'cumulative',
|
|
895
913
|
value,
|
|
896
|
-
|
|
897
|
-
files: sources.map((source) => getDefinedAtFile(source))
|
|
898
|
-
}
|
|
914
|
+
definedAtData
|
|
899
915
|
};
|
|
900
916
|
}
|
|
901
917
|
});
|
|
@@ -903,62 +919,21 @@ function getConfigValues(configValueSources, configValuesComputed, configDefinit
|
|
|
903
919
|
}
|
|
904
920
|
function getDefinedAtFile(configValueSource) {
|
|
905
921
|
return {
|
|
906
|
-
filePathToShowToUser: configValueSource.
|
|
907
|
-
fileExportPathToShowToUser: configValueSource.
|
|
922
|
+
filePathToShowToUser: configValueSource.definedAtFilePath.filePathToShowToUser,
|
|
923
|
+
fileExportPathToShowToUser: configValueSource.definedAtFilePath.fileExportPathToShowToUser
|
|
908
924
|
};
|
|
909
925
|
}
|
|
910
|
-
function getDefinedAt(configValueSource) {
|
|
911
|
-
return getDefinedAtFile(configValueSource);
|
|
912
|
-
}
|
|
913
926
|
function mergeCumulative(configName, configValueSources) {
|
|
914
|
-
const
|
|
915
|
-
const valuesSet = [];
|
|
916
|
-
let configValueSourcePrevious = null;
|
|
927
|
+
const configValues = [];
|
|
917
928
|
configValueSources.forEach((configValueSource) => {
|
|
918
|
-
const configDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSource);
|
|
919
929
|
// We could, in principle, also support cumulative for values that aren't loaded at config-time but it isn't completely trivial to implement.
|
|
920
930
|
(0, utils_js_1.assert)('value' in configValueSource);
|
|
921
931
|
// Make sure configValueSource.value is serializable
|
|
922
|
-
(0, getConfigValuesSerialized_js_1.assertConfigValueIsSerializable)(configValueSource.value, configName,
|
|
923
|
-
const assertNoMixing = (isSet) => {
|
|
924
|
-
const vals1 = isSet ? valuesSet : valuesArr;
|
|
925
|
-
const t1 = isSet ? 'a Set' : 'an array';
|
|
926
|
-
const vals2 = !isSet ? valuesSet : valuesArr;
|
|
927
|
-
const t2 = !isSet ? 'a Set' : 'an array';
|
|
928
|
-
(0, utils_js_1.assert)(vals1.length > 0);
|
|
929
|
-
if (vals2.length === 0)
|
|
930
|
-
return;
|
|
931
|
-
(0, utils_js_1.assert)(configValueSourcePrevious);
|
|
932
|
-
const configPreviousDefinedAt = (0, helpers_js_1.getConfigDefinedAtString)('Config', configName, configValueSourcePrevious);
|
|
933
|
-
(0, utils_js_1.assertUsage)(false, `${configDefinedAt} sets ${t1} but another ${configPreviousDefinedAt} sets ${t2} which is forbidden: the values must be all arrays or all sets (you cannot mix).`);
|
|
934
|
-
};
|
|
932
|
+
(0, getConfigValuesSerialized_js_1.assertConfigValueIsSerializable)(configValueSource.value, configName, getDefinedAtFile(configValueSource));
|
|
935
933
|
const { value } = configValueSource;
|
|
936
|
-
|
|
937
|
-
valuesArr.push(value);
|
|
938
|
-
assertNoMixing(false);
|
|
939
|
-
}
|
|
940
|
-
else if (value instanceof Set) {
|
|
941
|
-
valuesSet.push(value);
|
|
942
|
-
assertNoMixing(true);
|
|
943
|
-
}
|
|
944
|
-
else {
|
|
945
|
-
(0, utils_js_1.assertUsage)(false, `${configDefinedAt} must be an array or a Set`);
|
|
946
|
-
}
|
|
947
|
-
configValueSourcePrevious = configValueSource;
|
|
934
|
+
configValues.push(value);
|
|
948
935
|
});
|
|
949
|
-
|
|
950
|
-
(0, utils_js_1.assert)(valuesSet.length === 0);
|
|
951
|
-
const result = (0, utils_js_1.mergeCumulativeValues)(valuesArr);
|
|
952
|
-
(0, utils_js_1.assert)(result !== null);
|
|
953
|
-
return result;
|
|
954
|
-
}
|
|
955
|
-
if (valuesSet.length > 0) {
|
|
956
|
-
(0, utils_js_1.assert)(valuesArr.length === 0);
|
|
957
|
-
const result = (0, utils_js_1.mergeCumulativeValues)(valuesSet);
|
|
958
|
-
(0, utils_js_1.assert)(result !== null);
|
|
959
|
-
return result;
|
|
960
|
-
}
|
|
961
|
-
(0, utils_js_1.assert)(false);
|
|
936
|
+
return configValues;
|
|
962
937
|
}
|
|
963
938
|
function getConfigEnvValue(val, errMsgIntro) {
|
|
964
939
|
const errInvalidValue = `${errMsgIntro} an invalid value ${picocolors_1.default.cyan(JSON.stringify(val))}`;
|
|
@@ -1028,10 +1003,10 @@ function assertConfigExists(configName, configNamesRelevant, filePathToShowToUse
|
|
|
1028
1003
|
function sortConfigValueSources(configValueSources, locationIdPage) {
|
|
1029
1004
|
return Object.fromEntries(Object.entries(configValueSources)
|
|
1030
1005
|
// Make order deterministic (no other purpose)
|
|
1031
|
-
.sort(([, [source1]], [, [source2]]) => source1.
|
|
1006
|
+
.sort(([, [source1]], [, [source2]]) => source1.definedAtFilePath.filePathAbsoluteVite < source2.definedAtFilePath.filePathAbsoluteVite ? -1 : 1)
|
|
1032
1007
|
// Sort after whether the config value was defined by an npm package
|
|
1033
1008
|
.sort((0, utils_js_1.makeFirst)(([, [source]]) => {
|
|
1034
|
-
const { importPathAbsolute } = source.
|
|
1009
|
+
const { importPathAbsolute } = source.definedAtFilePath;
|
|
1035
1010
|
return (!!importPathAbsolute &&
|
|
1036
1011
|
(0, utils_js_1.isNpmPackageImport)(importPathAbsolute, {
|
|
1037
1012
|
// Vike config files don't support path aliases. (If they do one day, then Vike will/should be able to resolve path aliases.)
|
package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -6,7 +6,7 @@ const virtualFilePageConfigValuesAll_js_1 = require("../../../../shared/virtual-
|
|
|
6
6
|
const getVikeConfig_js_1 = require("./getVikeConfig.js");
|
|
7
7
|
const extractAssetsQuery_js_1 = require("../../../../shared/extractAssetsQuery.js");
|
|
8
8
|
const debug_js_1 = require("./debug.js");
|
|
9
|
-
const
|
|
9
|
+
const getConfigValue_js_1 = require("../../../../../shared/page-configs/getConfigValue.js");
|
|
10
10
|
const getConfigValueSourcesNotOverriden_js_1 = require("../../../shared/getConfigValueSourcesNotOverriden.js");
|
|
11
11
|
const isRuntimeEnvMatch_js_1 = require("./isRuntimeEnvMatch.js");
|
|
12
12
|
const serializeConfigValue_js_1 = require("../../../../../shared/page-configs/serialize/serializeConfigValue.js");
|
|
@@ -35,7 +35,7 @@ exports.getVirtualFilePageConfigValuesAll = getVirtualFilePageConfigValuesAll;
|
|
|
35
35
|
function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAssetsImportedByServer, isDev) {
|
|
36
36
|
const lines = [];
|
|
37
37
|
const importStatements = [];
|
|
38
|
-
const isClientRouting = (0,
|
|
38
|
+
const isClientRouting = (0, getConfigValue_js_1.getConfigValue)(pageConfig, 'clientRouting', 'boolean')?.value ?? false;
|
|
39
39
|
lines.push('export const configValuesImported = [');
|
|
40
40
|
lines.push(getConfigValuesImported(pageConfig, isForClientSide, isClientRouting, importStatements));
|
|
41
41
|
lines.push('];');
|
|
@@ -3,16 +3,11 @@ 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.cleanFilePathUnkown = exports.getFilePathToShowToUserFromUnkown = exports.getModuleFilePath = exports.getFilePathUnresolved = exports.getFilePathResolved = void 0;
|
|
6
|
+
exports.getFilePathAbsoluteUserRootDir = exports.cleanFilePathUnkown = exports.getFilePathToShowToUserFromUnkown = exports.getModuleFilePath = exports.getFilePathUnresolved = exports.getFilePathResolved = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const utils_js_1 = require("../utils.js");
|
|
9
|
-
function getFilePathUnresolved({ importPathAbsolute }) {
|
|
10
|
-
return getFilePath({ importPathAbsolute, filePathAbsoluteUserRootDir: null });
|
|
11
|
-
}
|
|
12
|
-
exports.getFilePathUnresolved = getFilePathUnresolved;
|
|
13
9
|
function getFilePathResolved(args) {
|
|
14
10
|
const { userRootDir } = args;
|
|
15
|
-
const importPathAbsolute = args.importPathAbsolute ?? null;
|
|
16
11
|
let filePathAbsoluteFilesystem;
|
|
17
12
|
let filePathAbsoluteUserRootDir;
|
|
18
13
|
if ('filePathAbsoluteFilesystem' in args) {
|
|
@@ -23,68 +18,68 @@ function getFilePathResolved(args) {
|
|
|
23
18
|
filePathAbsoluteUserRootDir = args.filePathAbsoluteUserRootDir;
|
|
24
19
|
filePathAbsoluteFilesystem = getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir });
|
|
25
20
|
}
|
|
26
|
-
let filePath;
|
|
27
|
-
const common = {
|
|
28
|
-
filePathAbsoluteUserRootDir,
|
|
29
|
-
importPathAbsolute,
|
|
30
|
-
userRootDir
|
|
31
|
-
};
|
|
32
|
-
if (importPathAbsolute) {
|
|
33
|
-
filePath = getFilePath({
|
|
34
|
-
...common,
|
|
35
|
-
importPathAbsolute
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir);
|
|
40
|
-
filePath = getFilePath({
|
|
41
|
-
...common,
|
|
42
|
-
filePathAbsoluteUserRootDir
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
21
|
(0, utils_js_1.assert)(filePathAbsoluteFilesystem);
|
|
46
|
-
(0, utils_js_1.
|
|
22
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
47
23
|
const filePathToShowToUserResolved = filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
|
|
48
24
|
(0, utils_js_1.assert)(filePathToShowToUserResolved);
|
|
25
|
+
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
26
|
+
const fileName = path_1.default.posix.basename(filePathAbsoluteFilesystem);
|
|
49
27
|
const filePathResolved = {
|
|
50
|
-
...
|
|
28
|
+
...getComputedProps(args),
|
|
51
29
|
filePathAbsoluteFilesystem,
|
|
52
|
-
filePathToShowToUserResolved
|
|
30
|
+
filePathToShowToUserResolved,
|
|
31
|
+
fileName
|
|
53
32
|
};
|
|
54
33
|
return filePathResolved;
|
|
55
34
|
}
|
|
56
35
|
exports.getFilePathResolved = getFilePathResolved;
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
function getComputedProps(args) {
|
|
37
|
+
if ('filePathAbsoluteUserRootDir' in args) {
|
|
38
|
+
const importPathAbsolute = args.importPathAbsolute ?? null;
|
|
39
|
+
const { filePathAbsoluteUserRootDir } = args;
|
|
40
|
+
if (importPathAbsolute)
|
|
41
|
+
(0, utils_js_1.assertIsNpmPackageImport)(importPathAbsolute);
|
|
42
|
+
return {
|
|
43
|
+
importPathAbsolute,
|
|
44
|
+
filePathAbsoluteUserRootDir,
|
|
45
|
+
filePathAbsoluteVite: filePathAbsoluteUserRootDir,
|
|
46
|
+
filePathToShowToUser: filePathAbsoluteUserRootDir
|
|
47
|
+
};
|
|
61
48
|
}
|
|
62
49
|
else {
|
|
63
|
-
|
|
64
|
-
filePathAbsoluteVite = args.importPathAbsolute;
|
|
50
|
+
return getComputedPropsImportPathAbsolute(args);
|
|
65
51
|
}
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
}
|
|
53
|
+
function getComputedPropsImportPathAbsolute(args) {
|
|
54
|
+
const { importPathAbsolute } = args;
|
|
55
|
+
(0, utils_js_1.assertIsNpmPackageImport)(importPathAbsolute);
|
|
68
56
|
return {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
filePathAbsoluteVite,
|
|
72
|
-
filePathToShowToUser
|
|
57
|
+
filePathAbsoluteUserRootDir: null,
|
|
58
|
+
importPathAbsolute,
|
|
59
|
+
filePathAbsoluteVite: importPathAbsolute,
|
|
60
|
+
filePathToShowToUser: importPathAbsolute
|
|
73
61
|
};
|
|
74
62
|
}
|
|
63
|
+
function getFilePathUnresolved(args) {
|
|
64
|
+
return {
|
|
65
|
+
...getComputedPropsImportPathAbsolute(args),
|
|
66
|
+
filePathAbsoluteFilesystem: null
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
exports.getFilePathUnresolved = getFilePathUnresolved;
|
|
75
70
|
function getFilePathAbsoluteUserFilesystem({ filePathAbsoluteUserRootDir, userRootDir }) {
|
|
76
71
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteUserRootDir);
|
|
77
72
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
78
|
-
(0, utils_js_1.
|
|
73
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
|
|
79
74
|
const filePathAbsoluteFilesystem = path_1.default.posix.join(userRootDir, filePathAbsoluteUserRootDir);
|
|
80
|
-
(0, utils_js_1.
|
|
75
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
|
|
81
76
|
return filePathAbsoluteFilesystem;
|
|
82
77
|
}
|
|
83
78
|
function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir }) {
|
|
84
79
|
(0, utils_js_1.assertPosixPath)(filePathAbsoluteFilesystem);
|
|
85
80
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
86
|
-
(0, utils_js_1.
|
|
87
|
-
(0, utils_js_1.
|
|
81
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
82
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
|
|
88
83
|
const filePathRelative = path_1.default.posix.relative(userRootDir, filePathAbsoluteFilesystem);
|
|
89
84
|
if (!filePathAbsoluteFilesystem.startsWith(userRootDir)) {
|
|
90
85
|
(0, utils_js_1.assert)(filePathRelative.startsWith('../'));
|
|
@@ -100,21 +95,22 @@ function getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDi
|
|
|
100
95
|
(0, utils_js_1.assert)(filePathAbsoluteUserRootDir === getFilePathAbsoluteUserRootDir2(filePathAbsoluteFilesystem, userRootDir));
|
|
101
96
|
return filePathAbsoluteUserRootDir;
|
|
102
97
|
}
|
|
98
|
+
exports.getFilePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir;
|
|
103
99
|
function getModuleFilePath(moduleId, config) {
|
|
104
100
|
const userRootDir = config.root;
|
|
105
101
|
(0, utils_js_1.assertPosixPath)(moduleId);
|
|
106
102
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
107
103
|
const filePathAbsoluteFilesystem = cleanModuleId(moduleId);
|
|
108
|
-
(0, utils_js_1.
|
|
109
|
-
const
|
|
110
|
-
return
|
|
104
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(filePathAbsoluteFilesystem);
|
|
105
|
+
const filePathAbsoluteUserRootDir = getFilePathAbsoluteUserRootDir({ filePathAbsoluteFilesystem, userRootDir });
|
|
106
|
+
return filePathAbsoluteUserRootDir || filePathAbsoluteFilesystem;
|
|
111
107
|
}
|
|
112
108
|
exports.getModuleFilePath = getModuleFilePath;
|
|
113
109
|
function getFilePathToShowToUserFromUnkown(
|
|
114
110
|
// We don't have any guarentee about filePath, e.g. about whether is filePathAbsoluteFilesystem or filePathAbsoluteUserRootDir
|
|
115
111
|
filePathUnkown, userRootDir) {
|
|
116
112
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
117
|
-
(0, utils_js_1.
|
|
113
|
+
(0, utils_js_1.assertPathFilesystemAbsolute)(userRootDir);
|
|
118
114
|
filePathUnkown = cleanFilePathUnkown(filePathUnkown);
|
|
119
115
|
if (!filePathUnkown.startsWith(userRootDir)) {
|
|
120
116
|
return filePathUnkown;
|
|
@@ -34,11 +34,11 @@ __exportStar(require("../../utils/trimWithAnsi.js"), exports);
|
|
|
34
34
|
__exportStar(require("../../utils/removeEmptyLines.js"), exports);
|
|
35
35
|
__exportStar(require("../../utils/findFile.js"), exports);
|
|
36
36
|
__exportStar(require("../../utils/getPropAccessNotation.js"), exports);
|
|
37
|
-
__exportStar(require("../../utils/mergeCumulativeValues.js"), exports);
|
|
38
37
|
__exportStar(require("../../utils/deepEqual.js"), exports);
|
|
39
38
|
__exportStar(require("../../utils/assertKeys.js"), exports);
|
|
40
39
|
__exportStar(require("../../utils/injectRollupInputs.js"), exports);
|
|
41
40
|
__exportStar(require("../../utils/humanizeTime.js"), exports);
|
|
42
41
|
__exportStar(require("../../utils/pLimit.js"), exports);
|
|
43
42
|
__exportStar(require("../../utils/assertVersion.js"), exports);
|
|
44
|
-
__exportStar(require("../../utils/
|
|
43
|
+
__exportStar(require("../../utils/assertPathFilesystemAbsolute.js"), exports);
|
|
44
|
+
__exportStar(require("../../utils/isArray.js"), exports);
|