According to Node.js documentation only on older versions of Node.js should main be required.
For new packages targeting the currently supported versions of Node.js, the "exports" field is recommended. For packages supporting Node.js 10 and below, the "main" field is required. If both "exports" and "main" are defined, the "exports" field takes precedence over "main" in supported versions of Node.js.
~Regardless, Parcel doesn't seem to honor the sole existence of exports (without main). This change will support both by allowing exports to take precedence per the above.~
UPDATE: Seems like the issue could be due to conditional exports not supported in Parcel. I think this is good justification to add the main entry as a fallback for when conditional exports is not supported (like in the case of Parcel).
Issue:
Closes https://github.com/emilkowalski/sonner/issues/456
What has been done:
According to Node.js documentation only on older versions of Node.js should
main
be required.~Regardless, Parcel doesn't seem to honor the sole existence of
exports
(withoutmain
). This change will support both by allowingexports
to take precedence per the above.~UPDATE: Seems like the issue could be due to conditional exports not supported in Parcel. I think this is good justification to add the
main
entry as a fallback for when conditional exports is not supported (like in the case of Parcel).