Commit acf67c31 authored by Robert Knight's avatar Robert Knight

Restrict the Node module polyfills included by Browserify

By default the app bundle included the large polyfills
for Node's buffer and crypto modules due to them being
required by node-uuid.

Fix this by making Buffer undefined in the browser
and explicitly whitelisting the set of modules
that Browserify should polyfill.
parent d47a9b46
......@@ -59,6 +59,27 @@ module.exports = function createBundle(opts) {
var bundleOpts = {
debug: true,
extensions: ['.coffee'],
// Browserify will retry to detect and automatically provide
// browser implementations of Node modules.
//
// This can bloat the bundle hugely if implementations for large
// modules like 'Buffer' or 'crypto' are inadvertently pulled in.
// Here we explicitly whitelist the builtins that can be used.
//
// In particular 'Buffer' is excluded from the list of automatically
// detected variables.
//
// See node_modules/browserify/lib/builtins.js to find out which
// modules provide the implementations of these.
builtins: [
'console',
'_process',
'querystring',
],
insertGlobalVars: {
Buffer: undefined,
},
};
if (opts.watch) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment