1import commonjs from '@rollup/plugin-commonjs';
2import resolve from '@rollup/plugin-node-resolve';
3import buble from '@rollup/plugin-buble';
4import babel from 'rollup-plugin-babel';
5
6const plugins = [
7 commonjs({
8 ignoreGlobal: true,
9 include: ['*', '**'],
10 extensions: ['.js', '.ts', '.tsx'],
11 }),
12 resolve({
13 mainFields: ['module', 'jsnext', 'main'],
14 extensions: ['.js', '.ts', '.tsx'],
15 browser: true,
16 }),
17 buble({
18 transforms: {
19 unicodeRegExp: false,
20 dangerousForOf: true,
21 dangerousTaggedTemplateString: true,
22 },
23 objectAssign: 'Object.assign',
24 exclude: 'node_modules/**',
25 }),
26 babel({
27 babelrc: false,
28 extensions: ['ts', 'tsx', 'js'],
29 exclude: 'node_modules/**',
30 presets: [],
31 plugins: [
32 '@babel/plugin-transform-object-assign',
33 'babel-plugin-closure-elimination',
34 ],
35 }),
36];
37
38const output = (format = 'cjs', ext = '.js') => ({
39 chunkFileNames: '[hash]' + ext,
40 entryFileNames: 'reghex-[name]' + ext,
41 dir: './dist',
42 exports: 'named',
43 externalLiveBindings: false,
44 sourcemap: true,
45 esModule: false,
46 indent: false,
47 freeze: false,
48 strict: false,
49 format,
50});
51
52export default {
53 input: {
54 core: './src/core.js',
55 babel: './src/babel/plugin.js',
56 macro: './src/babel/macro.js',
57 },
58 onwarn: () => {},
59 external: () => false,
60 treeshake: {
61 propertyReadSideEffects: false,
62 },
63 plugins,
64 output: [output('cjs', '.js'), output('esm', '.mjs')],
65};