@rollup/plugin-node-resolve
Advanced tools
Comparing version 15.2.4 to 15.3.0
@@ -15,3 +15,3 @@ 'use strict'; | ||
var version = "15.2.4"; | ||
var version = "15.3.0"; | ||
var peerDependencies = { | ||
@@ -1077,3 +1077,3 @@ rollup: "^2.78.0||^3.0.0||^4.0.0" | ||
const useBrowserOverrides = mainFields.indexOf('browser') !== -1; | ||
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false; | ||
const isPreferBuiltinsSet = Object.prototype.hasOwnProperty.call(options, 'preferBuiltins'); | ||
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true; | ||
@@ -1214,4 +1214,6 @@ const rootDir = path.resolve(options.rootDir || process.cwd()); | ||
const importeeIsBuiltin = module$1.builtinModules.includes(importee.replace(nodeImportPrefix, '')); | ||
const preferImporteeIsBuiltin = | ||
typeof preferBuiltins === 'function' ? preferBuiltins(importee) : preferBuiltins; | ||
const resolved = | ||
importeeIsBuiltin && preferBuiltins | ||
importeeIsBuiltin && preferImporteeIsBuiltin | ||
? { | ||
@@ -1251,7 +1253,10 @@ packageInfo: undefined, | ||
if (hasPackageEntry) { | ||
if (importeeIsBuiltin && preferBuiltins) { | ||
if (importeeIsBuiltin && preferImporteeIsBuiltin) { | ||
if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) { | ||
context.warn( | ||
`preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning` | ||
); | ||
context.warn({ | ||
message: | ||
`preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.` + | ||
`or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.`, | ||
pluginCode: 'PREFER_BUILTINS' | ||
}); | ||
} | ||
@@ -1258,0 +1263,0 @@ return false; |
@@ -15,3 +15,3 @@ 'use strict'; | ||
var version = "15.2.4"; | ||
var version = "15.3.0"; | ||
var peerDependencies = { | ||
@@ -1077,3 +1077,3 @@ rollup: "^2.78.0||^3.0.0||^4.0.0" | ||
const useBrowserOverrides = mainFields.indexOf('browser') !== -1; | ||
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false; | ||
const isPreferBuiltinsSet = Object.prototype.hasOwnProperty.call(options, 'preferBuiltins'); | ||
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true; | ||
@@ -1214,4 +1214,6 @@ const rootDir = path.resolve(options.rootDir || process.cwd()); | ||
const importeeIsBuiltin = module$1.builtinModules.includes(importee.replace(nodeImportPrefix, '')); | ||
const preferImporteeIsBuiltin = | ||
typeof preferBuiltins === 'function' ? preferBuiltins(importee) : preferBuiltins; | ||
const resolved = | ||
importeeIsBuiltin && preferBuiltins | ||
importeeIsBuiltin && preferImporteeIsBuiltin | ||
? { | ||
@@ -1251,7 +1253,10 @@ packageInfo: undefined, | ||
if (hasPackageEntry) { | ||
if (importeeIsBuiltin && preferBuiltins) { | ||
if (importeeIsBuiltin && preferImporteeIsBuiltin) { | ||
if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) { | ||
context.warn( | ||
`preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning` | ||
); | ||
context.warn({ | ||
message: | ||
`preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.` + | ||
`or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.`, | ||
pluginCode: 'PREFER_BUILTINS' | ||
}); | ||
} | ||
@@ -1258,0 +1263,0 @@ return false; |
@@ -11,3 +11,3 @@ import path, { dirname, resolve, extname, normalize, sep } from 'path'; | ||
var version = "15.2.4"; | ||
var version = "15.3.0"; | ||
var peerDependencies = { | ||
@@ -1073,3 +1073,3 @@ rollup: "^2.78.0||^3.0.0||^4.0.0" | ||
const useBrowserOverrides = mainFields.indexOf('browser') !== -1; | ||
const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false; | ||
const isPreferBuiltinsSet = Object.prototype.hasOwnProperty.call(options, 'preferBuiltins'); | ||
const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true; | ||
@@ -1210,4 +1210,6 @@ const rootDir = resolve(options.rootDir || process.cwd()); | ||
const importeeIsBuiltin = builtinModules.includes(importee.replace(nodeImportPrefix, '')); | ||
const preferImporteeIsBuiltin = | ||
typeof preferBuiltins === 'function' ? preferBuiltins(importee) : preferBuiltins; | ||
const resolved = | ||
importeeIsBuiltin && preferBuiltins | ||
importeeIsBuiltin && preferImporteeIsBuiltin | ||
? { | ||
@@ -1247,7 +1249,10 @@ packageInfo: undefined, | ||
if (hasPackageEntry) { | ||
if (importeeIsBuiltin && preferBuiltins) { | ||
if (importeeIsBuiltin && preferImporteeIsBuiltin) { | ||
if (!isPreferBuiltinsSet && resolvedWithoutBuiltins && resolved !== importee) { | ||
context.warn( | ||
`preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning` | ||
); | ||
context.warn({ | ||
message: | ||
`preferring built-in module '${importee}' over local alternative at '${resolvedWithoutBuiltins.location}', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning.` + | ||
`or passing a function to 'preferBuiltins' to provide more fine-grained control over which built-in modules to prefer.`, | ||
pluginCode: 'PREFER_BUILTINS' | ||
}); | ||
} | ||
@@ -1254,0 +1259,0 @@ return false; |
{ | ||
"name": "@rollup/plugin-node-resolve", | ||
"version": "15.2.4", | ||
"version": "15.3.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -136,3 +136,3 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve | ||
Type: `Boolean`<br> | ||
Type: `Boolean | (module: string) => boolean`<br> | ||
Default: `true` (with warnings if a builtin module is used over a local version. Set to `true` to disable warning.) | ||
@@ -142,2 +142,10 @@ | ||
Alternatively, you may pass in a function that returns a boolean to confirm whether the plugin should prefer built-in modules. e.g. | ||
```js | ||
preferBuiltins: (module) => module !== 'punycode'; | ||
``` | ||
will not treat `punycode` as a built-in module | ||
### `modulesOnly` | ||
@@ -144,0 +152,0 @@ |
@@ -82,5 +82,7 @@ import type { Plugin } from 'rollup'; | ||
* the plugin will look for locally installed modules of the same name. | ||
* | ||
* If a function is provided, it will be called to determine whether to prefer built-ins. | ||
* @default true | ||
*/ | ||
preferBuiltins?: boolean; | ||
preferBuiltins?: boolean | ((module: string) => boolean); | ||
@@ -87,0 +89,0 @@ /** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
154353
3851
294