For some time, I've seen in code, including large JavaScript libraries, sections 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 of this is related to modularization. In NodeJS I know this is used (I do not program in Node). What I did not understand is this being used on front-end / client-side.
Would that 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 like I said, browsers do not seem to take it natively.
Thank you.