-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace ignore-resolutions with profile
Add four profiles: - `strict` - same as today; all resolutions - `node16` - ignores node10 resolution failures - `esm-only` - ignores CJS resolution failures - `node16-only` - strictly node16 resolutions
- Loading branch information
Showing
4 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { RenderOptions } from "./render/index.js"; | ||
|
||
type Profile = Pick<Required<RenderOptions>, "ignoreResolutions">; | ||
|
||
export const profiles = { | ||
strict: { | ||
ignoreResolutions: [], | ||
}, | ||
node16: { | ||
ignoreResolutions: ["node10"], | ||
}, | ||
"esm-only": { | ||
ignoreResolutions: ["node10", "node16-cjs"], | ||
}, | ||
"node16-only": { | ||
ignoreResolutions: ["node10", "bundler"], | ||
}, | ||
} satisfies Record<string, Profile>; | ||
|
||
/** | ||
* Merges the profile with the provided options | ||
* | ||
* @param profileKey - name of the profile to apply | ||
* @param opts - options to apply the profile to | ||
*/ | ||
export function applyProfile(profileKey: keyof typeof profiles, opts: RenderOptions): void { | ||
const profile = profiles[profileKey]; | ||
opts.ignoreResolutions = (opts.ignoreResolutions ?? []).concat(profile.ignoreResolutions); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters