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 typescript from '@rollup/plugin-typescript'; 4import buble from '@rollup/plugin-buble'; 5import terser from '@rollup/plugin-terser'; 6import cjsCheck from 'rollup-plugin-cjs-check'; 7 8import flowTypings from './flow-typings-plugin.mjs'; 9 10const plugins = [ 11 resolve({ 12 extensions: ['.mjs', '.js', '.ts'], 13 mainFields: ['module', 'jsnext', 'main'], 14 preferBuiltins: false, 15 browser: true, 16 }), 17 18 commonjs({ 19 ignoreGlobal: true, 20 include: /\/node_modules\//, 21 extensions: ['.mjs', '.js', '.ts'], 22 }), 23 24 typescript({ 25 exclude: ['src/**/*.test.ts', '**/__tests__/*'], 26 compilerOptions: { 27 sourceMap: true, 28 sourceRoot: './', 29 noEmit: false, 30 declaration: true, 31 declarationDir: './dist/types/', 32 target: 'esnext', 33 }, 34 }), 35 36 cjsCheck(), 37 flowTypings(), 38 39 buble({ 40 transforms: { 41 unicodeRegExp: false, 42 defaultParameter: false, 43 dangerousForOf: true, 44 dangerousTaggedTemplateString: true, 45 destructuring: false, 46 asyncAwait: false, 47 arrow: false, 48 classes: false, 49 computedProperty: false, 50 conciseMethodProperty: false, 51 templateString: false, 52 objectRestSpread: false, 53 parameterDestructuring: false, 54 spreadRest: false, 55 }, 56 exclude: 'node_modules/**', 57 }), 58 59 terser({ 60 warnings: true, 61 ecma: 2015, 62 keep_fnames: true, 63 ie8: false, 64 compress: { 65 pure_getters: true, 66 toplevel: true, 67 booleans_as_integers: false, 68 keep_fnames: true, 69 keep_fargs: true, 70 if_return: false, 71 ie8: false, 72 sequences: false, 73 loops: false, 74 conditionals: false, 75 join_vars: false, 76 }, 77 mangle: { 78 module: true, 79 keep_fnames: true, 80 }, 81 output: { 82 beautify: true, 83 braces: true, 84 indent_level: 2, 85 }, 86 }), 87]; 88 89const output = format => { 90 const extension = format === 'esm' ? '.mjs' : '.js'; 91 return { 92 chunkFileNames: '[hash]' + extension, 93 entryFileNames: '[name]' + extension, 94 dir: './dist', 95 exports: 'named', 96 sourcemap: true, 97 indent: false, 98 freeze: false, 99 strict: false, 100 format, 101 // NOTE: All below settings are important for cjs-module-lexer to detect the export 102 // When this changes (and terser mangles the output) this will interfere with Node.js ESM intercompatibility 103 esModule: format !== 'esm', 104 externalLiveBindings: format !== 'esm', 105 generatedCode: { 106 preset: 'es5', 107 reservedNamesAsProps: false, 108 objectShorthand: false, 109 constBindings: false, 110 }, 111 }; 112}; 113 114const config = { 115 input: { 116 wonka: './src/index.ts', 117 }, 118 onwarn: () => {}, 119 external: () => false, 120 plugins, 121 treeshake: { 122 unknownGlobalSideEffects: false, 123 tryCatchDeoptimization: false, 124 moduleSideEffects: false, 125 }, 126 output: [output('esm'), output('cjs')], 127}; 128 129export default config;