Skip to content

Commit 9707781

Browse files
committed
added obesity warning
it's the responsible thing to do - at the very least, this should help avoid accidental bloat note the inline comment though
1 parent f6888ae commit 9707781

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
let Bundle = require("./bundle");
4+
let path = require("path");
45

56
module.exports = (config, assetManager, { watcher, browsers, compact } = {}) => {
67
let bundles = config.map(bundleConfig => {
@@ -21,15 +22,21 @@ module.exports = (config, assetManager, { watcher, browsers, compact } = {}) =>
2122
watcher.on("edit", filepaths => {
2223
bundles.forEach(bundle => {
2324
let res = bundle.recompile(...filepaths);
24-
res && res. // guards against irrelevant changes
25-
then(makeWriter(bundle, assetManager));
25+
res && // guards against irrelevant changes
26+
res.then(makeWriter(bundle, assetManager));
2627
});
2728
});
2829
return res; // XXX: akward? only reports the initial compilation's status
2930
};
3031

3132
function makeWriter(bundle, assetManager) {
3233
return ({ code, error }) => {
34+
if(code.length > 100000) { // ~100 kB -- XXX: arbitrary -- TODO: configurable
35+
console.error("☝️ this bundle looks to be fairly big, you might " +
36+
"want to double-check whether that's intended and " +
37+
"consider performance implications for your users:\n " +
38+
path.relative(assetManager.referenceDir, bundle.target));
39+
}
3340
assetManager.writeFile(bundle.target, code, error);
3441
};
3542
}

0 commit comments

Comments
 (0)