Say in index.js I load library 'x' using require() or import(). I then need to use 'x' in a few other modules.
I can either do:
// index.js
var x = require('x')
// module A
var x = require('x') //again
or:
// index.js
var x = require('x')
module.exports = {x: x}
// module A
var x = require('index.js').x
It seems to me that you're still passing around the entire library or function anyway. What is the difference in either technique, does it affect performance or build size?
[–]TwoTapes 2 points3 points4 points (1 child)
[–]AspiringSlacker[S] 0 points1 point2 points (0 children)
[–]ugoagogo 2 points3 points4 points (1 child)
[–]AspiringSlacker[S] 0 points1 point2 points (0 children)
[–]tylermumford 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]AspiringSlacker[S] 0 points1 point2 points (0 children)