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
|
@@ -2,7 +2,7 @@ export { getVikeConfig };
|
|
|
2
2
|
export { reloadVikeConfig };
|
|
3
3
|
export { vikeConfigDependencies };
|
|
4
4
|
export { isVikeConfigFile };
|
|
5
|
-
import { assertPosixPath, assert, isObject, assertUsage, toPosixPath, assertWarning,
|
|
5
|
+
import { assertPosixPath, assert, isObject, assertUsage, toPosixPath, assertWarning, objectEntries, hasProp, arrayIncludes, assertIsNotProductionRuntime, getMostSimilar, isNpmPackageImport, joinEnglish, lowerFirst, scriptFileExtensions, mergeCumulativeValues, requireResolve } from '../../../utils.js';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { configDefinitionsBuiltIn, configDefinitionsBuiltInGlobal } from './getVikeConfig/configDefinitionsBuiltIn.js';
|
|
8
8
|
import glob from 'fast-glob';
|
|
@@ -16,15 +16,17 @@ import { removeSuperfluousViteLog_enable, removeSuperfluousViteLog_disable } fro
|
|
|
16
16
|
import { getFilePathToShowToUser } from './getFilePathToShowToUser.js';
|
|
17
17
|
import pc from '@brillout/picocolors';
|
|
18
18
|
import { getConfigDefinedAtString } from '../../../../../shared/page-configs/utils.js';
|
|
19
|
+
import { assertExportsOfConfigFile, assertExportsOfValueFile } from '../../../../../shared/page-configs/assertExports.js';
|
|
20
|
+
import { getConfigValueSerialized } from './getVirtualFilePageConfigs.js';
|
|
19
21
|
assertIsNotProductionRuntime();
|
|
20
22
|
let devServerIsCorrupt = false;
|
|
21
23
|
let wasConfigInvalid = null;
|
|
22
24
|
let vikeConfigPromise = null;
|
|
23
25
|
const vikeConfigDependencies = new Set();
|
|
24
|
-
const
|
|
26
|
+
const filesEnv = new Map();
|
|
25
27
|
function reloadVikeConfig(userRootDir, extensions) {
|
|
26
28
|
vikeConfigDependencies.clear();
|
|
27
|
-
|
|
29
|
+
filesEnv.clear();
|
|
28
30
|
vikeConfigPromise = loadVikeConfig_withErrorHandling(userRootDir, true, extensions, true);
|
|
29
31
|
handleReloadSideEffects();
|
|
30
32
|
}
|
|
@@ -96,27 +98,27 @@ async function loadInterfaceFiles(userRootDir, isDev, extensions) {
|
|
|
96
98
|
}));
|
|
97
99
|
// Value files
|
|
98
100
|
await Promise.all(valueFiles.map(async ({ filePathAbsolute, filePathRelativeToUserRootDir }) => {
|
|
99
|
-
const
|
|
100
|
-
assert(
|
|
101
|
+
const configName = getConfigName(filePathRelativeToUserRootDir);
|
|
102
|
+
assert(configName);
|
|
101
103
|
const interfaceFile = {
|
|
102
104
|
filePath: {
|
|
103
105
|
filePathRelativeToUserRootDir,
|
|
104
106
|
filePathAbsolute
|
|
105
107
|
},
|
|
106
108
|
configMap: {
|
|
107
|
-
[
|
|
109
|
+
[configName]: {}
|
|
108
110
|
},
|
|
109
111
|
isConfigFile: false,
|
|
110
112
|
isValueFile: true,
|
|
111
|
-
|
|
113
|
+
configName
|
|
112
114
|
};
|
|
113
115
|
{
|
|
114
116
|
// We don't have access to custom config definitions yet
|
|
115
|
-
// - We load +
|
|
117
|
+
// - We load +{configName}.js later
|
|
116
118
|
// - But we do need to eagerly load +meta.js (to get all the custom config definitions)
|
|
117
|
-
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn,
|
|
119
|
+
const configDef = getConfigDefinitionOptional(configDefinitionsBuiltIn, configName);
|
|
118
120
|
if (configDef?.env === 'config-only') {
|
|
119
|
-
await loadValueFile(interfaceFile,
|
|
121
|
+
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
{
|
|
@@ -136,14 +138,13 @@ function getConfigDefinition(configDefinitionsRelevant, configName, definedByFil
|
|
|
136
138
|
function getConfigDefinitionOptional(configDefinitions, configName) {
|
|
137
139
|
return configDefinitions[configName] ?? null;
|
|
138
140
|
}
|
|
139
|
-
async function loadValueFile(interfaceValueFile,
|
|
141
|
+
async function loadValueFile(interfaceValueFile, configName, userRootDir) {
|
|
140
142
|
const { fileExports } = await transpileAndExecuteFile(interfaceValueFile.filePath, true, userRootDir);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
interfaceValueFile.configMap[configName] = { configValue };
|
|
143
|
+
const filePathToShowToUser = getFilePathToShowToUser(interfaceValueFile.filePath);
|
|
144
|
+
assertExportsOfValueFile(fileExports, filePathToShowToUser, configName);
|
|
145
|
+
Object.entries(fileExports).forEach(([exportName, configValue]) => {
|
|
146
|
+
const configName_ = exportName === 'default' ? configName : exportName;
|
|
147
|
+
interfaceValueFile.configMap[configName_] = { configValue };
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
150
|
function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
|
|
@@ -156,8 +157,8 @@ function getInterfaceFileFromConfigFile(configFile, isConfigExtend) {
|
|
|
156
157
|
isConfigExtend,
|
|
157
158
|
extendsFilePaths
|
|
158
159
|
};
|
|
159
|
-
const
|
|
160
|
-
|
|
160
|
+
const filePathToShowToUser = getFilePathToShowToUser(filePath);
|
|
161
|
+
assertExportsOfConfigFile(fileExports, filePathToShowToUser);
|
|
161
162
|
Object.entries(fileExports.default).forEach(([configName, configValue]) => {
|
|
162
163
|
interfaceFile.configMap[configName] = { configValue };
|
|
163
164
|
});
|
|
@@ -196,8 +197,7 @@ async function loadVikeConfig_withErrorHandling(userRootDir, isDev, extensions,
|
|
|
196
197
|
const dummyData = {
|
|
197
198
|
pageConfigs: [],
|
|
198
199
|
pageConfigGlobal: {
|
|
199
|
-
|
|
200
|
-
onBeforeRoute: null
|
|
200
|
+
configValueSources: {}
|
|
201
201
|
},
|
|
202
202
|
globalVikeConfig: {}
|
|
203
203
|
};
|
|
@@ -217,18 +217,18 @@ async function loadVikeConfig(userRootDir, isDev, extensions) {
|
|
|
217
217
|
await Promise.all(getInterfaceFileList(interfaceFilesRelevant).map(async (interfaceFile) => {
|
|
218
218
|
if (!interfaceFile.isValueFile)
|
|
219
219
|
return;
|
|
220
|
-
const {
|
|
221
|
-
if (isGlobalConfig(
|
|
220
|
+
const { configName } = interfaceFile;
|
|
221
|
+
if (isGlobalConfig(configName))
|
|
222
222
|
return;
|
|
223
|
-
const configDef = getConfigDefinition(configDefinitionsRelevant,
|
|
223
|
+
const configDef = getConfigDefinition(configDefinitionsRelevant, configName, getFilePathToShowToUser(interfaceFile.filePath));
|
|
224
224
|
if (configDef.env !== 'config-only')
|
|
225
225
|
return;
|
|
226
226
|
const isAlreadyLoaded = interfacefileIsAlreaydLoaded(interfaceFile);
|
|
227
227
|
if (isAlreadyLoaded)
|
|
228
228
|
return;
|
|
229
229
|
// Value files for built-in confg-only configs should have already been loaded at loadInterfaceFiles()
|
|
230
|
-
assert(!(
|
|
231
|
-
await loadValueFile(interfaceFile,
|
|
230
|
+
assert(!(configName in configDefinitionsBuiltIn));
|
|
231
|
+
await loadValueFile(interfaceFile, configName, userRootDir);
|
|
232
232
|
}));
|
|
233
233
|
const configValueSources = {};
|
|
234
234
|
objectEntries(configDefinitionsRelevant)
|
|
@@ -322,17 +322,16 @@ function getGlobalConfigs(interfaceFilesByLocationId, userRootDir) {
|
|
|
322
322
|
}
|
|
323
323
|
const globalVikeConfig = {};
|
|
324
324
|
const pageConfigGlobal = {
|
|
325
|
-
|
|
326
|
-
onPrerenderStart: null
|
|
325
|
+
configValueSources: {}
|
|
327
326
|
};
|
|
328
327
|
objectEntries(configDefinitionsBuiltInGlobal).forEach(([configName, configDef]) => {
|
|
329
328
|
const sources = resolveConfigValueSources(configName, configDef, interfaceFilesGlobal, userRootDir);
|
|
330
329
|
const configValueSource = sources?.[0];
|
|
331
330
|
if (!configValueSource)
|
|
332
331
|
return;
|
|
333
|
-
if (
|
|
332
|
+
if (configName === 'onBeforeRoute' || configName === 'onPrerenderStart') {
|
|
334
333
|
assert(!('value' in configValueSource));
|
|
335
|
-
pageConfigGlobal[configName] = configValueSource;
|
|
334
|
+
pageConfigGlobal.configValueSources[configName] = [configValueSource];
|
|
336
335
|
}
|
|
337
336
|
else {
|
|
338
337
|
assert('value' in configValueSource);
|
|
@@ -365,7 +364,7 @@ function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant
|
|
|
365
364
|
const interfaceValueFiles = interfaceFilesDefiningConfig
|
|
366
365
|
.filter((interfaceFile) => interfaceFile.isValueFile &&
|
|
367
366
|
// We consider side-effect exports (e.g. `export { frontmatter }` of .mdx files) later (i.e. with less priority)
|
|
368
|
-
interfaceFile.
|
|
367
|
+
interfaceFile.configName === configName)
|
|
369
368
|
.sort(makeOrderDeterministic);
|
|
370
369
|
const interfaceConfigFiles = interfaceFilesDefiningConfig
|
|
371
370
|
.filter((interfaceFile) => interfaceFile.isConfigFile &&
|
|
@@ -375,9 +374,9 @@ function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant
|
|
|
375
374
|
const interfaceValueFile = interfaceValueFiles[0];
|
|
376
375
|
const interfaceConfigFile = interfaceConfigFiles[0];
|
|
377
376
|
// Make this value:
|
|
378
|
-
// /pages/some-page/+
|
|
377
|
+
// /pages/some-page/+{configName}.js > `export default`
|
|
379
378
|
// override that value:
|
|
380
|
-
// /pages/some-page/+config > `export default { someConfig }`
|
|
379
|
+
// /pages/some-page/+config.h.js > `export default { someConfig }`
|
|
381
380
|
const interfaceFileWinner = interfaceValueFile ?? interfaceConfigFile;
|
|
382
381
|
if (interfaceFileWinner) {
|
|
383
382
|
const interfaceFilesOverriden = [...interfaceValueFiles, ...interfaceConfigFiles].filter((f) => f !== interfaceFileWinner);
|
|
@@ -392,7 +391,7 @@ function resolveConfigValueSources(configName, configDef, interfaceFilesRelevant
|
|
|
392
391
|
interfaceFilesDefiningConfig
|
|
393
392
|
.filter((interfaceFile) => interfaceFile.isValueFile &&
|
|
394
393
|
// Is side-effect export
|
|
395
|
-
interfaceFile.
|
|
394
|
+
interfaceFile.configName !== configName)
|
|
396
395
|
.forEach((interfaceValueFileSideEffect) => {
|
|
397
396
|
add(interfaceValueFileSideEffect);
|
|
398
397
|
});
|
|
@@ -430,22 +429,22 @@ function isInterfaceFileUserLand(interfaceFile) {
|
|
|
430
429
|
}
|
|
431
430
|
function getConfigValueSource(configName, interfaceFile, configDef, userRootDir) {
|
|
432
431
|
// TODO: rethink file paths of ConfigElement
|
|
433
|
-
const
|
|
432
|
+
const filePathToShowToUser = interfaceFile.filePath.filePathRelativeToUserRootDir ?? interfaceFile.filePath.filePathAbsolute;
|
|
434
433
|
const conf = interfaceFile.configMap[configName];
|
|
435
434
|
assert(conf);
|
|
436
435
|
const configEnv = configDef.env;
|
|
437
436
|
const definedAtInfoConfigFile = {
|
|
438
|
-
filePath:
|
|
437
|
+
filePath: filePathToShowToUser,
|
|
439
438
|
fileExportPath: ['default', configName]
|
|
440
439
|
};
|
|
441
440
|
if (configDef._valueIsFilePath) {
|
|
442
441
|
let filePath;
|
|
443
442
|
if (interfaceFile.isConfigFile) {
|
|
444
443
|
const { configValue } = conf;
|
|
445
|
-
const import_ =
|
|
444
|
+
const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
446
445
|
const configDefinedAt = getConfigDefinedAtString(configName, { definedAtInfo: definedAtInfoConfigFile }, true);
|
|
447
446
|
assertUsage(import_, `${configDefinedAt} should be an import`);
|
|
448
|
-
filePath = import_.
|
|
447
|
+
filePath = import_.filePathToShowToUser;
|
|
449
448
|
}
|
|
450
449
|
else {
|
|
451
450
|
assert(interfaceFile.isValueFile);
|
|
@@ -470,17 +469,16 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
470
469
|
if (interfaceFile.isConfigFile) {
|
|
471
470
|
assert('configValue' in conf);
|
|
472
471
|
const { configValue } = conf;
|
|
473
|
-
const import_ =
|
|
472
|
+
const import_ = resolveImport(configValue, interfaceFile.filePath, userRootDir, configEnv, configName);
|
|
474
473
|
if (import_) {
|
|
475
|
-
const {
|
|
476
|
-
assertCodeFileEnv(importFilePath, configEnv, configName);
|
|
474
|
+
const { filePathToShowToUser, fileExportName: exportName } = import_;
|
|
477
475
|
const configValueSource = {
|
|
478
476
|
configEnv,
|
|
479
477
|
valueIsImportedAtRuntime: true,
|
|
480
478
|
isComputed: false,
|
|
481
479
|
definedAtInfo: {
|
|
482
|
-
filePath:
|
|
483
|
-
fileExportPath: [
|
|
480
|
+
filePath: filePathToShowToUser,
|
|
481
|
+
fileExportPath: [exportName]
|
|
484
482
|
}
|
|
485
483
|
};
|
|
486
484
|
return configValueSource;
|
|
@@ -498,16 +496,16 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
498
496
|
}
|
|
499
497
|
else if (interfaceFile.isValueFile) {
|
|
500
498
|
// TODO: rethink file paths of ConfigElement
|
|
501
|
-
const
|
|
502
|
-
const
|
|
499
|
+
const importPath = interfaceFile.filePath.filePathRelativeToUserRootDir ?? interfaceFile.filePath.filePathAbsolute;
|
|
500
|
+
const exportName = configName === interfaceFile.configName ? 'default' : configName;
|
|
503
501
|
const valueAlreadyLoaded = 'configValue' in conf;
|
|
504
502
|
const configValueSource = {
|
|
505
503
|
configEnv,
|
|
506
504
|
valueIsImportedAtRuntime: !valueAlreadyLoaded,
|
|
507
505
|
isComputed: false,
|
|
508
506
|
definedAtInfo: {
|
|
509
|
-
filePath:
|
|
510
|
-
fileExportPath: [
|
|
507
|
+
filePath: importPath,
|
|
508
|
+
fileExportPath: [exportName]
|
|
511
509
|
}
|
|
512
510
|
};
|
|
513
511
|
if (valueAlreadyLoaded) {
|
|
@@ -520,16 +518,17 @@ function getConfigValueSource(configName, interfaceFile, configDef, userRootDir)
|
|
|
520
518
|
}
|
|
521
519
|
assert(false);
|
|
522
520
|
}
|
|
523
|
-
function
|
|
524
|
-
|
|
525
|
-
|
|
521
|
+
function assertFileEnv(filePathForEnvCheck, configEnv, configName) {
|
|
522
|
+
assertPosixPath(filePathForEnvCheck);
|
|
523
|
+
if (!filesEnv.has(filePathForEnvCheck)) {
|
|
524
|
+
filesEnv.set(filePathForEnvCheck, []);
|
|
526
525
|
}
|
|
527
|
-
const
|
|
528
|
-
|
|
529
|
-
const configDifferentEnv =
|
|
526
|
+
const fileEnv = filesEnv.get(filePathForEnvCheck);
|
|
527
|
+
fileEnv.push({ configEnv, configName });
|
|
528
|
+
const configDifferentEnv = fileEnv.filter((c) => c.configEnv !== configEnv)[0];
|
|
530
529
|
if (configDifferentEnv) {
|
|
531
530
|
assertUsage(false, [
|
|
532
|
-
`${
|
|
531
|
+
`${filePathForEnvCheck} defines the value of configs living in different environments:`,
|
|
533
532
|
...[configDifferentEnv, { configName, configEnv }].map((c) => ` - config ${pc.cyan(c.configName)} which value lives in environment ${pc.cyan(c.configEnv)}`),
|
|
534
533
|
'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'
|
|
535
534
|
].join('\n'));
|
|
@@ -547,53 +546,60 @@ function isDefiningPage(interfaceFiles) {
|
|
|
547
546
|
function isDefiningPageConfig(configName) {
|
|
548
547
|
return ['Page', 'route'].includes(configName);
|
|
549
548
|
}
|
|
550
|
-
function
|
|
549
|
+
function resolveImport(configValue, importerFilePath, userRootDir, configEnv, configName) {
|
|
551
550
|
if (typeof configValue !== 'string')
|
|
552
551
|
return null;
|
|
553
552
|
const importData = parseImportData(configValue);
|
|
554
553
|
if (!importData)
|
|
555
554
|
return null;
|
|
556
|
-
|
|
557
|
-
|
|
555
|
+
const { importPath, exportName } = importData;
|
|
556
|
+
const filePathAbsolute = resolveImportPath(importData, importerFilePath);
|
|
557
|
+
let filePathToShowToUser;
|
|
558
|
+
if (importPath.startsWith('.')) {
|
|
558
559
|
// We need to resolve relative paths into absolute paths. Because the import paths are included in virtual files:
|
|
559
560
|
// ```
|
|
560
561
|
// [vite] Internal server error: Failed to resolve import "./onPageTransitionHooks" from "virtual:vike:pageConfigValuesAll:client:/pages/index". Does the file exist?
|
|
561
562
|
// ```
|
|
562
|
-
|
|
563
|
+
assertImportPath(filePathAbsolute, importData, importerFilePath);
|
|
564
|
+
const filePathRelativeToUserRootDir = resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, importerFilePath, userRootDir);
|
|
565
|
+
filePathToShowToUser = filePathRelativeToUserRootDir;
|
|
563
566
|
}
|
|
564
567
|
else {
|
|
565
|
-
//
|
|
568
|
+
// importPath can be:
|
|
566
569
|
// - an npm package import
|
|
567
570
|
// - a path alias
|
|
571
|
+
filePathToShowToUser = importPath;
|
|
572
|
+
}
|
|
573
|
+
{
|
|
574
|
+
const filePathForEnvCheck = filePathAbsolute ?? importPath;
|
|
575
|
+
assertFileEnv(filePathForEnvCheck, configEnv, configName);
|
|
568
576
|
}
|
|
569
577
|
return {
|
|
570
|
-
|
|
571
|
-
|
|
578
|
+
filePathToShowToUser,
|
|
579
|
+
fileExportName: exportName
|
|
572
580
|
};
|
|
573
581
|
}
|
|
574
|
-
function
|
|
575
|
-
let importFilePath = resolveImport(importData, configFilePath);
|
|
576
|
-
// Make it a Vite path
|
|
582
|
+
function resolveImportPath_relativeToUserRootDir(filePathAbsolute, importData, configFilePath, userRootDir) {
|
|
577
583
|
assertPosixPath(userRootDir);
|
|
578
|
-
|
|
579
|
-
if (
|
|
580
|
-
|
|
584
|
+
let filePathRelativeToUserRootDir;
|
|
585
|
+
if (filePathAbsolute.startsWith(userRootDir)) {
|
|
586
|
+
filePathRelativeToUserRootDir = getVitePathFromAbsolutePath(filePathAbsolute, userRootDir);
|
|
581
587
|
}
|
|
582
588
|
else {
|
|
583
|
-
assertUsage(false, `${getFilePathToShowToUser(configFilePath)} imports from a relative path ${pc.cyan(importData.
|
|
589
|
+
assertUsage(false, `${getFilePathToShowToUser(configFilePath)} imports from a relative path ${pc.cyan(importData.importPath)} outside of ${userRootDir} which is forbidden: import from a relative path inside ${userRootDir}, or import from a dependency's package.json#exports entry instead`);
|
|
584
590
|
// None of the following works. Seems to be a Vite bug?
|
|
585
591
|
// /*
|
|
586
|
-
// assert(
|
|
587
|
-
//
|
|
592
|
+
// assert(filePathAbsolute.startsWith('/'))
|
|
593
|
+
// filePath = `/@fs${filePathAbsolute}`
|
|
588
594
|
// /*/
|
|
589
|
-
//
|
|
590
|
-
// assert(
|
|
591
|
-
//
|
|
595
|
+
// filePathRelativeToUserRootDir = path.posix.relative(userRootDir, filePathAbsolute)
|
|
596
|
+
// assert(filePathRelativeToUserRootDir.startsWith('../'))
|
|
597
|
+
// filePathRelativeToUserRootDir = '/' + filePathRelativeToUserRootDir
|
|
592
598
|
// //*/
|
|
593
599
|
}
|
|
594
|
-
assertPosixPath(
|
|
595
|
-
assert(
|
|
596
|
-
return
|
|
600
|
+
assertPosixPath(filePathRelativeToUserRootDir);
|
|
601
|
+
assert(filePathRelativeToUserRootDir.startsWith('/'));
|
|
602
|
+
return filePathRelativeToUserRootDir;
|
|
597
603
|
}
|
|
598
604
|
function getVitePathFromAbsolutePath(filePathAbsolute, root) {
|
|
599
605
|
assertPosixPath(filePathAbsolute);
|
|
@@ -705,10 +711,9 @@ function applyEffect(configModFromEffect, configValueEffectSource, configValueSo
|
|
|
705
711
|
function applyComputed(pageConfig, configDefinitionsRelevant) {
|
|
706
712
|
objectEntries(configDefinitionsRelevant).forEach(([configName, configDef]) => {
|
|
707
713
|
var _a;
|
|
708
|
-
|
|
709
|
-
if (!computed)
|
|
714
|
+
if (!configDef._computed)
|
|
710
715
|
return;
|
|
711
|
-
const value =
|
|
716
|
+
const value = configDef._computed(pageConfig);
|
|
712
717
|
if (value === undefined)
|
|
713
718
|
return;
|
|
714
719
|
const configValueSource = {
|
|
@@ -821,10 +826,11 @@ async function loadExtendsConfigs(configFileExports, configFilePath, userRootDir
|
|
|
821
826
|
const extendsImportData = getExtendsImportData(configFileExports, configFilePath);
|
|
822
827
|
const extendsConfigFiles = [];
|
|
823
828
|
extendsImportData.map((importData) => {
|
|
824
|
-
const {
|
|
829
|
+
const { importPath: importPath } = importData;
|
|
825
830
|
// TODO
|
|
826
831
|
// - validate extends configs
|
|
827
|
-
const filePathAbsolute =
|
|
832
|
+
const filePathAbsolute = resolveImportPath(importData, configFilePath);
|
|
833
|
+
assertImportPath(filePathAbsolute, importData, configFilePath);
|
|
828
834
|
assertExtendsImportPath(importPath, filePathAbsolute, configFilePath);
|
|
829
835
|
extendsConfigFiles.push({
|
|
830
836
|
filePathAbsolute,
|
|
@@ -870,7 +876,7 @@ function assertExtendsImportPath(importPath, filePath, configFilePath) {
|
|
|
870
876
|
}
|
|
871
877
|
function getExtendsImportData(configFileExports, configFilePath) {
|
|
872
878
|
const filePathToShowToUser = getFilePathToShowToUser(configFilePath);
|
|
873
|
-
|
|
879
|
+
assertExportsOfConfigFile(configFileExports, filePathToShowToUser);
|
|
874
880
|
const defaultExports = configFileExports.default;
|
|
875
881
|
const wrongUsage = `${filePathToShowToUser} sets the config 'extends' to an invalid value, see https://vike.dev/extends`;
|
|
876
882
|
let extendList;
|
|
@@ -968,7 +974,7 @@ function determineRouteFilesystem(locationId, configValueSources) {
|
|
|
968
974
|
const configFilesystemRoutingRoot = configValueSources[configName]?.[0];
|
|
969
975
|
let filesystemRouteString = getFilesystemRouteString(locationId);
|
|
970
976
|
if (determineIsErrorPage(filesystemRouteString)) {
|
|
971
|
-
return { isErrorPage: true, routeFilesystem:
|
|
977
|
+
return { isErrorPage: true, routeFilesystem: undefined };
|
|
972
978
|
}
|
|
973
979
|
let filesystemRouteDefinedBy = getFilesystemRouteDefinedBy(locationId); // for log404()
|
|
974
980
|
if (configFilesystemRoutingRoot) {
|
|
@@ -986,7 +992,7 @@ function determineRouteFilesystem(locationId, configValueSources) {
|
|
|
986
992
|
routeString: filesystemRouteString,
|
|
987
993
|
definedBy: filesystemRouteDefinedBy
|
|
988
994
|
};
|
|
989
|
-
return { routeFilesystem, isErrorPage:
|
|
995
|
+
return { routeFilesystem, isErrorPage: undefined };
|
|
990
996
|
}
|
|
991
997
|
function getFilesystemRoutingRootEffect(configFilesystemRoutingRoot, configName) {
|
|
992
998
|
assert(configFilesystemRoutingRoot.configEnv === 'config-only');
|
|
@@ -1006,22 +1012,22 @@ function determineIsErrorPage(routeFilesystem) {
|
|
|
1006
1012
|
assertPosixPath(routeFilesystem);
|
|
1007
1013
|
return routeFilesystem.split('/').includes('_error');
|
|
1008
1014
|
}
|
|
1009
|
-
function
|
|
1010
|
-
const
|
|
1011
|
-
assertPosixPath(
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
return
|
|
1015
|
+
function resolveImportPath(importData, importerFilePath) {
|
|
1016
|
+
const importerFilePathAbsolute = importerFilePath.filePathAbsolute;
|
|
1017
|
+
assertPosixPath(importerFilePathAbsolute);
|
|
1018
|
+
const cwd = path.posix.dirname(importerFilePathAbsolute);
|
|
1019
|
+
// filePathAbsolute is expected to be null when importData.importPath is a Vite path alias
|
|
1020
|
+
const filePathAbsolute = requireResolve(importData.importPath, cwd);
|
|
1021
|
+
return filePathAbsolute;
|
|
1016
1022
|
}
|
|
1017
|
-
function
|
|
1018
|
-
const {
|
|
1023
|
+
function assertImportPath(filePathAbsolute, importData, importerFilePath) {
|
|
1024
|
+
const { importPath: importPath, importStringWasGenerated, importString } = importData;
|
|
1019
1025
|
const filePathToShowToUser = getFilePathToShowToUser(importerFilePath);
|
|
1020
|
-
if (!
|
|
1026
|
+
if (!filePathAbsolute) {
|
|
1021
1027
|
const importPathString = pc.cyan(`'${importPath}'`);
|
|
1022
|
-
const errIntro =
|
|
1028
|
+
const errIntro = importStringWasGenerated
|
|
1023
1029
|
? `The import path ${importPathString} in ${filePathToShowToUser}`
|
|
1024
|
-
: `The import ${pc.cyan(
|
|
1030
|
+
: `The import ${pc.cyan(importString)} defined in ${filePathToShowToUser}`;
|
|
1025
1031
|
const errIntro2 = `${errIntro} couldn't be resolved: does ${importPathString}`;
|
|
1026
1032
|
if (importPath.startsWith('.')) {
|
|
1027
1033
|
assertUsage(false, `${errIntro2} point to an existing file?`);
|
|
@@ -1072,6 +1078,8 @@ function mergeCumulative(configName, configValueSources) {
|
|
|
1072
1078
|
/* This is more confusing than adding value. For example, this explanation shouldn't be shown for the passToClient config.
|
|
1073
1079
|
const explanation = `(Because the values of ${configNameColored} are cumulative and therefore merged together.)` as const
|
|
1074
1080
|
*/
|
|
1081
|
+
// Make sure configValueSource.value is serializable
|
|
1082
|
+
getConfigValueSerialized(configValueSource.value, configName, configValueSource.definedAtInfo);
|
|
1075
1083
|
const assertNoMixing = (isSet) => {
|
|
1076
1084
|
const vals1 = isSet ? valuesSet : valuesArr;
|
|
1077
1085
|
const t1 = isSet ? 'a Set' : 'an array';
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export { getVirtualFilePageConfigValuesAll };
|
|
2
|
+
export { serializeConfigValueImported };
|
|
3
|
+
import type { ConfigValueSource } from '../../../../../shared/page-configs/PageConfig.js';
|
|
2
4
|
import type { ConfigVikeResolved } from '../../../../../shared/ConfigVike.js';
|
|
3
5
|
declare function getVirtualFilePageConfigValuesAll(id: string, userRootDir: string, isDev: boolean, configVike: ConfigVikeResolved): Promise<string>;
|
|
6
|
+
declare function serializeConfigValueImported(configValueSource: ConfigValueSource, configName: string, whitespace: string, varCounterContainer: {
|
|
7
|
+
varCounter: number;
|
|
8
|
+
}, importStatements: string[]): string[];
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigValuesAll.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { getVirtualFilePageConfigValuesAll };
|
|
2
|
+
export { serializeConfigValueImported };
|
|
2
3
|
import { assert, assertPosixPath } from '../../../utils.js';
|
|
3
4
|
import { generateEagerImport } from '../generateEagerImport.js';
|
|
4
5
|
import { getVirtualFileIdPageConfigValuesAll, isVirtualFileIdPageConfigValuesAll } from '../../../../shared/virtual-files/virtualFilePageConfigValuesAll.js';
|
|
@@ -7,7 +8,7 @@ import { extractAssetsAddQuery } from '../../../../shared/extractAssetsQuery.js'
|
|
|
7
8
|
import { debug } from './debug.js';
|
|
8
9
|
import path from 'path';
|
|
9
10
|
import { getConfigValue } from '../../../../../shared/page-configs/utils.js';
|
|
10
|
-
import { getConfigValueSourcesRelevant } from '../../../shared/
|
|
11
|
+
import { getConfigValueSourcesRelevant } from '../../../shared/getConfigValueSourcesRelevant.js';
|
|
11
12
|
import { isConfigEnvMatch } from './isConfigEnvMatch.js';
|
|
12
13
|
async function getVirtualFilePageConfigValuesAll(id, userRootDir, isDev, configVike) {
|
|
13
14
|
const result = isVirtualFileIdPageConfigValuesAll(id);
|
|
@@ -32,37 +33,17 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
32
33
|
const lines = [];
|
|
33
34
|
const importStatements = [];
|
|
34
35
|
lines.push('export default [');
|
|
35
|
-
|
|
36
|
+
const varCounterContainer = { varCounter: 0 };
|
|
36
37
|
getConfigValueSourcesRelevant(pageConfig).forEach((configValueSource) => {
|
|
37
|
-
const { valueIsImportedAtRuntime,
|
|
38
|
+
const { valueIsImportedAtRuntime, configEnv, configName } = configValueSource;
|
|
38
39
|
if (!valueIsImportedAtRuntime)
|
|
39
40
|
return;
|
|
40
41
|
if (configValueSource.valueIsFilePath)
|
|
41
42
|
return;
|
|
42
43
|
if (!isConfigEnvMatch(configEnv, isForClientSide, isClientRouting))
|
|
43
44
|
return;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const fileName = path.posix.basename(filePath);
|
|
47
|
-
const isPlusFile = fileName.startsWith('+');
|
|
48
|
-
const fileExportName = fileExportPath[0];
|
|
49
|
-
assert(!configValueSource.valueIsFilePath);
|
|
50
|
-
assert(fileExportName);
|
|
51
|
-
const { importVar, importStatement } = generateEagerImport(filePath, varCounter++, isPlusFile ? undefined : fileExportName);
|
|
52
|
-
importStatements.push(importStatement);
|
|
53
|
-
lines.push(` {`);
|
|
54
|
-
lines.push(` configName: '${configName}',`);
|
|
55
|
-
lines.push(` importFilePath: '${filePath}',`);
|
|
56
|
-
lines.push(` isPlusFile: ${JSON.stringify(isPlusFile)},`);
|
|
57
|
-
if (isPlusFile) {
|
|
58
|
-
lines.push(` importFileExports: ${importVar},`);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
lines.push(` importFileExportValue: ${importVar},`);
|
|
62
|
-
assert(fileExportName);
|
|
63
|
-
lines.push(` importFileExportName: ${JSON.stringify(fileExportName)},`);
|
|
64
|
-
}
|
|
65
|
-
lines.push(` },`);
|
|
45
|
+
const whitespace = ' ';
|
|
46
|
+
lines.push(...serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements));
|
|
66
47
|
});
|
|
67
48
|
lines.push('];');
|
|
68
49
|
if (includeAssetsImportedByServer && isForClientSide && !isDev) {
|
|
@@ -71,3 +52,32 @@ function getLoadConfigValuesAll(pageConfig, isForClientSide, pageId, includeAsse
|
|
|
71
52
|
const code = [...importStatements, ...lines].join('\n');
|
|
72
53
|
return code;
|
|
73
54
|
}
|
|
55
|
+
function serializeConfigValueImported(configValueSource, configName, whitespace, varCounterContainer, importStatements) {
|
|
56
|
+
assert(whitespace.replaceAll(' ', '').length === 0);
|
|
57
|
+
const { valueIsImportedAtRuntime, definedAtInfo } = configValueSource;
|
|
58
|
+
assert(valueIsImportedAtRuntime);
|
|
59
|
+
const { filePath, fileExportPath } = definedAtInfo;
|
|
60
|
+
assertPosixPath(filePath);
|
|
61
|
+
const fileName = path.posix.basename(filePath);
|
|
62
|
+
const isValueFile = fileName.startsWith('+');
|
|
63
|
+
const fileExportName = fileExportPath[0];
|
|
64
|
+
assert(!configValueSource.valueIsFilePath);
|
|
65
|
+
assert(fileExportName);
|
|
66
|
+
const { importName, importStatement } = generateEagerImport(filePath, varCounterContainer.varCounter++, isValueFile ? undefined : fileExportName);
|
|
67
|
+
importStatements.push(importStatement);
|
|
68
|
+
const lines = [];
|
|
69
|
+
lines.push(` {`);
|
|
70
|
+
lines.push(` configName: '${configName}',`);
|
|
71
|
+
lines.push(` importPath: '${filePath}',`);
|
|
72
|
+
lines.push(` isValueFile: ${JSON.stringify(isValueFile)},`);
|
|
73
|
+
if (isValueFile) {
|
|
74
|
+
lines.push(` importFileExports: ${importName},`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
lines.push(` importFileExportValue: ${importName},`);
|
|
78
|
+
assert(fileExportName);
|
|
79
|
+
lines.push(` exportName: ${JSON.stringify(fileExportName)},`);
|
|
80
|
+
}
|
|
81
|
+
lines.push(` },`);
|
|
82
|
+
return lines;
|
|
83
|
+
}
|
package/dist/esm/node/plugin/plugins/importUserCode/v1-design/getVirtualFilePageConfigs.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { getVirtualFilePageConfigs };
|
|
2
|
+
export { getConfigValueSerialized };
|
|
3
|
+
import type { DefinedAtInfo } from '../../../../../shared/page-configs/PageConfig.js';
|
|
2
4
|
import type { ConfigVikeResolved } from '../../../../../shared/ConfigVike.js';
|
|
3
5
|
declare function getVirtualFilePageConfigs(userRootDir: string, isForClientSide: boolean, isDev: boolean, id: string, configVike: ConfigVikeResolved, isClientRouting: boolean): Promise<string>;
|
|
6
|
+
declare function getConfigValueSerialized(value: unknown, configName: string, definedAtInfo: null | DefinedAtInfo): string;
|