Tuesday 27 November 2018

Should I use ES modules or CommonJS for my libraries and applications?

I'm a bit confused about the current (and future) state of ES modules in node...Is node considering ever dropping CommonJS in favor of ES modules?Is there a recommended and future-proof approach, or is this topic a holy war?I'm currently developing a small library, primarily for node, but I might want to port it to browsers at some point.Am I recommended to use ES modules or require?If I went for ES modules, I'd have to transpile my library using babel, right? I can't expect people to use --experimental-modules just for my lib... It wouldn't be a big deal, anyways, since I'm using @babel/plugin-transform-modules-commonjs already.What bugs me more than transpiling is require(...).default as it looks ugly and pointless - are there many packages out there doing it?And what should I use when I'm developing a program, rather than a lib?

Submitted November 28, 2018 at 01:07AM by oroep

No comments:

Post a Comment