-
-
Notifications
You must be signed in to change notification settings - Fork 626
Description
- Rollup Plugin Name: @rollup/node-resolve
- Rollup Plugin Version: 15.2.3
Feature Use Case
Some NodeJS builtins (e.g. punycode) are deprecated, and replacement packages with the same name exist in NPM. It is desirable to have preferBuiltins set to false for these specific cases, while keeping it true for all other builtins (e.g. string_decoder is also available as both a builtin and a package, but in this case the builtin is stable and should be preferred).
Feature Proposal
Allow preferBuiltins to accept a regex, array, or function, matching the behaviour of e.g. external. The relevant code is already considering these on an import-by-import basis, so it should be possible without any restructuring needed.
For example, the config for the punycode example above could be:
nodeResolve({
preferBuiltins: (module) => module !== 'punycode',
})(perhaps an even better API would be to reverse the config, preferring builtins by default and offering a preferModules config, since that would allow preferModules: ['punycode'], but that is not backwards-compatible, or at least introduces ambiguity if both options are used)