Closed benmccann closed 2 years ago
webpack
and other bundlers use it - it's for scenarios where the bundler ensures esm and cjs are drop-in replacements for one another, so only loads one copy of a module (the module
version), unlike node
, which loads two (the require
and import
version), and we need to take steps to ensure only one copy of the code is loaded (but still presents the right named exports).
It's entirely "standard" in that regard.
FYI, the node docs page for conditions here may not list module
, but it 100% meets the bar for inclusion (it's well supported by a tool in the ecosystem already and a bunch of packages use it, not just tslib
) - nobody's added it yet though because it's just an as-requested thing.
Ok, thanks for the explanation
tslib has a
module
entry in theexports
, which is non-standard. It's unclear to me why this has been added or would be needed. I couldn't find any code comments explaining it various entry points. At the very least, it would be nice to add comments explaining this setup. However, I have a very strong feeling it's setup improperly and should be fixed. Looking through the issue tracker, it seems there's quite a lot of packaging issues in this library.Vite has added support for
module
to its codebase, but it's a rather messy thing I'd rather not keep around long-term.