Open trusktr opened 4 years ago
OT
@trusktr are you using named imports in production with node 13 today? I'm asking because most of libs do not provide exports
(i.e: lodash-es
) thus named import do not work with them, and this is preventing me from upgrading to v13+esm. Did you manage to work it around?
I am using
"exports"
in new project's package.json that I run in Node.js v13.2+ and it works great.(Note, specifically Node v13.2+ because 13.2 introduced a feature where mapping a folder in
exports
causes it to behave exactly like the desired functionality ofmainDir
that is expressed in https://github.com/nodejs/node/issues/14970).In particular the feature that I'm wondering about is, if a path is mapped to another path using
exports
, then the consumer of the package can import anything from that mapped folder and subfolders. Prior to Node 13.2 mapping a folder would cause any of its sub-folders to be unavailable for import.For example, my exports field is like this normally:
And this means a user can:
Does
esm
support this same functionality? I'm looking for something to fallback to until Electron is released with Node 14. They are on Node 12 right now, and only ship with LTS Node.