File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed
Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,20 @@ export default {
3030 ],
3131}
3232```
33+
34+ ## Options
35+ ### packageJsonPath
36+ If your ` package.json ` is not in the current working directory you can specify the path to the file
37+ ``` javascript
38+ // Add to plugins array in rollup.config.js
39+ import peerDepsExternal from ' rollup-plugin-peer-deps-external' ;
40+
41+ export default {
42+ plugins: [
43+ // Preferably set as first plugin.
44+ peerDepsExternal ({
45+ packageJsonPath: ' my/folder/package.json'
46+ }),
47+ ],
48+ }
49+ ```
Original file line number Diff line number Diff line change 1- export default function getPeerDeps ( ) {
1+ const { resolve } = require ( 'path' ) ;
2+
3+ export default function getPeerDeps ( path = resolve ( process . cwd ( ) , 'package.json' ) ) {
24 try {
3- const { resolve } = require ( 'path' ) ;
4- const pkg = require ( resolve ( process . cwd ( ) , 'package.json' ) ) ;
5+ const pkg = require ( path ) ;
56 return Object . keys ( pkg . peerDependencies ) ;
67 } catch ( err ) {
78 return [ ] ;
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ import externalToFn from './external-to-fn';
33import getModulesMatcher from './get-modules-matcher' ;
44import getPeerDeps from './get-peer-deps' ;
55
6- export default function PeerDepsExternalPlugin ( ) {
6+ export default function PeerDepsExternalPlugin ( { packageJsonPath } = { } ) {
77 return {
88 name : 'peer-deps-external' ,
99 options : opts => {
1010 opts . external = either (
1111 // Retain existing `external` config
1212 externalToFn ( opts . external ) ,
1313 // Add `peerDependencies` to `external` config
14- getModulesMatcher ( getPeerDeps ( ) )
14+ getModulesMatcher ( getPeerDeps ( packageJsonPath ) )
1515 ) ;
1616
1717 return opts ;
You can’t perform that action at this time.
0 commit comments