New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is commonjs2 ? #1114

Closed
Sinewyk opened this Issue May 25, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@Sinewyk

Sinewyk commented May 25, 2015

Sorry if that's obvious but it's been eating me for multiple days and even greping commonjs2 through this repository I couldn't find any obvious information.
My google-fu on commonjs2 led me back to #864 ... which was not helpful.

Anyone could explicitely inform me what is commonjs2, the differences with commonjs, and what is the relation with webpack ?

Thanks ...

@sokra

This comment has been minimized.

Show comment
Hide comment
@sokra

sokra May 26, 2015

Member

CommonJs spec defines only exports. But module.exports is used by node.js and many other CommonJs implementations.

commonjs mean pure CommonJs
commonjs2 also includes the module.exports stuff.

Member

sokra commented May 26, 2015

CommonJs spec defines only exports. But module.exports is used by node.js and many other CommonJs implementations.

commonjs mean pure CommonJs
commonjs2 also includes the module.exports stuff.

@Sinewyk

This comment has been minimized.

Show comment
Hide comment
@Sinewyk

Sinewyk May 26, 2015

So ... the replacement of module.exports

module.exports = function(){};

instead of simply adding stuff to the exports object

exports.a = 'a';
exports.b = 'b;'

is not in the "initial" commonjs spec ? nodejs started it and everybody followed ?

Sinewyk commented May 26, 2015

So ... the replacement of module.exports

module.exports = function(){};

instead of simply adding stuff to the exports object

exports.a = 'a';
exports.b = 'b;'

is not in the "initial" commonjs spec ? nodejs started it and everybody followed ?

@bebraw bebraw added the question label Nov 14, 2015

@bebraw

This comment has been minimized.

Show comment
Hide comment
@bebraw

bebraw Nov 14, 2015

Member

@Sinewyk Yeah, pretty much. See https://nodejs.org/docs/latest/api/modules.html for reference.

Member

bebraw commented Nov 14, 2015

@Sinewyk Yeah, pretty much. See https://nodejs.org/docs/latest/api/modules.html for reference.

@vamsiampolu

This comment has been minimized.

Show comment
Hide comment
@vamsiampolu

vamsiampolu Jul 31, 2017

Are there other commonjs implementations that do not use module.exports which need to be supported by webpack? Now that I understand what the two options commonjs and commonjs2 are, I would like to understand if there is a practical use case for commonjs.

vamsiampolu commented Jul 31, 2017

Are there other commonjs implementations that do not use module.exports which need to be supported by webpack? Now that I understand what the two options commonjs and commonjs2 are, I would like to understand if there is a practical use case for commonjs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment