-
-
Save jc00ke/1085352bd8673c579ffa to your computer and use it in GitHub Desktop.
Requires in js
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
// a.js | |
var add = function(a, b) { | |
return a + b; | |
}; | |
module.exports = add; |
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
require('./a'); | |
require('./b'); | |
// Want it to generate something like this: | |
"use strict"; | |
// b.js | |
// a.js | |
var add = function(a, b) { | |
return a + b; | |
}; | |
console.log(add(2, 3)); | |
// But it generates: | |
"use strict"; | |
// b.js | |
require("./foo"); | |
console.log(add(2, 3)); | |
// a.js | |
var add = function (a, b) { | |
return a + b; | |
}; | |
module.exports = add; |
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
// b.js | |
require('./a'); | |
console.log(add(2, 3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was wanting to do this for front-end only, via gulp, and happened upon https://www.npmjs.com/package/gulp-resolve-dependencies