From 74f9f396fea73ece186e6e46972d39c91c6505d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Tue, 11 Apr 2017 16:54:26 -0400 Subject: [PATCH 1/5] bump browserify version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f5b0f7157a1..270cb2c4540 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ }, "devDependencies": { "brfs": "^1.4.3", - "browserify": "^14.1.0", + "browserify": "^14.3.0", "browserify-transform-tools": "^1.7.0", "deep-equal": "^1.0.1", "ecstatic": "^2.1.0", From 3485c0eec5d70a3acacdb3f3b2c7e02507cdd1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Tue, 11 Apr 2017 16:56:38 -0400 Subject: [PATCH 2/5] add compress_attributes.js transform to "browserify" field - so that it is enabled by default on browserify builds - mv it to `./tasks/` for better discoveribility - ignore it when bundling plotly-with-meta.js bundle - :hocho: other refs to compress_attributes.js --- package.json | 3 ++- tasks/bundle.js | 3 ++- tasks/{util => }/compress_attributes.js | 0 tasks/util/browserify_wrapper.js | 6 ++++-- tasks/util/watchified_bundle.js | 2 -- 5 files changed, 8 insertions(+), 6 deletions(-) rename tasks/{util => }/compress_attributes.js (100%) diff --git a/package.json b/package.json index 270cb2c4540..e124910905b 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ }, "browserify": { "transform": [ - "glslify" + "glslify", + "./tasks/compress_attributes.js" ] }, "dependencies": { diff --git a/tasks/bundle.js b/tasks/bundle.js index 0fc7c7cd4d8..a7cda6888d7 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -41,7 +41,8 @@ _bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, // Browserify the plotly.js with meta _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDistWithMeta, { standalone: 'Plotly', - debug: DEV + debug: DEV, + noCompress: true }); // Browserify the plotly.js partial bundles 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 0e13fa01874..6e61c5679e7 100644 --- a/tasks/util/browserify_wrapper.js +++ b/tasks/util/browserify_wrapper.js @@ -5,7 +5,6 @@ var browserify = require('browserify'); var UglifyJS = require('uglify-js'); var constants = require('./constants'); -var compressAttributes = require('./compress_attributes'); var patchMinified = require('./patch_minified'); /** Convenience browserify wrapper @@ -38,7 +37,10 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts) { var browserifyOpts = {}; browserifyOpts.standalone = opts.standalone; browserifyOpts.debug = opts.debug; - browserifyOpts.transform = outputMinified ? [compressAttributes] : []; + + if(opts.noCompress) { + browserifyOpts.ignoreTransform = './tasks/compress_attributes.js'; + } var b = browserify(pathToIndex, browserifyOpts), bundleWriteStream = fs.createWriteStream(pathToBundle); diff --git a/tasks/util/watchified_bundle.js b/tasks/util/watchified_bundle.js index e2ab22068ee..82166590b56 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'); /** * Make a plotly.js browserify bundle function watched by watchify. @@ -22,7 +21,6 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) { var b = browserify(constants.pathToPlotlyIndex, { debug: true, standalone: 'Plotly', - transform: [compressAttributes], cache: {}, packageCache: {}, plugin: [watchify] From ce2a33aae96e022791ce9ff34daaf35db48b910f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 10 Sep 2018 12:04:37 -0400 Subject: [PATCH 3/5] :hocho: now obsolete compressAttrs arg --- tasks/bundle.js | 4 +--- tasks/cibundle.js | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tasks/bundle.js b/tasks/bundle.js index 3a2ed744c1c..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,7 +61,7 @@ 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', @@ -80,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 }); From 7e7baafba1e611ac757666ed3862a80bc0d1300b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 10 Sep 2018 12:05:26 -0400 Subject: [PATCH 4/5] move plotschema_test to bundle_tests/ ... where we ignore the compress_attributes.js transform on bundling. --- test/jasmine/{tests => bundle_tests}/plotschema_test.js | 0 test/jasmine/karma.conf.js | 4 ++++ 2 files changed, 4 insertions(+) rename test/jasmine/{tests => bundle_tests}/plotschema_test.js (100%) 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; From 9af5948f1471f0614b0cf956c4d57b6a4a2dad94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 10 Sep 2018 14:35:26 -0400 Subject: [PATCH 5/5] rm info about compress_attributes transform --- BUILDING.md | 7 ------- 1 file changed, 7 deletions(-) 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.