-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
rollup.config.js
49 lines (48 loc) · 1.44 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import babel from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
/**
* The wrapping added by bundlers when importing ~200 small functions ends up
* being significantly larger when using the `make-plural` ES module endpoint
* compared to CommonJS. However, importing a CommonJS module from a .mjs
* context is difficult to get right in all environment at the same time, so
* we're vendoring that dependency into `plural-rules.js`
*/
export default [
{
input: 'src/factory.mjs',
output: { file: 'factory.mjs', format: 'es' },
plugins: [babel({ babelHelpers: 'bundled' })]
},
{
input: 'src/factory.mjs',
output: { file: 'factory.js', format: 'cjs', exports: 'default' },
plugins: [babel({ babelHelpers: 'bundled' })]
},
{
input: 'src/plural-rules.mjs',
external: ['./factory.mjs'],
output: {
file: 'plural-rules.js',
format: 'cjs',
exports: 'default',
paths: id => id.replace(/^.*\/([^/]+)\.mjs$/, './$1.js')
},
plugins: [
resolve({ extensions: ['.js'] }),
commonjs(),
babel({ babelHelpers: 'bundled' })
]
},
{
input: 'src/polyfill.mjs',
context: 'this',
external: ['./plural-rules.mjs'],
output: {
file: 'polyfill.js',
format: 'cjs',
paths: id => id.replace(/^.*\/([^/]+)\.mjs$/, './$1.js')
},
plugins: [babel({ babelHelpers: 'bundled' })]
}
]