1
For a while I’ve seen in codes, including large Javascript libraries, more or less like this:
if (module.exports) {
// faça algo
}
//#####
define({/* parametros */})
//#####
import algumacoisa from biblioteca
//#####
var foo = require('biblioteca')
// aqui, foo já é um objeto com metodos da biblioteca
foo.bar();
Anyway... I realized that all this is related to modularization. In Nodejs I know that this is used (I do not program in Node). What I don’t understand is this being used in front-end/client-side.
Would this be promoted by some kind of transpiler? Or is it native? Because I tested many of these attributes in updated browsers and everything returned false
or undefined
. I even thought it was related to Ecmascript 6, but as I said, browsers don’t seem to support it natively.
Thank you.
These great libraries you mentioned are from Nodejs? Or some other framework?
– Woss