From 0591050f3157c9fb736e6fe0b018b334eb3ecbc3 Mon Sep 17 00:00:00 2001 From: Aaron Klinker Date: Sat, 30 Sep 2023 10:30:25 -0500 Subject: [PATCH] chore: Store user config metadata in memory This will be used in #16 --- src/core/types/internal.ts | 2 ++ src/core/utils/getInternalConfig.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/types/internal.ts b/src/core/types/internal.ts index 963e35ae..e349f6f5 100644 --- a/src/core/types/internal.ts +++ b/src/core/types/internal.ts @@ -8,6 +8,7 @@ import { UserManifest, ExtensionRunnerConfig, ConfigEnv, + UserConfig, } from './external'; import { UnimportOptions } from 'unimport'; import { ResolvedConfig } from 'c12'; @@ -48,6 +49,7 @@ export interface InternalConfig { enabled: boolean; template: NonNullable; }; + userConfigMetadata: Omit, 'config'>; } export type EntrypointGroup = Entrypoint | Entrypoint[]; diff --git a/src/core/utils/getInternalConfig.ts b/src/core/utils/getInternalConfig.ts index 26128a14..2e1115bc 100644 --- a/src/core/utils/getInternalConfig.ts +++ b/src/core/utils/getInternalConfig.ts @@ -30,13 +30,15 @@ export async function getInternalConfig( // Load user config let userConfig: UserConfig = {}; + let userConfigMetadata: InternalConfig['userConfigMetadata'] | undefined; if (inlineConfig.configFile !== false) { - const loaded = await loadConfig({ + const { config: loadedConfig, ...metadata } = await loadConfig({ name: 'wxt', cwd: inlineConfig.root ?? process.cwd(), rcFile: false, }); - userConfig = loaded.config ?? {}; + userConfig = loadedConfig ?? {}; + userConfigMetadata = metadata; } // Merge it into the inline config @@ -109,6 +111,7 @@ export async function getInternalConfig( enabled: mergedConfig.analysis?.enabled ?? false, template: mergedConfig.analysis?.template ?? 'treemap', }, + userConfigMetadata: userConfigMetadata ?? {}, }; finalConfig.vite = (env) =>