Mirror: 馃帺 A tiny but capable push & pull stream library for TypeScript and Flow
1import commonjs from '@rollup/plugin-commonjs'; 2import resolve from '@rollup/plugin-node-resolve'; 3import sucrase from '@rollup/plugin-sucrase'; 4import buble from '@rollup/plugin-buble'; 5import terser from '@rollup/plugin-terser'; 6import cjsCheck from 'rollup-plugin-cjs-check'; 7import dts from 'rollup-plugin-dts'; 8 9import flowTypings from './flow-typings-plugin.mjs'; 10 11const commonPlugins = [ 12 resolve({ 13 extensions: ['.mjs', '.js', '.ts'], 14 mainFields: ['module', 'jsnext', 'main'], 15 preferBuiltins: false, 16 browser: true, 17 }), 18 19 commonjs({ 20 ignoreGlobal: true, 21 include: /\/node_modules\//, 22 extensions: ['.mjs', '.js', '.ts'], 23 }), 24 25 sucrase({ 26 exclude: ['node_modules/**'], 27 transforms: ['typescript'] 28 }), 29]; 30 31const jsPlugins = [ 32 ...commonPlugins, 33 cjsCheck(), 34 35 buble({ 36 transforms: { 37 unicodeRegExp: false, 38 defaultParameter: false, 39 dangerousForOf: true, 40 dangerousTaggedTemplateString: true, 41 destructuring: false, 42 asyncAwait: false, 43 arrow: false, 44 classes: false, 45 computedProperty: false, 46 conciseMethodProperty: false, 47 templateString: false, 48 objectRestSpread: false, 49 parameterDestructuring: false, 50 spreadRest: false, 51 }, 52 exclude: 'node_modules/**', 53 }), 54 55 terser({ 56 warnings: true, 57 ecma: 2015, 58 keep_fnames: true, 59 ie8: false, 60 compress: { 61 pure_getters: true, 62 toplevel: true, 63 booleans_as_integers: false, 64 keep_fnames: true, 65 keep_fargs: true, 66 if_return: false, 67 ie8: false, 68 sequences: false, 69 loops: false, 70 conditionals: false, 71 join_vars: false, 72 }, 73 mangle: { 74 module: true, 75 keep_fnames: true, 76 }, 77 output: { 78 beautify: true, 79 braces: true, 80 indent_level: 2, 81 }, 82 }), 83]; 84 85const dtsPlugins = [ 86 ...commonPlugins, 87 dts(), 88 flowTypings(), 89]; 90 91const output = format => { 92 const extension = format === 'esm' ? '.mjs' : '.js'; 93 return { 94 chunkFileNames: '[hash]' + extension, 95 entryFileNames: '[name]' + extension, 96 dir: './dist', 97 exports: 'named', 98 sourcemap: true, 99 sourcemapExcludeSources: false, 100 indent: false, 101 freeze: false, 102 strict: false, 103 format, 104 // NOTE: All below settings are important for cjs-module-lexer to detect the export 105 // When this changes (and terser mangles the output) this will interfere with Node.js ESM intercompatibility 106 esModule: format !== 'esm', 107 externalLiveBindings: format !== 'esm', 108 generatedCode: { 109 preset: 'es5', 110 reservedNamesAsProps: false, 111 objectShorthand: false, 112 constBindings: false, 113 }, 114 }; 115}; 116 117const commonConfig = { 118 input: { 119 wonka: './src/index.ts', 120 }, 121 onwarn: () => {}, 122 external: () => false, 123 treeshake: { 124 unknownGlobalSideEffects: false, 125 tryCatchDeoptimization: false, 126 moduleSideEffects: false, 127 }, 128}; 129 130const jsConfig = { 131 ...commonConfig, 132 plugins: jsPlugins, 133 output: [ 134 output('esm'), 135 output('cjs'), 136 ], 137}; 138 139const dtsConfig = { 140 ...commonConfig, 141 input: { 142 wonka: './src/index.ts', 143 }, 144 onwarn: () => {}, 145 external: () => false, 146 plugins: dtsPlugins, 147 treeshake: { 148 unknownGlobalSideEffects: false, 149 tryCatchDeoptimization: false, 150 moduleSideEffects: false, 151 }, 152 output: { 153 dir: './dist', 154 entryFileNames: '[name].d.ts', 155 format: 'es' 156 }, 157}; 158 159export default [ 160 jsConfig, 161 dtsConfig, 162];