Skip to content

Commit 1b6c9a3

Browse files
authored
Merge pull request #1584 from plotly/compress-attr-transform-by-default
Enable compress attributes browserify transform by default
2 parents fdae65b + 9af5948 commit 1b6c9a3

9 files changed

+14
-20
lines changed

BUILDING.md

-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ then simply run,
4040
browserify index.js > bundle.js
4141
```
4242

43-
to trim meta information (and thus save a few bytes), run:
44-
45-
46-
```
47-
browserify -t path/to/plotly.js/tasks/util/compress_attributes.js index.js > bundle.js
48-
```
49-
5043
## Angular CLI
5144

5245
Currently Angular CLI uses Webpack under the hood to bundle and build your Angular application.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
},
5252
"browserify": {
5353
"transform": [
54-
"glslify"
54+
"glslify",
55+
"./tasks/compress_attributes.js"
5556
]
5657
},
5758
"dependencies": {

tasks/bundle.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ tasks.push(function(cb) {
5050
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, {
5151
standalone: 'Plotly',
5252
debug: DEV,
53-
compressAttrs: true,
5453
pathToMinBundle: constants.pathToPlotlyDistMin
5554
}, cb);
5655
});
@@ -62,11 +61,12 @@ tasks.push(function(cb) {
6261
}, cb);
6362
});
6463

65-
// Browserify the plotly.js with meta
64+
// Browserify plotly.js with meta and output plot-schema JSON
6665
tasks.push(function(cb) {
6766
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, {
6867
standalone: 'Plotly',
6968
debug: DEV,
69+
noCompress: true
7070
}, function() {
7171
makeSchema(constants.pathToPlotlyDistWithMeta, constants.pathToSchema)();
7272
cb();
@@ -79,7 +79,6 @@ constants.partialBundlePaths.forEach(function(pathObj) {
7979
_bundle(pathObj.index, pathObj.dist, {
8080
standalone: 'Plotly',
8181
debug: DEV,
82-
compressAttrs: true,
8382
pathToMinBundle: pathObj.distMin
8483
}, cb);
8584
});

tasks/cibundle.js

-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ var _bundle = require('./util/browserify_wrapper');
1111
* - plotly.min.js bundle in dist/ (for requirejs test)
1212
*/
1313

14-
1514
// Browserify plotly.js and plotly.min.js
1615
_bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuild, {
1716
standalone: 'Plotly',
1817
debug: true,
19-
compressAttrs: true,
2018
pathToMinBundle: constants.pathToPlotlyDistMin
2119
});
2220

File renamed without changes.

tasks/util/browserify_wrapper.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var derequire = require('derequire');
77
var through = require('through2');
88

99
var constants = require('./constants');
10-
var compressAttributes = require('./compress_attributes');
1110
var strictD3 = require('./strict_d3');
1211

1312
/** Convenience browserify wrapper
@@ -20,7 +19,7 @@ var strictD3 = require('./strict_d3');
2019
* - debug {boolean} [optional]
2120
* Additional option:
2221
* - pathToMinBundle {string} path to destination minified bundle
23-
* - compressAttrs {boolean} do we compress attribute meta?
22+
* - noCompress {boolean} skip attribute meta compression?
2423
* @param {function} cb callback
2524
*
2625
* Outputs one bundle (un-minified) file if opts.pathToMinBundle is omitted
@@ -38,10 +37,11 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {
3837
browserifyOpts.standalone = opts.standalone;
3938
browserifyOpts.debug = opts.debug;
4039

41-
browserifyOpts.transform = [];
42-
if(opts.compressAttrs) {
43-
browserifyOpts.transform.push(compressAttributes);
40+
if(opts.noCompress) {
41+
browserifyOpts.ignoreTransform = './tasks/compress_attributes.js';
4442
}
43+
44+
browserifyOpts.transform = [];
4545
if(opts.debug) {
4646
browserifyOpts.transform.push(strictD3);
4747
}

tasks/util/watchified_bundle.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var prettySize = require('prettysize');
66

77
var constants = require('./constants');
88
var common = require('./common');
9-
var compressAttributes = require('./compress_attributes');
109
var strictD3 = require('./strict_d3');
1110

1211
/**
@@ -23,7 +22,7 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) {
2322
var b = browserify(constants.pathToPlotlyIndex, {
2423
debug: true,
2524
standalone: 'Plotly',
26-
transform: [strictD3, compressAttributes],
25+
transform: [strictD3],
2726
cache: {},
2827
packageCache: {},
2928
plugin: [watchify]

test/jasmine/karma.conf.js

+4
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ if(isBundleTest) {
274274
func.defaultConfig.files.push(pathToIE9mock);
275275
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
276276
break;
277+
case 'plotschema':
278+
func.defaultConfig.browserify.ignoreTransform = './tasks/compress_attributes.js';
279+
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
280+
break;
277281
default:
278282
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
279283
break;

0 commit comments

Comments
 (0)