rollup.config.js 4.56 KB
Newer Older
prova's avatar
prova committed
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
/*jshint esversion: 6 */

import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import lodash from 'lodash';

/**
 * Add here external dependencies that actually you use.
 * 
 * Angular dependencies
 * - '@angular/animations' => 'ng.animations'
 * - '@angular/animations/browser': 'ng.animations.browser'
 * - '@angular/common' => 'ng.common'
 * - '@angular/compiler' => 'ng.compiler'
 * - '@angular/core' => 'ng.core'
 * - '@angular/forms' => 'ng.forms'
 * - '@angular/common/http' => 'ng.common.http'
 * - '@angular/platform-browser-dynamic' => 'ng.platformBrowserDynamic'
 * - '@angular/platform-browser' => 'ng.platformBrowser'
 * - '@angular/platform-browser/animations' => 'ng.platformBrowser.animations'
 * - '@angular/platform-server' => 'ng.platformServer'
 * - '@angular/router' => 'ng.router'
 * 
 * RxJS dependencies
 * From RxJS v6 you need only 'rxjs' and 'rxjs.operators'.
 * 
 * Other dependencies
 * - Angular libraries: refer to their global namespace
 * - TypeScript/JavaScript libraries:
 *      e.g. lodash: 'lodash' => 'lodash'
 *      
 * Also, if the dependency uses CommonJS modules, such as lodash,
 * you should also use a plugin like rollup-plugin-commonjs,
 * to explicitly specify unresolvable "named exports".
 * 
 */

const angularglobals = {
    '@angular/core': 'ng.core',
    '@angular/http': 'ng.http',
    '@angular/forms': 'ng.forms',
    '@angular/common': 'ng.common',
    '@angular/router': 'ng.router',
    '@angular/compiler': 'ng.compiler',
    '@angular/elements': 'ng.elements',
    '@angular/animations': 'ng.animations',
    '@angular/animations/browser': 'ng.animations.browser',
    '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
    '@angular/platform-browser/animations': 'ng.platformBrowser.animations',
};

const rxjsGlobals = {
    'rxjs': 'rxjs',
    'rxjs/Subject': 'rxjs',
    'rxjs/Observer': 'rxjs',
    'rxjs/Observable': 'rxjs',
    'rxjs/Subscription': 'rxjs',
    'rxjs/ReplaySubject': 'rxjs',
    'rxjs/BehaviorSubject': 'rxjs',
    'rxjs/operators': 'rxjs.operators',
    'rxjs/observable': 'rxjs.observable',
    'rxjs/observable/of': 'rxjs.observable',
    'rxjs/observable/empty': 'rxjs.observable',
    'rxjs/observable/from': 'rxjs.observable',
    'rxjs/observable/fromEvent': 'rxjs.observable',
    'rxjs/observable/fromPromise': 'rxjs.observable',
    'rxjs/observable/interval': 'rxjs.observable',
    'rxjs/observable/merge': 'rxjs.observable',
    'rxjs/operators/filter': 'rxjs.operators',
    'rxjs/operators/merge': 'rxjs.operators',
    'rxjs/operators/scan': 'rxjs.operators',
    'rxjs/operators/takeWhile': 'rxjs.operators',
    'rxjs/operators/partition': 'rxjs.operators',
    'rxjs/operators/concatMap': 'rxjs.operators',
    'rxjs/operators/startWith': 'rxjs.operators',
    'rxjs/operators/takeUntil': 'rxjs.operators',
    'rxjs/operators/switchMap': 'rxjs.operators',
    'rxjs/operators/switchMapTo': 'rxjs.operators',
    'rxjs/operators/catchError': 'rxjs.operators',
    'rxjs/operators/skipWhile': 'rxjs.operators',
    'rxjs/observable/combineLatest': 'rxjs.operators',
    'rxjs/operators/skip': 'rxjs.operators',
    'rxjs/operators/map': 'rxjs.operators',
    'rxjs/operators/tap': 'rxjs.operators',
    'rxjs/operators/take': 'rxjs.operators',
    'rxjs/operators/auditTime': 'rxjs.operators',
    'rxjs/operators/distinctUntilChanged': 'rxjs.operators',
    'rxjs/operators/throttleTime': 'rxjs.operators',
    'rxjs/observable/zip': 'rxjs.operators',
    'rxjs/operators/delay': 'rxjs.operators',
    'rxjs/operators/debounceTime': 'rxjs.operators',
    'rxjs/operators/bufferCount': 'rxjs.operators',
    'rxjs/scheduler/animationFrame': 'rxjs.scheduler'
}

const otherGlobals = {
    'lodash': 'lodash',
    'util': 'util'
};

const maggioliGlobals = {
    '@maggioli/cmn-ng': 'maggioli.cmnNg',
    '@maggioli/ctl-dt': 'maggioli.ctlDt',
    '@maggioli/grd-dt': 'maggioli.grdDt',
};

const globals = { ...angularglobals, ...rxjsGlobals, ...otherGlobals, ...maggioliGlobals };

const format = `umd`
const sourcemap = false
const name = `maggioli.lytDt`
const exports = `named`

const output = { format, name, globals, sourcemap, exports }

const external = lodash.keys(globals)

export default {
    external, 
    plugins: [
        resolve({
            mainFields: ['module', 'main', 'jsnext', 'browser'],
            extensions: ['.js'],
        }),
        commonjs({
            include: [
                'node_modules/**',
            ],
            namedExports: {
                'rxjs/symbol/iterator': ['iterator'],
            },
        }),
        // sourcemaps()
    ],
    output
};