Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp rollup.config.js #4311

Merged
merged 3 commits into from
Mar 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { defineConfig } from 'rollup'
import nodeResolve from '@rollup/plugin-node-resolve'
import babel from '@rollup/plugin-babel'
import replace from '@rollup/plugin-replace'
Expand All @@ -14,23 +15,17 @@ const babelRuntimeVersion = pkg.dependencies['@babel/runtime'].replace(
''
)

const makeExternalPredicate = externalArr => {
if (externalArr.length === 0) {
return () => false
}
const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`)
return id => pattern.test(id)
}
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
].map(name => RegExp(`^${name}($|/)`))

export default [
export default defineConfig([
// CommonJS
{
input: 'src/index.ts',
output: { file: 'lib/redux.js', format: 'cjs', indent: false },
external: makeExternalPredicate([
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
]),
external,
plugins: [
nodeResolve({
extensions
Expand All @@ -51,10 +46,7 @@ export default [
{
input: 'src/index.ts',
output: { file: 'es/redux.js', format: 'es', indent: false },
external: makeExternalPredicate([
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {})
]),
external,
plugins: [
nodeResolve({
extensions
Expand Down Expand Up @@ -98,8 +90,7 @@ export default [
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false
unsafe_comps: true
}
})
]
Expand Down Expand Up @@ -161,10 +152,9 @@ export default [
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false
unsafe_comps: true
}
})
]
}
]
])