Skip to content

Commit

Permalink
build: add package dependencies to Rollup external
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar authored and wangcheng committed Apr 19, 2019
1 parent 18dac5c commit 19d0dfc
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,8 @@ import resolve from 'rollup-plugin-node-resolve'

const pkg = require(path.resolve(process.cwd(), 'package.json'))

const externalLibraries = [
'react',
'prop-types',
'eventemitter3',
'griffith-message',
'query-string',
'griffith-utils',
'isomorphic-bigscreen',
'element-resize-event',
/^aphrodite\//,
/^lodash\//,
]

const external = id =>
externalLibraries.some(name =>
name instanceof RegExp ? name.test(id) : name === id
)
const deps = Object.keys({...pkg.dependencies, ...pkg.peerDependencies})
const reExternal = new RegExp(`^(${deps.join('|')})($|/)`)

export default [
{
Expand All @@ -42,6 +27,6 @@ export default [
// resolves `./directory` to `./directory/index.js`
resolve({only: [/\/packages\/.*/]}),
],
external,
external: id => (deps.length ? reExternal.test(id) : false),
},
]

0 comments on commit 19d0dfc

Please sign in to comment.