Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 4a2dff3

Browse files
committed
Build-all by default
1 parent 696b0e9 commit 4a2dff3

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

packages/optimizely-sdk/rollup.config.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,24 @@ const bundles = {
154154
'umd': umdBundle,
155155
}
156156

157-
const bundlesMatching = key => Object.entries(bundles)
158-
.filter(([name, config]) => RegExp(key).test(name))
159-
.map(([_, config]) => config)
157+
// Returns the bundle config matching the given pattern
158+
const bundlesMatching = pattern => Object.entries(bundles)
159+
.reduce((bundles, [name, config]) => {
160+
if (name.match(pattern)) bundles.push(config)
161+
return bundles
162+
}, [])
160163

161-
export default args => Object.keys(args)
162-
.filter(arg => arg.startsWith('config-'))
163-
.map(arg => arg.replace(/config-/, ''))
164-
.flatMap(bundlesMatching)
164+
// Collect all --config-* options and return the matching bundle configs
165+
// Builds all bundles if no --config-* option given
166+
// --config-cjs will build all three cjs-* bundles
167+
// --config-umd will build only the umd bundle
168+
// --config-umd --config-json will build both umd and the json-schema bundles
169+
export default args => {
170+
const patterns = Object.keys(args)
171+
.filter(arg => arg.startsWith('config-'))
172+
.map(arg => arg.replace(/config-/, ''))
173+
174+
if (!patterns.length) patterns.push(/.*/)
175+
176+
return patterns.flatMap(bundlesMatching)
177+
}

0 commit comments

Comments
 (0)