diff --git a/rollup.config.js b/rollup.config.js index b2f36dc..563a1bb 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,6 +5,7 @@ import commonjs from '@rollup/plugin-commonjs'; import json from '@rollup/plugin-json'; import babel from 'rollup-plugin-babel'; +import packageJson from './package.json'; /** * @external RollupConfig @@ -16,18 +17,26 @@ import babel from 'rollup-plugin-babel'; * @param {PlainObject} [config= {}] * @param {boolean} [config.minifying=false] * @param {string} [config.format='umd'] + * @param {boolean} [config.lite=false] * @returns {external:RollupConfig} */ -function getRollupObject ({ minifying, format = 'umd' } = {}) { +function getRollupObject ({ minifying = false, format = 'umd', lite = false } = {}) { const nonMinified = { input: 'esquery.js', output: { format, sourcemap: minifying, - file: `dist/esquery${ - format === 'umd' ? '' : `.${format}` - }${minifying ? '.min' : ''}.js`, - name: 'esquery' + file: [ + 'dist/esquery', + lite ? '.lite' : '', + format === 'umd' ? '' : `.${format}`, + minifying ? '.min' : '', + '.js' + ].join(''), + name: 'esquery', + globals: { + estraverse: 'estraverse' + } }, plugins: [ json(), @@ -36,6 +45,9 @@ function getRollupObject ({ minifying, format = 'umd' } = {}) { babel() ] }; + if (lite) { + nonMinified.external = Object.keys(packageJson.dependencies); + } if (minifying) { nonMinified.plugins.push(terser()); } @@ -46,5 +58,7 @@ export default [ getRollupObject({ minifying: true, format: 'umd' }), getRollupObject({ minifying: false, format: 'umd' }), getRollupObject({ minifying: true, format: 'esm' }), - getRollupObject({ minifying: false, format: 'esm' }) + getRollupObject({ minifying: false, format: 'esm' }), + getRollupObject({ minifying: true, format: 'umd', lite: true }), + getRollupObject({ minifying: false, format: 'umd', lite: true }) ];