From time to time I hear that CommonJS http://www.commonjs.org/ is an effort to create a set of modular javascript components but frankly I have never understood anything of it.
Where are the these modular components I can use? I don’t see much on their homepage.
CommonJS is only a standard that specifies a way to modularize JavaScript, so CommonJS itself does not provide any JavaScript libraries.
CommonJS specifies a
require()function which lets one import the modules and then use them, the modules have a special global variable namedexportswhich is an object which holds the things that will get exported.The Node.js standard library and all 3rd party libraries use CommonJS to modularize their code.
One more example: