Skip to content

Instantly share code, notes, and snippets.

@kuu
Created November 10, 2014 12:01
Show Gist options
  • Save kuu/90f49da86f70b4776f66 to your computer and use it in GitHub Desktop.
Save kuu/90f49da86f70b4776f66 to your computer and use it in GitHub Desktop.
Output of Browserify
// --------------------
// [main.js]
// var MyModule = require('./MyModule');
// var obj = new MyModule();
// --------------------
// [MyModule.js]
// var Foo = require('./Foo');
// var Bar = require('./Bar');
// module.exports = function () {
// this.foo = new Foo();
// this.bar = new Bar();
// };
// --------------------
// [Foo.js]
// module.exports = function () {
// console.log('Foo is created.');
// };
// --------------------
// [Bar.js]
// module.exports = function () {
// console.log('Bar is created.');
// };
// --------------------
//
// Below are the result of:
// $ browserify main.js -o out.js
//
// [out.js]
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports = function () {
console.log('Bar is created.');
};
},{}],2:[function(require,module,exports){
module.exports = function () {
console.log('Foo is created.');
};
},{}],3:[function(require,module,exports){
var Foo = require('./Foo');
var Bar = require('./Bar');
module.exports = function () {
this.foo = new Foo();
this.bar = new Bar();
};
},{"./Bar":1,"./Foo":2}],4:[function(require,module,exports){
var MyModule = require('./MyModule');
var obj = new MyModule();
},{"./MyModule":3}]},{},[4]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment