diff --git a/BUILDING.md b/BUILDING.md index 816ecb20daa..c2aea8a659e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -40,13 +40,6 @@ then simply run, browserify index.js > bundle.js ``` -to trim meta information (and thus save a few bytes), run: - - -``` -browserify -t path/to/plotly.js/tasks/util/compress_attributes.js index.js > bundle.js -``` - ## Angular CLI Currently Angular CLI uses Webpack under the hood to bundle and build your Angular application. diff --git a/package.json b/package.json index 7b1a6d52425..f422ff42cb1 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ }, "browserify": { "transform": [ - "glslify" + "glslify", + "./tasks/compress_attributes.js" ] }, "dependencies": { diff --git a/tasks/bundle.js b/tasks/bundle.js index 7c6586c1c14..a4f0fce1516 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -50,7 +50,6 @@ tasks.push(function(cb) { _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, { standalone: 'Plotly', debug: DEV, - compressAttrs: true, pathToMinBundle: constants.pathToPlotlyDistMin }, cb); }); @@ -62,11 +61,12 @@ tasks.push(function(cb) { }, cb); }); -// Browserify the plotly.js with meta +// Browserify plotly.js with meta and output plot-schema JSON tasks.push(function(cb) { _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, { standalone: 'Plotly', debug: DEV, + noCompress: true }, function() { makeSchema(constants.pathToPlotlyDistWithMeta, constants.pathToSchema)(); cb(); @@ -79,7 +79,6 @@ constants.partialBundlePaths.forEach(function(pathObj) { _bundle(pathObj.index, pathObj.dist, { standalone: 'Plotly', debug: DEV, - compressAttrs: true, pathToMinBundle: pathObj.distMin }, cb); }); diff --git a/tasks/cibundle.js b/tasks/cibundle.js index 5a2310e2295..7b53995b81e 100644 --- a/tasks/cibundle.js +++ b/tasks/cibundle.js @@ -11,12 +11,10 @@ var _bundle = require('./util/browserify_wrapper'); * - plotly.min.js bundle in dist/ (for requirejs test) */ - // Browserify plotly.js and plotly.min.js _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuild, { standalone: 'Plotly', debug: true, - compressAttrs: true, pathToMinBundle: constants.pathToPlotlyDistMin }); diff --git a/tasks/util/compress_attributes.js b/tasks/compress_attributes.js similarity index 100% rename from tasks/util/compress_attributes.js rename to tasks/compress_attributes.js diff --git a/tasks/util/browserify_wrapper.js b/tasks/util/browserify_wrapper.js index 362a6121097..7a4e49113b4 100644 --- a/tasks/util/browserify_wrapper.js +++ b/tasks/util/browserify_wrapper.js @@ -7,7 +7,6 @@ var derequire = require('derequire'); var through = require('through2'); var constants = require('./constants'); -var compressAttributes = require('./compress_attributes'); var strictD3 = require('./strict_d3'); /** Convenience browserify wrapper @@ -20,7 +19,7 @@ var strictD3 = require('./strict_d3'); * - debug {boolean} [optional] * Additional option: * - pathToMinBundle {string} path to destination minified bundle - * - compressAttrs {boolean} do we compress attribute meta? + * - noCompress {boolean} skip attribute meta compression? * @param {function} cb callback * * Outputs one bundle (un-minified) file if opts.pathToMinBundle is omitted @@ -38,10 +37,11 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) { browserifyOpts.standalone = opts.standalone; browserifyOpts.debug = opts.debug; - browserifyOpts.transform = []; - if(opts.compressAttrs) { - browserifyOpts.transform.push(compressAttributes); + if(opts.noCompress) { + browserifyOpts.ignoreTransform = './tasks/compress_attributes.js'; } + + browserifyOpts.transform = []; if(opts.debug) { browserifyOpts.transform.push(strictD3); } diff --git a/tasks/util/watchified_bundle.js b/tasks/util/watchified_bundle.js index 864716dca6f..05fb07c9526 100644 --- a/tasks/util/watchified_bundle.js +++ b/tasks/util/watchified_bundle.js @@ -6,7 +6,6 @@ var prettySize = require('prettysize'); var constants = require('./constants'); var common = require('./common'); -var compressAttributes = require('./compress_attributes'); var strictD3 = require('./strict_d3'); /** @@ -23,7 +22,7 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) { var b = browserify(constants.pathToPlotlyIndex, { debug: true, standalone: 'Plotly', - transform: [strictD3, compressAttributes], + transform: [strictD3], cache: {}, packageCache: {}, plugin: [watchify] diff --git a/test/jasmine/tests/plotschema_test.js b/test/jasmine/bundle_tests/plotschema_test.js similarity index 100% rename from test/jasmine/tests/plotschema_test.js rename to test/jasmine/bundle_tests/plotschema_test.js diff --git a/test/jasmine/karma.conf.js b/test/jasmine/karma.conf.js index 66bce39e73c..4050c8ccc5e 100644 --- a/test/jasmine/karma.conf.js +++ b/test/jasmine/karma.conf.js @@ -274,6 +274,10 @@ if(isBundleTest) { func.defaultConfig.files.push(pathToIE9mock); func.defaultConfig.preprocessors[testFileGlob] = ['browserify']; break; + case 'plotschema': + func.defaultConfig.browserify.ignoreTransform = './tasks/compress_attributes.js'; + func.defaultConfig.preprocessors[testFileGlob] = ['browserify']; + break; default: func.defaultConfig.preprocessors[testFileGlob] = ['browserify']; break;