Skip to content

v2.0.0

Compare
Choose a tag to compare
@goto-bus-stop goto-bus-stop released this 22 Jun 11:12
· 11 commits to master since this release
7e13064

Update to static-module 3. This adds scope tracking, and keeps fs requires around if they are still used.

Scope tracking

Previously the below:

var fs = require('fs')
function x (fs) { return fs.readFileSync(__filename) }
x({ readFileSync: function () { return 10 } })

would compile the fs.readFileSync() call, even though it's not actually referring to the fs module. This may seem contrived but it can happen easily if a file was minified before being passed to brfs, and a million different variables are all named e.

Retain used requires

Previously the below:

var fs = require('fs')
fs.readFileSync(someDynamicValue())
fs.readFileSync(__filename)

would compile to:

fs.readFileSync(someDynamicValue())
Buffer('...', 'base64')

But now it compiles to:

var fs = require('fs')
fs.readFileSync(someDynamicValue())
Buffer('...', 'base64')

This is primarily helpful when bundling for node or electron.