Last active
October 22, 2015 21:59
-
-
Save kirbysayshi/8d848e50f89d09555460 to your computer and use it in GitHub Desktop.
browserify for node example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function () { | |
return 'another'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var browserify = require('browserify'); | |
var b = browserify({ | |
builtins: false, | |
commondir: false, | |
browserField: false, | |
insertGlobalVars: ['__filename', '__dirname'] | |
}); | |
b.add('./index.js'); | |
b.bundle(function (err, data) { | |
process.stdout.write(data.toString()); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 () { | |
return 'another'; | |
} | |
},{}],2:[function(require,module,exports){ | |
(function (__filename,__dirname){ | |
var events = require('events'); | |
var vm = require('vm'); | |
var another = require('./another'); | |
console.log(another()); | |
console.log('__filename', __filename); | |
console.log('__dirname', __dirname); | |
}).call(this,"/private/tmp/browserify-for-node/index.js","/private/tmp/browserify-for-node") | |
},{"./another":1,"events":undefined,"vm":undefined}]},{},[2]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var events = require('events'); | |
var vm = require('vm'); | |
var another = require('./another'); | |
console.log(another()); | |
console.log('__filename', __filename); | |
console.log('__dirname', __dirname); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "browserify-for-node", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"build": "node builder.js > bundle.js" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"browserify": "^11.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment