@@ -5,6 +5,7 @@ import commonjs from '@rollup/plugin-commonjs';
55import json from '@rollup/plugin-json' ;
66
77import babel from 'rollup-plugin-babel' ;
8+ import packageJson from './package.json' ;
89
910/**
1011 * @external RollupConfig
@@ -16,18 +17,26 @@ import babel from 'rollup-plugin-babel';
1617 * @param {PlainObject } [config= {}]
1718 * @param {boolean } [config.minifying=false]
1819 * @param {string } [config.format='umd']
20+ * @param {boolean } [config.lite=false]
1921 * @returns {external:RollupConfig }
2022 */
21- function getRollupObject ( { minifying, format = 'umd' } = { } ) {
23+ function getRollupObject ( { minifying = false , format = 'umd' , lite = false } = { } ) {
2224 const nonMinified = {
2325 input : 'esquery.js' ,
2426 output : {
2527 format,
2628 sourcemap : minifying ,
27- file : `dist/esquery${
28- format === 'umd' ? '' : `.${ format } `
29- } ${ minifying ? '.min' : '' } .js`,
30- name : 'esquery'
29+ file : [
30+ 'dist/esquery' ,
31+ lite ? '.lite' : '' ,
32+ format === 'umd' ? '' : `.${ format } ` ,
33+ minifying ? '.min' : '' ,
34+ '.js'
35+ ] . join ( '' ) ,
36+ name : 'esquery' ,
37+ globals : {
38+ estraverse : 'estraverse'
39+ }
3140 } ,
3241 plugins : [
3342 json ( ) ,
@@ -36,6 +45,9 @@ function getRollupObject ({ minifying, format = 'umd' } = {}) {
3645 babel ( )
3746 ]
3847 } ;
48+ if ( lite ) {
49+ nonMinified . external = Object . keys ( packageJson . dependencies ) ;
50+ }
3951 if ( minifying ) {
4052 nonMinified . plugins . push ( terser ( ) ) ;
4153 }
@@ -46,5 +58,7 @@ export default [
4658 getRollupObject ( { minifying : true , format : 'umd' } ) ,
4759 getRollupObject ( { minifying : false , format : 'umd' } ) ,
4860 getRollupObject ( { minifying : true , format : 'esm' } ) ,
49- getRollupObject ( { minifying : false , format : 'esm' } )
61+ getRollupObject ( { minifying : false , format : 'esm' } ) ,
62+ getRollupObject ( { minifying : true , format : 'umd' , lite : true } ) ,
63+ getRollupObject ( { minifying : false , format : 'umd' , lite : true } )
5064] ;
0 commit comments