A browserify helper to save the export value of a module for easier debugging.
It doesn't require changing your build - it works at runtime by simply requiring bpack-debug and running it. It scans the raw source of modules in the module cache for the alias name to export as a docblock directive.
// in main.js
require('bpack-debug')(window);
/**
* This is my my-module.js
* @debugKey app.myModule
*/
module.exports = function(name) {
console.log('hello ' + name);
}
// in the console
app.myModule('andres');
// hello andres
targetObj
is the object to which you want to save the exported modules.debugKey
(optional) the docblock directive for the alias of the module. It can contain periods to denote a deep object.
bpack-debug lazily loads modules so it doesn't disturb the natural order of your dependency loading. However, if you need to access a module that hasn't been loaded yet, it can be forcefully loaded with this function.
- bpack-debug is meant for development use only. The comment directives must exist for it to work. So if you minify the bundle, and remove the comments, it naturally won't work.
- bpack-debug doesn't work across split bundles. Each bundle must load bpack-debug on its own.