Skip to content

Commit 0abfdac

Browse files
committed
fix & update bundle options
1 parent 3a50892 commit 0abfdac

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

tasks/bundle.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ if(!doesFileExist(constants.pathToCSSBuild)) {
3131
// memory consumption.
3232
var tasks = [];
3333

34-
// Browserify plotly.js
34+
// Bundle plotly.js
3535
tasks.push(function(done) {
3636
_bundle(pathToPlotlyIndex, pathToPlotlyDist, {
37-
standalone: 'Plotly',
3837
pathToMinBundle: pathToPlotlyDistMin
3938
}, function() {
4039
prependFile.sync(pathToPlotlyDist, header, common.throwOnError);
@@ -44,10 +43,9 @@ tasks.push(function(done) {
4443
});
4544
});
4645

47-
// Browserify plotly.js-strict
46+
// Bundle plotly.js-strict
4847
tasks.push(function(done) {
4948
_bundle(pathToPlotlyStrict, pathToPlotlyStrictDist, {
50-
standalone: 'Plotly',
5149
pathToMinBundle: pathToPlotlyStrictDistMin
5250
}, function() {
5351
prependFile.sync(pathToPlotlyStrictDist, header.replace('plotly.js', 'plotly.js (strict)'), common.throwOnError);
@@ -57,7 +55,7 @@ tasks.push(function(done) {
5755
});
5856
});
5957

60-
// Browserify the geo assets
58+
// Bundle the geo assets
6159
tasks.push(function(done) {
6260
_bundle(pathToPlotlyGeoAssetsSrc, pathToPlotlyGeoAssetsDist, {
6361
standalone: 'PlotlyGeoAssets'
@@ -68,10 +66,9 @@ tasks.push(function(done) {
6866
});
6967
});
7068

71-
// Browserify plotly.js with meta
69+
// Bundle plotly.js with meta
7270
tasks.push(function(done) {
7371
_bundle(pathToPlotlyIndex, pathToPlotlyDistWithMeta, {
74-
standalone: 'Plotly',
7572
noCompress: true
7673
}, function() {
7774
prependFile.sync(pathToPlotlyDistWithMeta, header, common.throwOnError);

tasks/cibundle.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ var _bundle = require('./util/browserify_wrapper');
1313

1414
// Bundle plotly.js and plotly.min.js
1515
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuild, {
16-
standalone: 'Plotly',
17-
debug: true,
16+
noCompress: true,
1817
pathToMinBundle: constants.pathToPlotlyBuildMin
1918
}, function() {
2019
// Bundle the geo assets

tasks/extra_bundles.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if(process.argv.length > 2) {
2626

2727
var tasks = [];
2828

29-
// Browserify the plotly.js partial bundles
29+
// Bundle the plotly.js partial bundles
3030
for(var i = 0; i < list.length; i++) {
3131
var opts = list[i];
3232

tasks/partial_bundle.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var allTransforms = constants.allTransforms;
99
var allTraces = constants.allTraces;
1010
var mainIndex = constants.mainIndex;
1111

12-
// Browserify the plotly.js partial bundles
12+
// Bundle the plotly.js partial bundles
1313
module.exports = function partialBundle(tasks, opts) {
1414
var name = opts.name;
1515
var index = opts.index;
@@ -54,7 +54,6 @@ module.exports = function partialBundle(tasks, opts) {
5454

5555
tasks.push(function(done) {
5656
var bundleOpts = {
57-
standalone: 'Plotly',
5857
deleteIndex: deleteIndex,
5958
pathToMinBundle: distMin
6059
};

tasks/util/browserify_wrapper.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ var webpack = require('webpack');
44

55
var config = require('../../webpack.config.js');
66

7+
var nRules = config.module.rules.length;
8+
79
/** Convenience bundle wrapper
810
*
911
* @param {string} pathToIndex path to index file to bundle
1012
* @param {string} pathToBunlde path to destination bundle
1113
* @param {object} opts
1214
* Browserify options:
1315
* - standalone {string}
14-
* - debug {boolean} [optional]
1516
* Additional option:
1617
* - pathToMinBundle {string} path to destination minified bundle
1718
* - noCompress {boolean} skip attribute meta compression?
@@ -27,14 +28,12 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {
2728

2829
var pathToMinBundle = opts.pathToMinBundle;
2930

30-
if(!opts.noCompress) {
31-
config.module.rules.push({
32-
test: /\.(js|glsl)$/,
33-
use: [
34-
'ify-loader'
35-
]
36-
});
37-
}
31+
config.module.rules[nRules] = opts.noCompress ? {} : {
32+
test: /\.js$/,
33+
use: [
34+
'transform-loader?' + path.resolve(__dirname, '../../tasks/compress_attributes.js')
35+
]
36+
};
3837

3938
config.entry = pathToIndex;
4039

@@ -45,8 +44,10 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {
4544
config.output.path = parsedPath.dir;
4645
config.output.filename = parsedPath.base;
4746

47+
config.output.library.name = opts.standalone || 'Plotly';
48+
4849
config.optimization = {
49-
minimize: pathToMinBundle && pending === 1
50+
minimize: !!(pathToMinBundle && pending === 1)
5051
};
5152

5253
var compiler = webpack(config);

0 commit comments

Comments
 (0)