diff --git a/tasks/bundle.mjs b/tasks/bundle.mjs index 84b6bda0721..5ff76c5df68 100644 --- a/tasks/bundle.mjs +++ b/tasks/bundle.mjs @@ -34,9 +34,18 @@ var tasks = []; // Bundle plotly.js tasks.push(function(done) { _bundle(pathToPlotlyIndex, pathToPlotlyDist, { - pathToMinBundle: pathToPlotlyDistMin }, function() { prependFile.sync(pathToPlotlyDist, header, common.throwOnError); + + done(); + }); +}); + +// Bundle plotly.min.js +tasks.push(function(done) { + _bundle(pathToPlotlyIndex, pathToPlotlyDistMin, { + minify: true, + }, function() { prependFile.sync(pathToPlotlyDistMin, header, common.throwOnError); done(); @@ -46,9 +55,18 @@ tasks.push(function(done) { // Bundle plotly.js-strict tasks.push(function(done) { _bundle(pathToPlotlyStrict, pathToPlotlyStrictDist, { - pathToMinBundle: pathToPlotlyStrictDistMin }, function() { prependFile.sync(pathToPlotlyStrictDist, header.replace('plotly.js', 'plotly.js (strict)'), common.throwOnError); + + done(); + }); +}); + +// Bundle plotly.min.js-strict +tasks.push(function(done) { + _bundle(pathToPlotlyStrict, pathToPlotlyStrictDistMin, { + minify: true, + }, function() { prependFile.sync(pathToPlotlyStrictDistMin, header.replace('plotly.js', 'plotly.js (strict - minified)'), common.throwOnError); done(); diff --git a/tasks/cibundle.mjs b/tasks/cibundle.mjs index 4074ba3a263..f0d8761634c 100644 --- a/tasks/cibundle.mjs +++ b/tasks/cibundle.mjs @@ -1,3 +1,4 @@ +import runSeries from 'run-series'; import constants from './util/constants.js'; import _bundle from './util/bundle_wrapper.mjs'; @@ -11,14 +12,33 @@ import _bundle from './util/bundle_wrapper.mjs'; * - plotly.min.js bundle in build/ (for minified_bundle test) */ -// Bundle plotly.js and plotly.min.js -_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuild, { - noCompressAttributes: true, - pathToMinBundle: constants.pathToPlotlyBuildMin -}, function() { - // Bundle the geo assets +// list of tasks to pass to run-series to not blow up +// memory consumption. +var tasks = []; + +// Bundle plotly.js +tasks.push(function(done) { + _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuild, { + noCompressAttributes: true, + }, done) +}); + +// Bundle plotly.min.js +tasks.push(function(done) { + _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuildMin, { + minify: true, + noCompressAttributes: true, + }, done) +}); + +// Bundle the geo assets +tasks.push(function(done) { _bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, { noPlugins: true, standalone: 'PlotlyGeoAssets' - }); + }, done) +}); + +runSeries(tasks, function(err) { + if(err) throw err; }); diff --git a/tasks/partial_bundle.mjs b/tasks/partial_bundle.mjs index c51a4acbae4..9f8b868eb97 100644 --- a/tasks/partial_bundle.mjs +++ b/tasks/partial_bundle.mjs @@ -55,15 +55,27 @@ export default function partialBundle(tasks, opts) { tasks.push(function(done) { var bundleOpts = { - deleteIndex: deleteIndex, - pathToMinBundle: distMin + deleteIndex: deleteIndex && !distMin, }; _bundle(index, dist, bundleOpts, function() { var headerDist = header.replace('plotly.js', 'plotly.js (' + name + ')'); - var headerDistMin = header.replace('plotly.js', 'plotly.js (' + name + ' - minified)'); if(dist) prependFile.sync(dist, headerDist, common.throwOnError); + + done(); + }); + }); + + tasks.push(function(done) { + var bundleOpts = { + deleteIndex: deleteIndex, + minify: true, + }; + + _bundle(index, distMin, bundleOpts, function() { + var headerDistMin = header.replace('plotly.js', 'plotly.js (' + name + ' - minified)'); + if(distMin) prependFile.sync(distMin, headerDistMin, common.throwOnError); done(); diff --git a/tasks/util/bundle_wrapper.mjs b/tasks/util/bundle_wrapper.mjs index 39b2a804620..3955735aa87 100644 --- a/tasks/util/bundle_wrapper.mjs +++ b/tasks/util/bundle_wrapper.mjs @@ -15,11 +15,9 @@ var basePlugins = esbuildConfig.plugins; * Bundle options: * - standalone {string} * Additional option: - * - pathToMinBundle {string} path to destination minified bundle * - noCompressAttributes {boolean} skip attribute meta compression? * @param {function} cb callback * - * Outputs one bundle (un-minified) file if opts.pathToMinBundle is omitted. * Otherwise outputs two file: one un-minified bundle and one minified bundle. * * Logs basename of bundle when completed. @@ -30,28 +28,15 @@ export default async function _bundle(pathToIndex, pathToBundle, opts, cb) { var config = {...esbuildConfig}; config.entryPoints = [pathToIndex]; - config.outfile = pathToBundle || pathToMinBundle; + config.outfile = pathToBundle; + config.minify = !!opts.minify; + if(!opts.noCompressAttributes) { config.plugins = basePlugins.concat([browserifyAdapter(transform)]); } if(opts.noPlugins) config.plugins = []; - var pathToMinBundle = opts.pathToMinBundle; - var pending = (pathToMinBundle && pathToBundle) ? 2 : 1; - - config.minify = !!(pathToMinBundle && pending === 1); - config.outfile = pathToBundle || pathToMinBundle; - config.sourcemap = false; - build(config).then(function() { - if(pending === 2) { - config.minify = true; - config.outfile = pathToMinBundle; - // config.sourcemap = true; - build(config).then(function() { - if(cb) cb(); - }); - } else { - if(cb) cb(); - } - }); + + await build(config); + if(cb) cb(); }