From 63041bcc74ba3d7f52523636516d65098e5c9659 Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 18 Nov 2015 13:43:38 -0500 Subject: [PATCH 1/4] rm all traces of appendVersion: - appending `Plotly.version` is the bundle break UMD more info: https://github.com/plotly/plotly.js/issues/14 --- tasks/bundle.js | 23 ++++------------------- tasks/cibundle.js | 11 ++--------- tasks/util/append_version.js | 24 ------------------------ tasks/util/make_watchified_bundle.js | 4 ---- 4 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 tasks/util/append_version.js diff --git a/tasks/bundle.js b/tasks/bundle.js index 86df8aaf28f..2b13767ddab 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -4,7 +4,6 @@ var browserify = require('browserify'); var UglifyJS = require('uglify-js'); var compressAttributes = require('./util/compress_attributes'); -var appendVersion = require('./util/append_version'); var constants = require('./util/constants'); /* @@ -48,19 +47,11 @@ browserify(constants.pathToPlotlySrc, { if(!DEV) { fs.writeFile( constants.pathToPlotlyDistMin, - UglifyJS.minify(buf.toString(), constants.uglifyOptions).code, - function() { - appendVersion( - constants.pathToPlotlyDistMin, {object: 'Plotly'} - ); - } + UglifyJS.minify(buf.toString(), constants.uglifyOptions).code ); } }) -.pipe(fs.createWriteStream(constants.pathToPlotlyDist)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyDist, {object: 'Plotly', DEV: DEV}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyDist)); // Browserify the geo assets @@ -70,10 +61,7 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyGeoAssetsDist, {object: 'PlotlyGeoAssets'}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)); // Browserify the plotly.js with meta @@ -84,7 +72,4 @@ browserify(constants.pathToPlotlySrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyDistWithMeta)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyDistWithMeta, {object: 'Plotly', DEV: DEV}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyDistWithMeta)); diff --git a/tasks/cibundle.js b/tasks/cibundle.js index 1c37f3b7cd4..8e1db62885d 100644 --- a/tasks/cibundle.js +++ b/tasks/cibundle.js @@ -3,7 +3,6 @@ var fs = require('fs'); var browserify = require('browserify'); var compressAttributes = require('./util/compress_attributes'); -var appendVersion = require('./util/append_version'); var constants = require('./util/constants'); /* @@ -24,10 +23,7 @@ browserify(constants.pathToPlotlySrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyBuild)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyBuild, {object: 'Plotly'}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyBuild)); // Browserify the geo assets @@ -37,7 +33,4 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { .bundle(function(err) { if(err) throw err; }) -.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)) -.on('finish', function() { - appendVersion(constants.pathToPlotlyGeoAssetsDist, {object: 'PlotlyGeoAssets'}); -}); +.pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)); diff --git a/tasks/util/append_version.js b/tasks/util/append_version.js deleted file mode 100644 index cc17057e40d..00000000000 --- a/tasks/util/append_version.js +++ /dev/null @@ -1,24 +0,0 @@ -var fs = require('fs'); - -var pkg = require('../../package.json'); - -/** - * Append package version to bundle - * - * @param {string} path path to bundle - * @param {object} opts - * - object {string} the standalone object in the bundle - * - DEV {boolean} is this a DEV build? - */ -module.exports = function appendVersion(path, opts) { - var txt = [ - opts.object, - '.version=', '\'', - pkg.version, opts.DEV ? '-dev' : '', - '\'', ';' - ].join(''); - - fs.appendFile(path, txt, function(err) { - if(err) throw err; - }) ; -}; diff --git a/tasks/util/make_watchified_bundle.js b/tasks/util/make_watchified_bundle.js index 7af73f3bd63..70ae5fadaa4 100644 --- a/tasks/util/make_watchified_bundle.js +++ b/tasks/util/make_watchified_bundle.js @@ -4,7 +4,6 @@ var browserify = require('browserify'); var watchify = require('watchify'); var compressAttributes = require('./compress_attributes'); -var appendVersion = require('./append_version'); var formatBundleMsg = require('./format_bundle_msg'); var constants = require('./constants'); @@ -53,9 +52,6 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) { .pipe( fs.createWriteStream(constants.pathToPlotlyBuild) ) - .on('finish', function() { - appendVersion(constants.pathToPlotlyBuild, {object: 'Plotly', DEV: true}); - }); } return bundle; From afaeeafc791ef11f9a8bbf7d0b264c5cc4d8bb27 Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 18 Nov 2015 13:48:50 -0500 Subject: [PATCH 2/4] add versionify transform to add version to plotly.js dist files: - task bundle.js uses the verisonify transform to insert to package.json version in exports.version - watch builds don't use the versionify transform because it breaks source maps https://github.com/webpro/versionify/issues/11 - the exports.version placeholder is set to 'see pacakge.json' --- package.json | 1 + src/assets/geo_assets.js | 3 +++ src/index.js | 3 +++ tasks/bundle.js | 12 +++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7a64a412fe1..82447a81d3a 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "alpha-shape": "^1.0.0", "arraytools": "^1.0.0", "browserify": "^12.0.1", + "browserify-versionify": "^1.0.6", "convex-hull": "^1.0.3", "d3": "3.5.6", "delaunay-triangulate": "^1.1.6", diff --git a/src/assets/geo_assets.js b/src/assets/geo_assets.js index a66a3942e8e..8b4682045bd 100644 --- a/src/assets/geo_assets.js +++ b/src/assets/geo_assets.js @@ -9,4 +9,7 @@ var saneTopojson = require('sane-topojson'); +// export version using browserify-versionify +exports.version = 'see package.json'; + exports.topojson = saneTopojson; diff --git a/src/index.js b/src/index.js index 0b41010c308..434cd388288 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,9 @@ var Plotly = require('./plotly'); +// export version using browserify-versionify +exports.version = 'see package.json'; + // plot api exports.plot = Plotly.plot; exports.newPlot = Plotly.newPlot; diff --git a/tasks/bundle.js b/tasks/bundle.js index 2b13767ddab..eece91f14b3 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -1,11 +1,15 @@ var fs = require('fs'); var browserify = require('browserify'); +var versionify = require('browserify-versionify'); var UglifyJS = require('uglify-js'); var compressAttributes = require('./util/compress_attributes'); var constants = require('./util/constants'); +var versionifyArg = [versionify, {placeholder: 'see package.json'}]; + + /* * This script takes one argument * @@ -38,7 +42,7 @@ catch(e) { browserify(constants.pathToPlotlySrc, { debug: DEV, standalone: 'Plotly', - transform: [compressAttributes] + transform: [compressAttributes, versionifyArg] }) .bundle(function(err, buf) { if(err) throw err; @@ -56,7 +60,8 @@ browserify(constants.pathToPlotlySrc, { // Browserify the geo assets browserify(constants.pathToPlotlyGeoAssetsSrc, { - standalone: 'PlotlyGeoAssets' + standalone: 'PlotlyGeoAssets', + transform: [versionifyArg] }) .bundle(function(err) { if(err) throw err; @@ -67,7 +72,8 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { // Browserify the plotly.js with meta browserify(constants.pathToPlotlySrc, { debug: DEV, - standalone: 'Plotly' + standalone: 'Plotly', + transform: [versionifyArg] }) .bundle(function(err) { if(err) throw err; From b0cca5268580bab6b78c63465baf11a3f54b2a60 Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 18 Nov 2015 16:54:38 -0500 Subject: [PATCH 3/4] Revert "add versionify transform to add version to plotly.js dist files:" This reverts commit afaeeafc791ef11f9a8bbf7d0b264c5cc4d8bb27. --- package.json | 1 - src/assets/geo_assets.js | 3 --- src/index.js | 3 --- tasks/bundle.js | 12 +++--------- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 82447a81d3a..7a64a412fe1 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "alpha-shape": "^1.0.0", "arraytools": "^1.0.0", "browserify": "^12.0.1", - "browserify-versionify": "^1.0.6", "convex-hull": "^1.0.3", "d3": "3.5.6", "delaunay-triangulate": "^1.1.6", diff --git a/src/assets/geo_assets.js b/src/assets/geo_assets.js index 8b4682045bd..a66a3942e8e 100644 --- a/src/assets/geo_assets.js +++ b/src/assets/geo_assets.js @@ -9,7 +9,4 @@ var saneTopojson = require('sane-topojson'); -// export version using browserify-versionify -exports.version = 'see package.json'; - exports.topojson = saneTopojson; diff --git a/src/index.js b/src/index.js index 434cd388288..0b41010c308 100644 --- a/src/index.js +++ b/src/index.js @@ -16,9 +16,6 @@ var Plotly = require('./plotly'); -// export version using browserify-versionify -exports.version = 'see package.json'; - // plot api exports.plot = Plotly.plot; exports.newPlot = Plotly.newPlot; diff --git a/tasks/bundle.js b/tasks/bundle.js index eece91f14b3..2b13767ddab 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -1,15 +1,11 @@ var fs = require('fs'); var browserify = require('browserify'); -var versionify = require('browserify-versionify'); var UglifyJS = require('uglify-js'); var compressAttributes = require('./util/compress_attributes'); var constants = require('./util/constants'); -var versionifyArg = [versionify, {placeholder: 'see package.json'}]; - - /* * This script takes one argument * @@ -42,7 +38,7 @@ catch(e) { browserify(constants.pathToPlotlySrc, { debug: DEV, standalone: 'Plotly', - transform: [compressAttributes, versionifyArg] + transform: [compressAttributes] }) .bundle(function(err, buf) { if(err) throw err; @@ -60,8 +56,7 @@ browserify(constants.pathToPlotlySrc, { // Browserify the geo assets browserify(constants.pathToPlotlyGeoAssetsSrc, { - standalone: 'PlotlyGeoAssets', - transform: [versionifyArg] + standalone: 'PlotlyGeoAssets' }) .bundle(function(err) { if(err) throw err; @@ -72,8 +67,7 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { // Browserify the plotly.js with meta browserify(constants.pathToPlotlySrc, { debug: DEV, - standalone: 'Plotly', - transform: [versionifyArg] + standalone: 'Plotly' }) .bundle(function(err) { if(err) throw err; From 970088ac59797bbe6ef1fd205d2687c003a727cb Mon Sep 17 00:00:00 2001 From: etpinard Date: Wed, 18 Nov 2015 17:02:15 -0500 Subject: [PATCH 4/4] require package.json into index.js and geo_assets.js: - to show package version onto exported object in a low-cost, seemless way. --- src/assets/geo_assets.js | 3 +++ src/index.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/assets/geo_assets.js b/src/assets/geo_assets.js index a66a3942e8e..1c74ed528c5 100644 --- a/src/assets/geo_assets.js +++ b/src/assets/geo_assets.js @@ -9,4 +9,7 @@ var saneTopojson = require('sane-topojson'); +// export the version found in the package.json +exports.version = require('../../package.json').version; + exports.topojson = saneTopojson; diff --git a/src/index.js b/src/index.js index 0b41010c308..fadf663eb17 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,9 @@ var Plotly = require('./plotly'); +// export the version found in the package.json +exports.version = require('../package.json').version; + // plot api exports.plot = Plotly.plot; exports.newPlot = Plotly.newPlot;