1 | import { either, pipe } from 'ramda';
|
2 | import externalToFn from './external-to-fn';
|
3 | import getModulesMatcher from './get-modules-matcher';
|
4 | import getDeps from './get-deps';
|
5 |
|
6 | export default function PeerDepsExternalPlugin({packageJsonPath, includeDependencies} = {}) {
|
7 | return {
|
8 | name: 'peer-deps-external',
|
9 | options: opts => {
|
10 | opts.external = either(
|
11 |
|
12 | externalToFn(opts.external),
|
13 |
|
14 | getModulesMatcher(
|
15 | getDeps(packageJsonPath, 'peerDependencies')
|
16 | .concat(includeDependencies ? getDeps(packageJsonPath, 'dependencies') : []))
|
17 | );
|
18 |
|
19 | return opts;
|
20 | },
|
21 | };
|
22 | }
|