Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 142 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"browserify-transform-tools": "^1.7.0",
"check-node-version": "^3.2.0",
"deep-equal": "^1.0.1",
"derequire": "^2.0.6",
"ecstatic": "^3.2.0",
"eslint": "^4.19.1",
"falafel": "^2.0.0",
Expand Down
15 changes: 15 additions & 0 deletions tasks/util/browserify_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var path = require('path');

var browserify = require('browserify');
var minify = require('minify-stream');
var derequire = require('derequire');
var through = require('through2');

var constants = require('./constants');
var compressAttributes = require('./compress_attributes');
Expand Down Expand Up @@ -60,6 +62,7 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {

if(pathToMinBundle) {
bundleStream
.pipe(applyDerequire())
.pipe(minify(constants.uglifyOptions))
.pipe(fs.createWriteStream(pathToMinBundle))
.on('finish', function() {
Expand All @@ -69,6 +72,7 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts, cb) {
}

bundleStream
.pipe(applyDerequire())
.pipe(fs.createWriteStream(pathToBundle))
.on('finish', function() {
logger(pathToBundle);
Expand All @@ -80,3 +84,14 @@ function logger(pathToOutput) {
var log = 'ok ' + path.basename(pathToOutput);
console.log(log);
}

function applyDerequire() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice, you turned the plugin into a transforms for speed. Love it!

var buf = '';
return through(function(chunk, enc, next) {
buf += chunk.toString();
next();
}, function(done) {
this.push(derequire(buf));
done();
});
}