vike 0.4.142-commit-acfc159 → 0.4.143-commit-f03b42d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/node/plugin/index.js +2 -2
- package/dist/cjs/node/plugin/plugins/buildConfig.js +4 -5
- package/dist/cjs/node/plugin/plugins/commonConfig.js +1 -6
- package/dist/cjs/node/plugin/plugins/devConfig/determineOptimizeDeps.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/cjs/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +2 -2
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +103 -95
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +37 -27
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +50 -80
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/helpers.js +12 -3
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- package/dist/cjs/node/plugin/plugins/importUserCode/v1-design/transpileAndExecuteFile.js +19 -16
- package/dist/cjs/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +1 -12
- package/dist/cjs/node/plugin/shared/loggerNotProd.js +1 -1
- package/dist/cjs/node/plugin/utils.js +1 -2
- package/dist/cjs/node/prerender/runPrerender.js +13 -16
- package/dist/cjs/node/runtime/html/stream.js +4 -1
- package/dist/cjs/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/cjs/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/cjs/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +1 -1
- package/dist/cjs/shared/error-page.js +1 -1
- package/dist/cjs/shared/getPageFiles/assertPageConfigs.js +13 -13
- package/dist/cjs/shared/getPageFiles/getExports.js +3 -3
- package/dist/cjs/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/cjs/shared/getPageFiles/parsePageConfigsSerialized.js +62 -0
- package/dist/cjs/shared/page-configs/assertExports.js +60 -0
- package/dist/cjs/shared/page-configs/loadConfigValues.js +18 -0
- package/dist/cjs/shared/page-configs/parseConfigValuesImported.js +50 -0
- package/dist/cjs/shared/page-configs/utils.js +1 -1
- package/dist/cjs/shared/route/loadPageRoutes.js +11 -13
- package/dist/cjs/shared/route/resolvePrecedence.js +32 -11
- package/dist/cjs/shared/route/resolveRedirects.js +1 -1
- package/dist/cjs/shared/route/resolveRouteFunction.js +1 -0
- package/dist/cjs/shared/route/resolveRouteString.js +99 -43
- package/dist/cjs/shared/utils.js +1 -1
- package/dist/cjs/types/defineConfig.js +7 -0
- package/dist/cjs/types/index.js +3 -0
- package/dist/cjs/utils/objectAssign.js +3 -1
- package/dist/cjs/utils/projectInfo.js +1 -1
- package/dist/cjs/utils/{resolve.js → requireResolve.js} +3 -3
- package/dist/esm/__internal/index.d.ts +3 -3
- package/dist/esm/client/client-routing-runtime/createPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageContext.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/getPageId.d.ts +2 -2
- package/dist/esm/client/client-routing-runtime/prefetch.js +3 -1
- package/dist/esm/client/client-routing-runtime/useClientRouter.js +2 -2
- package/dist/esm/client/server-routing-runtime/getPageContext.d.ts +1 -1
- package/dist/esm/client/shared/executeOnRenderClientHook.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.d.ts +2 -2
- package/dist/esm/client/shared/loadPageFilesClientSide.js +2 -2
- package/dist/esm/client/shared/preparePageContextForUserConsumptionClientSide.d.ts +2 -2
- package/dist/esm/node/plugin/index.js +3 -2
- package/dist/esm/node/plugin/plugins/buildConfig.js +4 -5
- package/dist/esm/node/plugin/plugins/commonConfig.js +1 -6
- package/dist/esm/node/plugin/plugins/devConfig/determineOptimizeDeps.js +1 -1
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.d.ts +13 -2
- package/dist/esm/node/plugin/plugins/importUserCode/generateEagerImport.js +19 -8
- package/dist/esm/node/plugin/plugins/importUserCode/getVirtualFileImportUserCode.js +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getFilePathToShowToUser.d.ts +8 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.d.ts +2 -2
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.js +104 -96
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts +5 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js +35 -25
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts +3 -0
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.js +49 -79
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/helpers.js +10 -1
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.d.ts +18 -6
- package/dist/esm/node/plugin/plugins/importUserCode/v1-design/replaceImportStatements.js +25 -25
- 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 +19 -16
- package/dist/esm/node/plugin/shared/{getConfigValueSource.d.ts → getConfigValueSourcesRelevant.d.ts} +0 -2
- package/dist/esm/node/plugin/shared/{getConfigValueSource.js → getConfigValueSourcesRelevant.js} +0 -11
- package/dist/esm/node/plugin/shared/loggerNotProd.js +2 -2
- package/dist/esm/node/plugin/utils.d.ts +1 -2
- package/dist/esm/node/plugin/utils.js +1 -2
- package/dist/esm/node/prerender/runPrerender.js +13 -16
- package/dist/esm/node/runtime/html/injectAssets.d.ts +2 -2
- package/dist/esm/node/runtime/html/serializePageContextClientSide.d.ts +2 -2
- package/dist/esm/node/runtime/html/stream.js +4 -1
- package/dist/esm/node/runtime/renderPage/analyzePage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/analyzePage.js +2 -2
- package/dist/esm/node/runtime/renderPage/createHttpResponseObject.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/debugPageFiles.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/handleErrorWithoutErrorPage.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/loadPageFilesServerSide.js +2 -2
- package/dist/esm/node/runtime/renderPage/preparePageContextForUserConsumptionServerSide.d.ts +2 -2
- package/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.d.ts +13 -13
- package/dist/esm/node/shared/getClientEntryFilePath.d.ts +2 -2
- package/dist/esm/node/shared/virtual-files/virtualFilePageConfigValuesAll.js +1 -1
- package/dist/esm/shared/addIs404ToPageProps.d.ts +2 -2
- package/dist/esm/shared/error-page.d.ts +3 -3
- package/dist/esm/shared/error-page.js +1 -1
- package/dist/esm/shared/getPageFiles/analyzeClientSide.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/assertPageConfigs.d.ts +5 -5
- package/dist/esm/shared/getPageFiles/assertPageConfigs.js +12 -12
- package/dist/esm/shared/getPageFiles/getExports.d.ts +2 -2
- package/dist/esm/shared/getPageFiles/getExports.js +1 -1
- package/dist/esm/shared/getPageFiles/parseGlobResults.d.ts +3 -3
- package/dist/esm/shared/getPageFiles/parseGlobResults.js +9 -43
- package/dist/esm/shared/getPageFiles/parsePageConfigsSerialized.d.ts +6 -0
- package/dist/esm/shared/getPageFiles/parsePageConfigsSerialized.js +59 -0
- package/dist/esm/shared/getPageFiles/setPageFiles.d.ts +3 -3
- package/dist/esm/shared/page-configs/Config.d.ts +200 -11
- package/dist/esm/shared/page-configs/PageConfig.d.ts +59 -39
- package/dist/esm/shared/page-configs/assertExports.d.ts +6 -0
- package/dist/esm/shared/page-configs/assertExports.js +54 -0
- package/dist/esm/shared/page-configs/findPageConfig.d.ts +2 -2
- package/dist/esm/shared/page-configs/loadConfigValues.d.ts +3 -0
- package/dist/esm/shared/page-configs/loadConfigValues.js +15 -0
- package/dist/esm/shared/page-configs/parseConfigValuesImported.d.ts +3 -0
- package/dist/esm/shared/page-configs/parseConfigValuesImported.js +44 -0
- package/dist/esm/shared/page-configs/utils.d.ts +3 -2
- package/dist/esm/shared/page-configs/utils.js +1 -1
- package/dist/esm/shared/route/executeGuardHook.d.ts +2 -2
- package/dist/esm/shared/route/index.d.ts +3 -3
- package/dist/esm/shared/route/loadPageRoutes.d.ts +2 -2
- package/dist/esm/shared/route/loadPageRoutes.js +11 -13
- package/dist/esm/shared/route/resolvePrecedence.js +33 -12
- package/dist/esm/shared/route/resolveRedirects.js +1 -1
- package/dist/esm/shared/route/resolveRouteFunction.js +1 -0
- package/dist/esm/shared/route/resolveRouteString.d.ts +21 -4
- package/dist/esm/shared/route/resolveRouteString.js +98 -42
- package/dist/esm/shared/types.d.ts +7 -6
- package/dist/esm/shared/utils.d.ts +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/esm/types/defineConfig.d.ts +3 -0
- package/dist/esm/types/defineConfig.js +4 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/utils/objectAssign.js +3 -1
- package/dist/esm/utils/projectInfo.d.ts +1 -1
- package/dist/esm/utils/projectInfo.js +1 -1
- package/dist/esm/utils/requireResolve.d.ts +2 -0
- package/dist/esm/utils/{resolve.js → requireResolve.js} +2 -2
- package/package.json +3 -3
- package/dist/cjs/shared/page-configs/loadPageCode.js +0 -63
- package/dist/cjs/utils/assertDefaultExport.js +0 -53
- package/dist/esm/shared/page-configs/loadPageCode.d.ts +0 -3
- package/dist/esm/shared/page-configs/loadPageCode.js +0 -57
- package/dist/esm/utils/assertDefaultExport.d.ts +0 -8
- package/dist/esm/utils/assertDefaultExport.js +0 -47
- package/dist/esm/utils/resolve.d.ts +0 -2
- /package/dist/cjs/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.d.ts → assert_exports_old_design.d.ts} +0 -0
- /package/dist/esm/shared/getPageFiles/{assertExports.js → assert_exports_old_design.js} +0 -0
|
@@ -54,7 +54,7 @@ function plugin(vikeConfig) {
|
|
|
54
54
|
}
|
|
55
55
|
exports.plugin = plugin;
|
|
56
56
|
exports.ssr = plugin;
|
|
57
|
-
// Enable `const
|
|
57
|
+
// Enable `const vike = require('vike/plugin')`.
|
|
58
58
|
// - This lives at the end of the file to ensure it happens after all assignments to `exports`.
|
|
59
59
|
// - This is only used for the CJS build; we wrap it in a try-catch for the ESM build.
|
|
60
60
|
try {
|
|
@@ -65,6 +65,6 @@ catch { }
|
|
|
65
65
|
Object.defineProperty(plugin, 'apply', {
|
|
66
66
|
enumerable: true,
|
|
67
67
|
get: () => {
|
|
68
|
-
(0, utils_js_1.assertUsage)(false, `Add ${picocolors_1.default.cyan('
|
|
68
|
+
(0, utils_js_1.assertUsage)(false, `Add ${picocolors_1.default.cyan('vike()')} instead of ${picocolors_1.default.cyan('vike')} to vite.config.js#plugins (i.e. call the function and add the return value instead of adding the function itself)`, { showStackTrace: true });
|
|
69
69
|
}
|
|
70
70
|
});
|
|
@@ -53,8 +53,10 @@ function buildConfig() {
|
|
|
53
53
|
},
|
|
54
54
|
async writeBundle(options, bundle) {
|
|
55
55
|
const manifestEntry = bundle[manifestTempFile];
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
/* Fails with @vitejs/plugin-legacy because writeBundle() is called twice during the client build (once for normal client assets and a second time for legacy assets), see reproduction at https://github.com/vikejs/vike/issues/1154
|
|
57
|
+
assert(generateManifest === !!manifestEntry)
|
|
58
|
+
*/
|
|
59
|
+
if (manifestEntry) {
|
|
58
60
|
const { dir } = options;
|
|
59
61
|
(0, utils_js_1.assert)(dir);
|
|
60
62
|
const manifestFilePathOld = path_1.default.join(dir, manifestEntry.fileName);
|
|
@@ -64,9 +66,6 @@ function buildConfig() {
|
|
|
64
66
|
const manifestFilePathNew = path_1.default.join(dir, '..', 'assets.json');
|
|
65
67
|
await promises_1.default.rename(manifestFilePathOld, manifestFilePathNew);
|
|
66
68
|
}
|
|
67
|
-
else {
|
|
68
|
-
(0, utils_js_1.assert)(!manifestEntry);
|
|
69
|
-
}
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
}
|
|
@@ -19,12 +19,7 @@ function commonConfig() {
|
|
|
19
19
|
{
|
|
20
20
|
name: 'vike-commonConfig-1',
|
|
21
21
|
config: () => ({
|
|
22
|
-
appType: 'custom'
|
|
23
|
-
ssr: {
|
|
24
|
-
// Needed as long as Vike is published as CJS.
|
|
25
|
-
// TODO: can we remove this once Vike is published as ESM?
|
|
26
|
-
external: ['vike', 'vike/server']
|
|
27
|
-
}
|
|
22
|
+
appType: 'custom'
|
|
28
23
|
}),
|
|
29
24
|
configResolved(config) {
|
|
30
25
|
(0, require_shim_1.installRequireShim_setUserRootDir)(config.root);
|
|
@@ -4,7 +4,7 @@ exports.determineOptimizeDeps = void 0;
|
|
|
4
4
|
const findPageFiles_js_1 = require("../../shared/findPageFiles.js");
|
|
5
5
|
const utils_js_1 = require("../../utils.js");
|
|
6
6
|
const getVikeConfig_js_1 = require("../importUserCode/v1-design/getVikeConfig.js");
|
|
7
|
-
const
|
|
7
|
+
const getConfigValueSourcesRelevant_js_1 = require("../../shared/getConfigValueSourcesRelevant.js");
|
|
8
8
|
const buildConfig_js_1 = require("../buildConfig.js");
|
|
9
9
|
const virtualFileImportUserCode_js_1 = require("../../../shared/virtual-files/virtualFileImportUserCode.js");
|
|
10
10
|
async function determineOptimizeDeps(config, configVike, isDev) {
|
|
@@ -33,7 +33,7 @@ async function getPageDeps(config, pageConfigs, isDev) {
|
|
|
33
33
|
// V1 design
|
|
34
34
|
{
|
|
35
35
|
pageConfigs.forEach((pageConfig) => {
|
|
36
|
-
const configValueSourcesRelevant = (0,
|
|
36
|
+
const configValueSourcesRelevant = (0, getConfigValueSourcesRelevant_js_1.getConfigValueSourcesRelevant)(pageConfig);
|
|
37
37
|
configValueSourcesRelevant.forEach((configValueSource) => {
|
|
38
38
|
const { valueIsImportedAtRuntime, configEnv, definedAtInfo } = configValueSource;
|
|
39
39
|
if (!valueIsImportedAtRuntime)
|
|
@@ -2,20 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateEagerImport = void 0;
|
|
4
4
|
let varCounterGlobal = 0;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Naming:
|
|
7
|
+
* `import { someExport as someImport } from './some-file'`
|
|
8
|
+
* <=>
|
|
9
|
+
* `{`
|
|
10
|
+
* `importPath: './some-file',`
|
|
11
|
+
* `exportName: 'someExport',`
|
|
12
|
+
* `importName: 'someImport',`
|
|
13
|
+
* `}`
|
|
14
|
+
* We discard the information that the import variable is called `someImport` because we don't need it.
|
|
15
|
+
*/
|
|
16
|
+
function generateEagerImport(importPath, varCounter, exportName) {
|
|
6
17
|
if (varCounter === undefined)
|
|
7
18
|
varCounter = varCounterGlobal++;
|
|
8
|
-
const
|
|
19
|
+
const importName = `import_${varCounter}`;
|
|
9
20
|
const importLiteral = (() => {
|
|
10
|
-
if (!
|
|
11
|
-
return `* as ${
|
|
21
|
+
if (!exportName || exportName === '*') {
|
|
22
|
+
return `* as ${importName}`;
|
|
12
23
|
}
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
24
|
+
if (exportName === 'default') {
|
|
25
|
+
return importName;
|
|
15
26
|
}
|
|
16
|
-
return `{ ${
|
|
27
|
+
return `{ ${exportName} as ${importName} }`;
|
|
17
28
|
})();
|
|
18
29
|
const importStatement = `import ${importLiteral} from '${importPath}';`;
|
|
19
|
-
return {
|
|
30
|
+
return { importName, importStatement };
|
|
20
31
|
}
|
|
21
32
|
exports.generateEagerImport = generateEagerImport;
|
|
@@ -127,9 +127,9 @@ function addImport(importPath, fileType, exportNames, isBuild) {
|
|
|
127
127
|
return `() => import('${importPath}${query}')`;
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
const {
|
|
130
|
+
const { importName, importStatement } = (0, generateEagerImport_js_1.generateEagerImport)(`${importPath}${query}`);
|
|
131
131
|
fileContent += importStatement + '\n';
|
|
132
|
-
return
|
|
132
|
+
return importName;
|
|
133
133
|
}
|
|
134
134
|
})();
|
|
135
135
|
fileContent += `${mapVar}['${importPath}'] = ${value};\n`;
|
|
@@ -18,16 +18,18 @@ const removeSuperfluousViteLog_js_1 = require("../../../shared/loggerVite/remove
|
|
|
18
18
|
const getFilePathToShowToUser_js_1 = require("./getFilePathToShowToUser.js");
|
|
19
19
|
const picocolors_1 = __importDefault(require("@brillout/picocolors"));
|
|
20
20
|
const utils_js_2 = require("../../../../../shared/page-configs/utils.js");
|
|
21
|
+
const assertExports_js_1 = require("../../../../../shared/page-configs/assertExports.js");
|
|
22
|
+
const getVirtualFilePageConfigs_js_1 = require("./getVirtualFilePageConfigs.js");
|
|
21
23
|
(0, utils_js_1.assertIsNotProductionRuntime)();
|
|
22
24
|
let devServerIsCorrupt = false;
|
|
23
25
|
let wasConfigInvalid = null;
|
|
24
26
|
let vikeConfigPromise = null;
|
|
25
27
|
const vikeConfigDependencies = new Set();
|
|
26
28
|
exports.vikeConfigDependencies = vikeConfigDependencies;
|
|
27
|
-
const
|
|
29
|
+
const filesEnv = new Map();
|
|
28
30
|
function reloadVikeConfig(userRootDir, extensions) {
|
|
29
31
|
vikeConfigDependencies.clear();
|
|
30
|
-
|
|
32
|
+
filesEnv.clear();
|
|
31
33
|
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, true, extensions, true);
|
|
32
34
|
handleReloadSideEffects();
|
|
33
35
|
}
|
|
@@ -101,27 +103,27 @@ async function loadInterfaceFiles(userRootDir, isDev, extensions) {
|
|
|
101
103
|
}));
|
|
102
104
|
// Value files
|
|
103
105
|
await Promise.all(valueFiles.map(async ({ filePathAbsolute, filePathRelativeToUserRootDir }) => {
|
|
104
|
-
const
|
|
105
|
-
(0, utils_js_1.assert)(
|
|
106
|
+
const configName = getConfigName(filePathRelativeToUserRootDir);
|
|
107
|
+
(0, utils_js_1.assert)(configName);
|
|
106
108
|
const interfaceFile = {
|
|
107
109
|
filePath: {
|
|
108
110
|
filePathRelativeToUserRootDir,
|
|
109
111
|
filePathAbsolute
|
|
110
112
|
},
|
|
111
113
|
configMap: {
|
|
112
|
-
[
|
|
114
|
+
[configName]: {}
|
|
113
115
|
},
|
|
114
116
|
isConfigFile: false,
|
|
115
117
|
isValueFile: true,
|
|
116
|
-
|
|
118
|
+
configName
|
|
117
119
|
};
|
|
118
120
|
{
|
|
119
121
|
// We don't have access to custom config definitions yet
|
|
120
|
-
// - We load +
|
|
122
|
+
// - We load +{configName}.js later
|
|
121
123
|
// - But we do need to eagerly load +meta.js (to get all the custom config definitions)
|
|
122
|
-
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn,
|
|
124
|
+
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn, configName);
|
|
123
125
|
if (configDef?.env === 'config-only') {
|
|
124
|
-
await loadValueFile(interfaceFile,
|
|
126
|
+
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
{
|
|
@@ -141,14 +143,13 @@ function getConfigDefinition(configDefinitionsRelevant, configName, definedByFil
|
|
|
141
143
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
142
144
|
return configDefinitions[configName] ?? null;
|
|
143
145
|
}
|
|
144
|
-
async function loadValueFile(interfaceValueFile,
|
|
146
|
+
async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
145
147
|
const { fileExports } = await (0, transpileAndExecuteFile_js_1.transpileAndExecuteFile)(interfaceValueFile.filePath, true, userRootDir);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
interfaceValueFile.configMap[configName] = { configValue };
|
|
148
|
+
const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceValueFile.filePath);
|
|
149
|
+
(0, assertExports_js_1.assertExportsOfValueFile)(fileExports, filePathToShowToUser, configName);
|
|
150
|
+
Object.entries(fileExports).forEach(([exportName, configValue]) => {
|
|
151
|
+
const configName_ = exportName === 'default' ? configName : exportName;
|
|
152
|
+
interfaceValueFile.configMap[configName_] = { configValue };
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
|
|
@@ -161,8 +162,8 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
|
|
|
161
162
|
isConfigExtend,
|
|
162
163
|
extendsFilePaths
|
|
163
164
|
};
|
|
164
|
-
const
|
|
165
|
-
(0,
|
|
165
|
+
const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(filePath);
|
|
166
|
+
(0, assertExports_js_1.assertExportsOfConfigFile)(fileExports, filePathToShowToUser);
|
|
166
167
|
Object.entries(fileExports.default).forEach(([configName, configValue]) => {
|
|
167
168
|
interfaceFile.configMap[configName] = { configValue };
|
|
168
169
|
});
|
|
@@ -201,8 +202,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, extensions,
|
|
|
201
202
|
const dummyData = {
|
|
202
203
|
pageConfigs: [],
|
|
203
204
|
pageConfigGlobal: {
|
|
204
|
-
|
|
205
|
-
onBeforeRoute: null
|
|
205
|
+
configValueSources: {}
|
|
206
206
|
},
|
|
207
207
|
globalVikeConfig: {}
|
|
208
208
|
};
|
|
@@ -222,18 +222,18 @@ async function loadVikeConfig(userRootDir, isDev, extensions) {
|
|
|
222
222
|
await Promise.all(getInterfaceFileList(interfaceFilesRelevant).map(async (interfaceFile) => {
|
|
223
223
|
if (!interfaceFile.isValueFile)
|
|
224
224
|
return;
|
|
225
|
-
const {
|
|
226
|
-
if (isGlobalConfig(
|
|
225
|
+
const { configName } = interfaceFile;
|
|
226
|
+
if (isGlobalConfig(configName))
|
|
227
227
|
return;
|
|
228
|
-
const configDef = getConfigDefinition(configDefinitionsRelevant,
|
|
228
|
+
const configDef = getConfigDefinition(configDefinitionsRelevant, configName, (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(interfaceFile.filePath));
|
|
229
229
|
if (configDef.env !== 'config-only')
|
|
230
230
|
return;
|
|
231
231
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
232
232
|
if (isAlreadyLoaded)
|
|
233
233
|
return;
|
|
234
234
|
// Value files for built-in confg-only configs should have already been loaded at loadInterfaceFiles()
|
|
235
|
-
(0, utils_js_1.assert)(!(
|
|
236
|
-
await loadValueFile(interfaceFile,
|
|
235
|
+
(0, utils_js_1.assert)(!(configName in configDefinitionsBuiltIn_js_1.configDefinitionsBuiltIn));
|
|
236
|
+
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
237
237
|
}));
|
|
238
238
|
const configValueSources = {};
|
|
239
239
|
(0, utils_js_1.objectEntries)(configDefinitionsRelevant)
|
|
@@ -327,17 +327,16 @@ function getGlobalConfigs(interfaceFilesByLocationId, userRootDir) {
|
|
|
327
327
|
}
|
|
328
328
|
const globalVikeConfig = {};
|
|
329
329
|
const pageConfigGlobal = {
|
|
330
|
-
|
|
331
|
-
onPrerenderStart: null
|
|
330
|
+
configValueSources: {}
|
|
332
331
|
};
|
|
333
332
|
(0, utils_js_1.objectEntries)(configDefinitionsBuiltIn_js_1.configDefinitionsBuiltInGlobal).forEach(([configName, configDef]) => {
|
|
334
333
|
const sources = resolveConfigValueSources(configName, configDef, interfaceFilesGlobal, userRootDir);
|
|
335
334
|
const configValueSource = sources?.[0];
|
|
336
335
|
if (!configValueSource)
|
|
337
336
|
return;
|
|
338
|
-
if (
|
|
337
|
+
if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
|
|
339
338
|
(0, utils_js_1.assert)(!('value' in configValueSource));
|
|
340
|
-
pageConfigGlobal[configName] = configValueSource;
|
|
339
|
+
pageConfigGlobal.configValueSources[configName] = [configValueSource];
|
|
341
340
|
}
|
|
342
341
|
else {
|
|
343
342
|
(0, utils_js_1.assert)('value' in configValueSource);
|
|
@@ -370,7 +369,7 @@ function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant
|
|
|
370
369
|
const interfaceValueFiles = interfaceFilesDefiningConfig
|
|
371
370
|
.filter((interfaceFile) => interfaceFile.isValueFile &&
|
|
372
371
|
// We consider side-effect exports (e.g. `export { frontmatter }` of .mdx files) later (i.e. with less priority)
|
|
373
|
-
interfaceFile.
|
|
372
|
+
interfaceFile.configName === configName)
|
|
374
373
|
.sort(makeOrderDeterministic);
|
|
375
374
|
const interfaceConfigFiles = interfaceFilesDefiningConfig
|
|
376
375
|
.filter((interfaceFile) => interfaceFile.isConfigFile &&
|
|
@@ -380,9 +379,9 @@ function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant
|
|
|
380
379
|
const interfaceValueFile = interfaceValueFiles[0];
|
|
381
380
|
const interfaceConfigFile = interfaceConfigFiles[0];
|
|
382
381
|
// Make this value:
|
|
383
|
-
// /pages/some-page/+
|
|
382
|
+
// /pages/some-page/+{configName}.js > `export default`
|
|
384
383
|
// override that value:
|
|
385
|
-
// /pages/some-page/+config > `export default { someConfig }`
|
|
384
|
+
// /pages/some-page/+config.h.js > `export default { someConfig }`
|
|
386
385
|
const interfaceFileWinner = interfaceValueFile ?? interfaceConfigFile;
|
|
387
386
|
if (interfaceFileWinner) {
|
|
388
387
|
const interfaceFilesOverriden = [...interfaceValueFiles, ...interfaceConfigFiles].filter((f) => f !== interfaceFileWinner);
|
|
@@ -397,7 +396,7 @@ function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant
|
|
|
397
396
|
interfaceFilesDefiningConfig
|
|
398
397
|
.filter((interfaceFile) => interfaceFile.isValueFile &&
|
|
399
398
|
// Is side-effect export
|
|
400
|
-
interfaceFile.
|
|
399
|
+
interfaceFile.configName !== configName)
|
|
401
400
|
.forEach((interfaceValueFileSideEffect) => {
|
|
402
401
|
add(interfaceValueFileSideEffect);
|
|
403
402
|
});
|
|
@@ -435,22 +434,22 @@ function isInterfaceFileUserLand(interfaceFile) {
|
|
|
435
434
|
}
|
|
436
435
|
function getConfigValueSource(configName, interfaceFile, configDef, userRootDir) {
|
|
437
436
|
// TODO: rethink file paths of ConfigElement
|
|
438
|
-
const
|
|
437
|
+
const filePathToShowToUser = interfaceFile.filePath.filePathRelativeToUserRootDir ?? interfaceFile.filePath.filePathAbsolute;
|
|
439
438
|
const conf = interfaceFile.configMap[configName];
|
|
440
439
|
(0, utils_js_1.assert)(conf);
|
|
441
440
|
const configEnv = configDef.env;
|
|
442
441
|
const definedAtInfoConfigFile = {
|
|
443
|
-
filePath:
|
|
442
|
+
filePath: filePathToShowToUser,
|
|
444
443
|
fileExportPath: ['default', configName]
|
|
445
444
|
};
|
|
446
445
|
if (configDef._valueIsFilePath) {
|
|
447
446
|
let filePath;
|
|
448
447
|
if (interfaceFile.isConfigFile) {
|
|
449
448
|
const { configValue } = conf;
|
|
450
|
-
const import_ =
|
|
449
|
+
const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
451
450
|
const configDefinedAt = (0, utils_js_2.getConfigDefinedAtString)(configName, { definedAtInfo: definedAtInfoConfigFile }, true);
|
|
452
451
|
(0, utils_js_1.assertUsage)(import_, `${configDefinedAt} should be an import`);
|
|
453
|
-
filePath = import_.
|
|
452
|
+
filePath = import_.filePathToShowToUser;
|
|
454
453
|
}
|
|
455
454
|
else {
|
|
456
455
|
(0, utils_js_1.assert)(interfaceFile.isValueFile);
|
|
@@ -475,17 +474,16 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
475
474
|
if (interfaceFile.isConfigFile) {
|
|
476
475
|
(0, utils_js_1.assert)('configValue' in conf);
|
|
477
476
|
const { configValue } = conf;
|
|
478
|
-
const import_ =
|
|
477
|
+
const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
479
478
|
if (import_) {
|
|
480
|
-
const {
|
|
481
|
-
assertCodeFileEnv(importFilePath, configEnv, configName);
|
|
479
|
+
const { filePathToShowToUser, fileExportName: exportName } = import_;
|
|
482
480
|
const configValueSource = {
|
|
483
481
|
configEnv,
|
|
484
482
|
valueIsImportedAtRuntime: true,
|
|
485
483
|
isComputed: false,
|
|
486
484
|
definedAtInfo: {
|
|
487
|
-
filePath:
|
|
488
|
-
fileExportPath: [
|
|
485
|
+
filePath: filePathToShowToUser,
|
|
486
|
+
fileExportPath: [exportName]
|
|
489
487
|
}
|
|
490
488
|
};
|
|
491
489
|
return configValueSource;
|
|
@@ -503,16 +501,16 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
503
501
|
}
|
|
504
502
|
else if (interfaceFile.isValueFile) {
|
|
505
503
|
// TODO: rethink file paths of ConfigElement
|
|
506
|
-
const
|
|
507
|
-
const
|
|
504
|
+
const importPath = interfaceFile.filePath.filePathRelativeToUserRootDir ?? interfaceFile.filePath.filePathAbsolute;
|
|
505
|
+
const exportName = configName === interfaceFile.configName ? 'default' : configName;
|
|
508
506
|
const valueAlreadyLoaded = 'configValue' in conf;
|
|
509
507
|
const configValueSource = {
|
|
510
508
|
configEnv,
|
|
511
509
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
512
510
|
isComputed: false,
|
|
513
511
|
definedAtInfo: {
|
|
514
|
-
filePath:
|
|
515
|
-
fileExportPath: [
|
|
512
|
+
filePath: importPath,
|
|
513
|
+
fileExportPath: [exportName]
|
|
516
514
|
}
|
|
517
515
|
};
|
|
518
516
|
if (valueAlreadyLoaded) {
|
|
@@ -525,16 +523,17 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
525
523
|
}
|
|
526
524
|
(0, utils_js_1.assert)(false);
|
|
527
525
|
}
|
|
528
|
-
function
|
|
529
|
-
|
|
530
|
-
|
|
526
|
+
function assertFileEnv(filePathForEnvCheck, configEnv, configName) {
|
|
527
|
+
(0, utils_js_1.assertPosixPath)(filePathForEnvCheck);
|
|
528
|
+
if (!filesEnv.has(filePathForEnvCheck)) {
|
|
529
|
+
filesEnv.set(filePathForEnvCheck, []);
|
|
531
530
|
}
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
const configDifferentEnv =
|
|
531
|
+
const fileEnv = filesEnv.get(filePathForEnvCheck);
|
|
532
|
+
fileEnv.push({ configEnv, configName });
|
|
533
|
+
const configDifferentEnv = fileEnv.filter((c) => c.configEnv !== configEnv)[0];
|
|
535
534
|
if (configDifferentEnv) {
|
|
536
535
|
(0, utils_js_1.assertUsage)(false, [
|
|
537
|
-
`${
|
|
536
|
+
`${filePathForEnvCheck} defines the value of configs living in different environments:`,
|
|
538
537
|
...[configDifferentEnv, { configName, configEnv }].map((c) => ` - config ${picocolors_1.default.cyan(c.configName)} which value lives in environment ${picocolors_1.default.cyan(c.configEnv)}`),
|
|
539
538
|
'Defining config values in the same file is allowed only if they live in the same environment, see https://vike.dev/header-file/import-from-same-file'
|
|
540
539
|
].join('\n'));
|
|
@@ -552,53 +551,60 @@ function isDefiningPage(interfaceFiles) {
|
|
|
552
551
|
function isDefiningPageConfig(configName) {
|
|
553
552
|
return ['Page', 'route'].includes(configName);
|
|
554
553
|
}
|
|
555
|
-
function
|
|
554
|
+
function resolveImport(configValue, importerFilePath, userRootDir, configEnv, configName) {
|
|
556
555
|
if (typeof configValue !== 'string')
|
|
557
556
|
return null;
|
|
558
557
|
const importData = (0, replaceImportStatements_js_1.parseImportData)(configValue);
|
|
559
558
|
if (!importData)
|
|
560
559
|
return null;
|
|
561
|
-
|
|
562
|
-
|
|
560
|
+
const { importPath, exportName } = importData;
|
|
561
|
+
const filePathAbsolute = resolveImportPath(importData, importerFilePath);
|
|
562
|
+
let filePathToShowToUser;
|
|
563
|
+
if (importPath.startsWith('.')) {
|
|
563
564
|
// We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
|
|
564
565
|
// ```
|
|
565
566
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
566
567
|
// ```
|
|
567
|
-
|
|
568
|
+
assertImportPath(filePathAbsolute, importData, importerFilePath);
|
|
569
|
+
const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, importerFilePath, userRootDir);
|
|
570
|
+
filePathToShowToUser = filePathRelativeToUserRootDir;
|
|
568
571
|
}
|
|
569
572
|
else {
|
|
570
|
-
//
|
|
573
|
+
// importPath can be:
|
|
571
574
|
// - an npm package import
|
|
572
575
|
// - a path alias
|
|
576
|
+
filePathToShowToUser = importPath;
|
|
577
|
+
}
|
|
578
|
+
{
|
|
579
|
+
const filePathForEnvCheck = filePathAbsolute ?? importPath;
|
|
580
|
+
assertFileEnv(filePathForEnvCheck, configEnv, configName);
|
|
573
581
|
}
|
|
574
582
|
return {
|
|
575
|
-
|
|
576
|
-
|
|
583
|
+
filePathToShowToUser,
|
|
584
|
+
fileExportName: exportName
|
|
577
585
|
};
|
|
578
586
|
}
|
|
579
|
-
function
|
|
580
|
-
let importFilePath = resolveImport(importData, configFilePath);
|
|
581
|
-
// Make it a Vite path
|
|
587
|
+
function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, configFilePath, userRootDir) {
|
|
582
588
|
(0, utils_js_1.assertPosixPath)(userRootDir);
|
|
583
|
-
|
|
584
|
-
if (
|
|
585
|
-
|
|
589
|
+
let filePathRelativeToUserRootDir;
|
|
590
|
+
if (filePathAbsolute.startsWith(userRootDir)) {
|
|
591
|
+
filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsolute, userRootDir);
|
|
586
592
|
}
|
|
587
593
|
else {
|
|
588
|
-
(0, utils_js_1.assertUsage)(false, `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath)} imports from a relative path ${picocolors_1.default.cyan(importData.
|
|
594
|
+
(0, utils_js_1.assertUsage)(false, `${(0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath)} imports from a relative path ${picocolors_1.default.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
|
|
589
595
|
// None of the following works. Seems to be a Vite bug?
|
|
590
596
|
// /*
|
|
591
|
-
// assert(
|
|
592
|
-
//
|
|
597
|
+
// assert(filePathAbsolute.startsWith('/'))
|
|
598
|
+
// filePath = `/@fs${filePathAbsolute}`
|
|
593
599
|
// /*/
|
|
594
|
-
//
|
|
595
|
-
// assert(
|
|
596
|
-
//
|
|
600
|
+
// filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsolute)
|
|
601
|
+
// assert(filePathRelativeToUserRootDir.startsWith('../'))
|
|
602
|
+
// filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir
|
|
597
603
|
// //*/
|
|
598
604
|
}
|
|
599
|
-
(0, utils_js_1.assertPosixPath)(
|
|
600
|
-
(0, utils_js_1.assert)(
|
|
601
|
-
return
|
|
605
|
+
(0, utils_js_1.assertPosixPath)(filePathRelativeToUserRootDir);
|
|
606
|
+
(0, utils_js_1.assert)(filePathRelativeToUserRootDir.startsWith('/'));
|
|
607
|
+
return filePathRelativeToUserRootDir;
|
|
602
608
|
}
|
|
603
609
|
function getVitePathFromAbsolutePath(filePathAbsolute, root) {
|
|
604
610
|
(0, utils_js_1.assertPosixPath)(filePathAbsolute);
|
|
@@ -710,10 +716,9 @@ function applyEffect(configModFromEffect, configValueEffectSource, configValueSo
|
|
|
710
716
|
function applyComputed(pageConfig, configDefinitionsRelevant) {
|
|
711
717
|
(0, utils_js_1.objectEntries)(configDefinitionsRelevant).forEach(([configName, configDef]) => {
|
|
712
718
|
var _a;
|
|
713
|
-
|
|
714
|
-
if (!computed)
|
|
719
|
+
if (!configDef._computed)
|
|
715
720
|
return;
|
|
716
|
-
const value =
|
|
721
|
+
const value = configDef._computed(pageConfig);
|
|
717
722
|
if (value === undefined)
|
|
718
723
|
return;
|
|
719
724
|
const configValueSource = {
|
|
@@ -826,10 +831,11 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
826
831
|
const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
|
|
827
832
|
const extendsConfigFiles = [];
|
|
828
833
|
extendsImportData.map((importData) => {
|
|
829
|
-
const {
|
|
834
|
+
const { importPath: importPath } = importData;
|
|
830
835
|
// TODO
|
|
831
836
|
// - validate extends configs
|
|
832
|
-
const filePathAbsolute =
|
|
837
|
+
const filePathAbsolute = resolveImportPath(importData, configFilePath);
|
|
838
|
+
assertImportPath(filePathAbsolute, importData, configFilePath);
|
|
833
839
|
assertExtendsImportPath(importPath, filePathAbsolute, configFilePath);
|
|
834
840
|
extendsConfigFiles.push({
|
|
835
841
|
filePathAbsolute,
|
|
@@ -875,7 +881,7 @@ function assertExtendsImportPath(importPath, filePath, configFilePath) {
|
|
|
875
881
|
}
|
|
876
882
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
877
883
|
const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(configFilePath);
|
|
878
|
-
(0,
|
|
884
|
+
(0, assertExports_js_1.assertExportsOfConfigFile)(configFileExports, filePathToShowToUser);
|
|
879
885
|
const defaultExports = configFileExports.default;
|
|
880
886
|
const wrongUsage = `${filePathToShowToUser} sets the config 'extends' to an invalid value, see https://vike.dev/extends`;
|
|
881
887
|
let extendList;
|
|
@@ -973,7 +979,7 @@ function determineRouteFilesystem(locationId, configValueSources) {
|
|
|
973
979
|
const configFilesystemRoutingRoot = configValueSources[configName]?.[0];
|
|
974
980
|
let filesystemRouteString = (0, filesystemRouting_js_1.getFilesystemRouteString)(locationId);
|
|
975
981
|
if (determineIsErrorPage(filesystemRouteString)) {
|
|
976
|
-
return { isErrorPage: true, routeFilesystem:
|
|
982
|
+
return { isErrorPage: true, routeFilesystem: undefined };
|
|
977
983
|
}
|
|
978
984
|
let filesystemRouteDefinedBy = (0, filesystemRouting_js_1.getFilesystemRouteDefinedBy)(locationId); // for log404()
|
|
979
985
|
if (configFilesystemRoutingRoot) {
|
|
@@ -991,7 +997,7 @@ function determineRouteFilesystem(locationId, configValueSources) {
|
|
|
991
997
|
routeString: filesystemRouteString,
|
|
992
998
|
definedBy: filesystemRouteDefinedBy
|
|
993
999
|
};
|
|
994
|
-
return { routeFilesystem, isErrorPage:
|
|
1000
|
+
return { routeFilesystem, isErrorPage: undefined };
|
|
995
1001
|
}
|
|
996
1002
|
function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName) {
|
|
997
1003
|
(0, utils_js_1.assert)(configFilesystemRoutingRoot.configEnv === 'config-only');
|
|
@@ -1011,22 +1017,22 @@ function determineIsErrorPage(routeFilesystem) {
|
|
|
1011
1017
|
(0, utils_js_1.assertPosixPath)(routeFilesystem);
|
|
1012
1018
|
return routeFilesystem.split('/').includes('_error');
|
|
1013
1019
|
}
|
|
1014
|
-
function
|
|
1015
|
-
const
|
|
1016
|
-
(0, utils_js_1.assertPosixPath)(
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
return
|
|
1020
|
+
function resolveImportPath(importData, importerFilePath) {
|
|
1021
|
+
const importerFilePathAbsolute = importerFilePath.filePathAbsolute;
|
|
1022
|
+
(0, utils_js_1.assertPosixPath)(importerFilePathAbsolute);
|
|
1023
|
+
const cwd = path_1.default.posix.dirname(importerFilePathAbsolute);
|
|
1024
|
+
// filePathAbsolute is expected to be null when importData.importPath is a Vite path alias
|
|
1025
|
+
const filePathAbsolute = (0, utils_js_1.requireResolve)(importData.importPath, cwd);
|
|
1026
|
+
return filePathAbsolute;
|
|
1021
1027
|
}
|
|
1022
|
-
function
|
|
1023
|
-
const {
|
|
1028
|
+
function assertImportPath(filePathAbsolute, importData, importerFilePath) {
|
|
1029
|
+
const { importPath: importPath, importStringWasGenerated, importString } = importData;
|
|
1024
1030
|
const filePathToShowToUser = (0, getFilePathToShowToUser_js_1.getFilePathToShowToUser)(importerFilePath);
|
|
1025
|
-
if (!
|
|
1031
|
+
if (!filePathAbsolute) {
|
|
1026
1032
|
const importPathString = picocolors_1.default.cyan(`'${importPath}'`);
|
|
1027
|
-
const errIntro =
|
|
1033
|
+
const errIntro = importStringWasGenerated
|
|
1028
1034
|
? `The import path ${importPathString} in ${filePathToShowToUser}`
|
|
1029
|
-
: `The import ${picocolors_1.default.cyan(
|
|
1035
|
+
: `The import ${picocolors_1.default.cyan(importString)} defined in ${filePathToShowToUser}`;
|
|
1030
1036
|
const errIntro2 = `${errIntro} couldn't be resolved: does ${importPathString}`;
|
|
1031
1037
|
if (importPath.startsWith('.')) {
|
|
1032
1038
|
(0, utils_js_1.assertUsage)(false, `${errIntro2} point to an existing file?`);
|
|
@@ -1078,6 +1084,8 @@ function mergeCumulative(configName, configValueSources) {
|
|
|
1078
1084
|
/* This is more confusing than adding value. For example, this explanation shouldn't be shown for the passToClient config.
|
|
1079
1085
|
const explanation = `(Because the values of ${configNameColored} are cumulative and therefore merged together.)` as const
|
|
1080
1086
|
*/
|
|
1087
|
+
// Make sure configValueSource.value is serializable
|
|
1088
|
+
(0, getVirtualFilePageConfigs_js_1.getConfigValueSerialized)(configValueSource.value, configName, configValueSource.definedAtInfo);
|
|
1081
1089
|
const assertNoMixing = (isSet) => {
|
|
1082
1090
|
const vals1 = isSet ? valuesSet : valuesArr;
|
|
1083
1091
|
const t1 = isSet ? 'a Set' : 'an array';
|