-
Notifications
You must be signed in to change notification settings - Fork 128
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
fix: default interop compat for "module" condition #179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn’t we do export default tslib
in modules/index.js
as well then?
Yes, exactly. |
This package ships an |
The problem I had here is JSPM supports the "module" condition because it can support CJS loading ESM, but it uses Node.js-style interop for the "module" condition which then breaks down. In general JSPM will be moving away from the "module" condition now for this reason... |
My understanding of the |
@Andarist this is because bundlers in implementing the |
All this to say, the default + NS pattern is a kind of approach that can work for best interop. Node.js does it with its core modules too. |
yeah, i know how this one goes but that's only when the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have feelings about this that mostly involve lamenting how the ecosystem has gotten to the point where redundant API shapes like this seem required. I don't think more packages bending over backwards to help out tools that are mis-processing files or confused users will ultimately help the ecosystem - after all, the more packages that do this, the more people expect it, the more it's an issue - it just helps us triage less confusion. :(
This adds default import interop compat when resolving using the
"module"
condition.Many users are still expecting
import tslib from 'tslib'
to work, since this is supported for the CommonJS interface in both Node.js and browsers, but if building with the"module"
condition outside of Webpack (eg as import map generators like JSPM do), this results in breaking the tslib interop.It is always recommended for all exports conditions to provide the same interface. This decoration effectively provides the identical interfaces between the ESM and CJS forms of tslib, maximizing interop.
//cc @weswigham