Skip to content

Commit

Permalink
feat: support fallbackLoaders option
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 29, 2024
1 parent 4b373d0 commit b4c2a02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async function loadConfigFile<T>(filepath: string, source: LoadConfigSource<T>):
parentURL: filepath,
cache: false,
loader: source.loader || 'auto',
fallbackLoaders: source.fallbackLoaders,
})
dependencies = r.getModuleInfo(mod)?.dependencies
return interopDefault(mod)
Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export interface LoadConfigSource<T = any> {
*/
loader?: SupportedLoader | 'auto'

/**
* Fallback loaders when the previous loader failed.
*
* Set to `false` to disable fallback.
*
* Default to importx's default.
*/
fallbackLoaders?: SupportedLoader[] | false

/**
* Rewrite the config object,
* return nullish value to bypassing loading the file
Expand Down

0 comments on commit b4c2a02

Please sign in to comment.