Skip to content

Commit

Permalink
expose lite build without dependencies bundled (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikaspran authored May 4, 2020
1 parent b48c76b commit 6a0b228
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
Expand All @@ -36,6 +45,9 @@ function getRollupObject ({ minifying, format = 'umd' } = {}) {
babel()
]
};
if (lite) {
nonMinified.external = Object.keys(packageJson.dependencies);
}
if (minifying) {
nonMinified.plugins.push(terser());
}
Expand All @@ -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 })
];

0 comments on commit 6a0b228

Please sign in to comment.