@@ -9,7 +9,7 @@ import envCi from 'env-ci';
99/**
1010 * Attempts to load and parse a single config file
1111 * @param {string } configPath - Path to the configuration file
12- * @returns {Promise<BundleSizeCheckerConfig | null> } The parsed config or null if file doesn't exist
12+ * @returns {Promise<BundleSizeCheckerConfigObject | null> } The parsed config or null if file doesn't exist
1313 * @throws {Error } If the file exists but has invalid format
1414 */
1515async function loadConfigFile ( configPath ) {
@@ -20,20 +20,18 @@ async function loadConfigFile(configPath) {
2020
2121 // Dynamic import for ESM
2222 const configUrl = new URL ( `file://${ configPath } ` ) ;
23- let { default : config } = await import ( configUrl . href ) ;
23+ const { default : config } = await import ( configUrl . href ) ;
2424
25+ /** @type {BundleSizeCheckerConfigObject | null } */
26+ let resolvedConfig = null ;
2527 // Handle configs that might be Promise-returning functions
2628 if ( config instanceof Promise ) {
27- config = await config ;
29+ resolvedConfig = await config ;
2830 } else if ( typeof config === 'function' ) {
29- config = await config ( ) ;
31+ resolvedConfig = await config ( ) ;
3032 }
3133
32- if ( ! config . entrypoints || ! Array . isArray ( config . entrypoints ) ) {
33- throw new Error ( 'Configuration must include an entrypoints array' ) ;
34- }
35-
36- return config ;
34+ return resolvedConfig ;
3735 } catch ( error ) {
3836 console . error ( `Error loading config from ${ configPath } :` , error ) ;
3937 throw error ; // Re-throw to indicate failure
@@ -81,7 +79,7 @@ export function applyUploadConfigDefaults(uploadConfig, ciInfo) {
8179
8280/**
8381 * Apply default values to the configuration using CI environment
84- * @param {BundleSizeCheckerConfig } config - The loaded configuration
82+ * @param {BundleSizeCheckerConfigObject } config - The loaded configuration
8583 * @returns {NormalizedBundleSizeCheckerConfig } Configuration with defaults applied
8684 * @throws {Error } If required fields are missing
8785 */
0 commit comments