@rollup/plugin-node-resolve
Advanced tools
Comparing version 6.1.0 to 7.0.0
# @rollup/plugin-node-resolve ChangeLog | ||
## v7.0.0 | ||
_2020-01-07_ | ||
### Breaking Changes | ||
- feat: dedupe by package name (#99) | ||
## v6.1.0 | ||
@@ -4,0 +12,0 @@ |
@@ -160,2 +160,20 @@ import { dirname, resolve, normalize, sep, extname } from 'path'; | ||
return p; | ||
} // returns the imported package name for bare module imports | ||
function getPackageName(id) { | ||
if (id.startsWith('.') || id.startsWith('/')) { | ||
return null; | ||
} | ||
const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package | ||
// @my-scope/my-package -> @my-scope/my-package | ||
if (split[0][0] === '@') { | ||
return `${split[0]}/${split[1]}`; | ||
} // my-package/foo.js -> my-package | ||
// my-package -> my-package | ||
return split[0]; | ||
} | ||
@@ -183,3 +201,3 @@ | ||
const idToPackageInfo = new Map(); | ||
const shouldDedupe = typeof dedupe === 'function' ? dedupe : importee => dedupe.includes(importee); | ||
const shouldDedupe = typeof dedupe === 'function' ? dedupe : importee => dedupe.includes(importee) || dedupe.includes(getPackageName(importee)); | ||
@@ -186,0 +204,0 @@ function getCachedPackageInfo(pkg, pkgPath) { |
@@ -165,2 +165,20 @@ 'use strict'; | ||
return p; | ||
} // returns the imported package name for bare module imports | ||
function getPackageName(id) { | ||
if (id.startsWith('.') || id.startsWith('/')) { | ||
return null; | ||
} | ||
const split = id.split('/'); // @my-scope/my-package/foo.js -> @my-scope/my-package | ||
// @my-scope/my-package -> @my-scope/my-package | ||
if (split[0][0] === '@') { | ||
return `${split[0]}/${split[1]}`; | ||
} // my-package/foo.js -> my-package | ||
// my-package -> my-package | ||
return split[0]; | ||
} | ||
@@ -188,3 +206,3 @@ | ||
const idToPackageInfo = new Map(); | ||
const shouldDedupe = typeof dedupe === 'function' ? dedupe : importee => dedupe.includes(importee); | ||
const shouldDedupe = typeof dedupe === 'function' ? dedupe : importee => dedupe.includes(importee) || dedupe.includes(getPackageName(importee)); | ||
@@ -191,0 +209,0 @@ function getCachedPackageInfo(pkg, pkgPath) { |
{ | ||
"name": "@rollup/plugin-node-resolve", | ||
"version": "6.1.0", | ||
"version": "7.0.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -123,5 +123,19 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-node-resolve | ||
``` | ||
dedupe: [ 'react', 'react-dom' ] | ||
dedupe: [ 'my-package', '@namespace/my-package' ] | ||
``` | ||
This will deduplicate bare imports such as: | ||
```js | ||
import 'my-package'; | ||
import '@namespace/my-package'; | ||
``` | ||
And it will deduplicate deep imports such as: | ||
```js | ||
import 'my-package/foo.js'; | ||
import '@namespace/my-package/bar.js'; | ||
``` | ||
### `customResolveOptions` | ||
@@ -128,0 +142,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
53251
857
207