Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Feb 29, 2024
1 parent a49d65d commit f34e580
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
46 changes: 28 additions & 18 deletions vike/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ async function loadVikeConfig(userRootDir: string, outDirRoot: string, isDev: bo
importedFilesLoaded
)

// interfaceFilesByLocationId => pageConfigs
const pageConfigs: PageConfigBuildTime[] = await Promise.all(
objectEntries(interfaceFilesByLocationId)
.filter(([_pageId, interfaceFiles]) => isDefiningPage(interfaceFiles))
Expand All @@ -388,8 +389,7 @@ async function loadVikeConfig(userRootDir: string, outDirRoot: string, isDev: bo
getInterfaceFileList(interfaceFilesRelevant).map(async (interfaceFile) => {
if (!interfaceFile.isValueFile) return
const { configName } = interfaceFile
const configValue = interfaceFile.fileExportsByConfigName[configName]?.configValue
if (isGlobalConfig(configName, configValue)) return
if (isGlobalConfig_interfaceFile(configName, interfaceFile)) return
const configDef = getConfigDefinition(
configDefinitions,
configName,
Expand All @@ -406,19 +406,18 @@ async function loadVikeConfig(userRootDir: string, outDirRoot: string, isDev: bo

let configValueSources: ConfigValueSources = {}
await Promise.all(
objectEntries(configDefinitions)
.filter(([configName]) => !isGlobalConfig(configName))
.map(async ([configName, configDef]) => {
const sources = await resolveConfigValueSources(
configName,
configDef,
interfaceFilesRelevant,
userRootDir,
importedFilesLoaded
)
if (sources.length === 0) return
configValueSources[configName] = sources
})
objectEntries(configDefinitions).map(async ([configName, configDef]) => {
const sources = await resolveConfigValueSources(
configName,
configDef,
interfaceFilesRelevant,
userRootDir,
importedFilesLoaded,
true
)
if (sources.length === 0) return
configValueSources[configName] = sources
})
)
configValueSources = sortConfigValueSources(configValueSources, locationId)

Expand Down Expand Up @@ -553,7 +552,8 @@ async function getGlobalConfigs(
configDef,
interfaceFilesGlobal,
userRootDir,
importedFilesLoaded
importedFilesLoaded,
false
)
const configValueSource = sources[0]
if (!configValueSource) return
Expand All @@ -575,14 +575,17 @@ async function resolveConfigValueSources(
configDef: ConfigDefinitionInternal,
interfaceFilesRelevant: InterfaceFilesByLocationId,
userRootDir: string,
importedFilesLoaded: ImportedFilesLoaded
importedFilesLoaded: ImportedFilesLoaded,
isForGlobalConfig: boolean
): Promise<ConfigValueSource[]> {
const sourcesInfo: Parameters<typeof getConfigValueSource>[] = []

// interfaceFilesRelevant is sorted by sortAfterInheritanceOrder()
for (const interfaceFiles of Object.values(interfaceFilesRelevant)) {
const interfaceFilesDefiningConfig = interfaceFiles.filter(
(interfaceFile) => interfaceFile.fileExportsByConfigName[configName]
(interfaceFile) =>
interfaceFile.fileExportsByConfigName[configName] &&
(isForGlobalConfig || !isGlobalConfig_interfaceFile(configName, interfaceFile))
)
if (interfaceFilesDefiningConfig.length === 0) continue
const visited = new WeakSet<InterfaceFile>()
Expand Down Expand Up @@ -1320,6 +1323,13 @@ function isGlobalConfig(configName: string, configValue: undefined | unknown): c
const configNamesGlobal = getConfigNamesGlobal()
return arrayIncludes(configNamesGlobal, configName)
}
function isGlobalConfig_interfaceFile(
configName: string,
interfaceFile: InterfaceFile
): configName is ConfigNameGlobal {
const configValue = interfaceFile.fileExportsByConfigName[configName]?.configValue
return isGlobalConfig(configName, configValue)
}
function getConfigNamesGlobal() {
return Object.keys(configDefinitionsBuiltInGlobal)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function loadVikeConfigFile() {
const found = findVikeConfigFile(process.cwd())
if (!found) return null
const { vikeConfigFilePath, userRootDir } = found
const { fileExports } = await transpileAndExecuteFile(vikeConfigFilePath, true, userRootDir)
const { fileExports } = await transpileAndExecuteFile(vikeConfigFilePath, userRootDir, true)
return { fileExports }
}
function findVikeConfigFile(cwd: string): { vikeConfigFilePath: FilePathResolved; userRootDir: string } | null {
Expand Down

0 comments on commit f34e580

Please sign in to comment.