Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 328af5f

Browse files
committed
Upgrade bundling to uglify-es
Conflicts: package.json
1 parent accae1a commit 328af5f

File tree

5 files changed

+42
-47
lines changed

5 files changed

+42
-47
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
"3d-view": "^2.0.0",
5757
"@plotly/d3-sankey": "^0.5.0",
5858
"alpha-shape": "^1.0.0",
59+
"bubleify": "^1.0.0",
60+
"canvas-fit": "^1.5.0",
5961
"color-rgba": "^1.1.1",
6062
"convex-hull": "^1.0.3",
6163
"country-regex": "^1.1.0",
@@ -86,6 +88,7 @@
8688
"has-hover": "^1.0.1",
8789
"mapbox-gl": "^0.22.0",
8890
"matrix-camera-controller": "^2.1.3",
91+
"minify-stream": "^1.1.0",
8992
"mouse-change": "^1.4.0",
9093
"mouse-event-offset": "^3.0.2",
9194
"mouse-wheel": "^1.0.2",
@@ -140,7 +143,6 @@
140143
"read-last-lines": "^1.1.0",
141144
"requirejs": "^2.3.1",
142145
"through2": "^2.0.3",
143-
"uglify-js": "^2.8.12",
144146
"watchify": "^3.9.0",
145147
"xml2js": "^0.4.16"
146148
}

tasks/bundle.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, {
3333
pathToMinBundle: constants.pathToPlotlyDistMin
3434
});
3535

36+
3637
// Browserify the geo assets
3738
_bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, {
3839
standalone: 'PlotlyGeoAssets'
@@ -53,3 +54,4 @@ constants.partialBundlePaths.forEach(function(pathObj) {
5354
pathToMinBundle: pathObj.distMin
5455
});
5556
});
57+

tasks/util/browserify_wrapper.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var fs = require('fs');
22
var path = require('path');
33

44
var browserify = require('browserify');
5-
var UglifyJS = require('uglify-js');
5+
var bubleify = require('bubleify');
6+
var minify = require('minify-stream');
67

78
var constants = require('./constants');
89
var compressAttributes = require('./compress_attributes');
9-
var patchMinified = require('./patch_minified');
1010
var strictD3 = require('./strict_d3');
1111

1212
/** Convenience browserify wrapper
@@ -46,30 +46,30 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts) {
4646
}
4747

4848
var b = browserify(pathToIndex, browserifyOpts);
49-
var bundleWriteStream = fs.createWriteStream(pathToBundle);
5049

51-
bundleWriteStream.on('finish', function() {
52-
logger(pathToBundle);
53-
if(opts.then) {
54-
opts.then();
55-
}
56-
});
50+
b.transform(bubleify, constants.bubleifyOptions);
5751

58-
b.bundle(function(err, buf) {
52+
var bundleStream = b.bundle(function(err, buf) {
5953
if(err) throw err;
54+
})
6055

61-
if(outputMinified) {
62-
var minifiedCode = UglifyJS.minify(buf.toString(), constants.uglifyOptions).code;
63-
minifiedCode = patchMinified(minifiedCode);
64-
65-
fs.writeFile(pathToMinBundle, minifiedCode, function(err) {
66-
if(err) throw err;
67-
56+
if (outputMinified) {
57+
bundleStream
58+
.pipe(minify(constants.uglifyOptions))
59+
.pipe(fs.createWriteStream(pathToMinBundle))
60+
.on('finish', function() {
6861
logger(pathToMinBundle);
6962
});
70-
}
71-
})
72-
.pipe(bundleWriteStream);
63+
}
64+
65+
bundleStream
66+
.pipe(fs.createWriteStream(pathToBundle))
67+
.on('finish', function() {
68+
logger(pathToBundle);
69+
if(opts.then) {
70+
opts.then();
71+
}
72+
});
7373
};
7474

7575
function logger(pathToOutput) {

tasks/util/constants.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,29 @@ module.exports = {
8484
testContainerHome: '/var/www/streambed/image_server/plotly.js',
8585

8686
uglifyOptions: {
87-
fromString: true,
8887
mangle: true,
8988
compress: {
90-
warnings: false,
91-
screw_ie8: true
89+
warnings: false
9290
},
9391
output: {
9492
beautify: false,
9593
ascii_only: true
96-
}
94+
},
95+
sourceMap: false
96+
},
97+
98+
bubleifyOptions: {
99+
target: {
100+
chrome: 48,
101+
firefox: 44,
102+
edge: 12
103+
},
104+
transforms: {
105+
arrow: true,
106+
defaultParameter: false,
107+
dangerousForOf: true,
108+
},
109+
sourceMap: false
97110
},
98111

99112
licenseDist: [

tasks/util/patch_minified.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)