-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat: sort types
and default
in exports
field
#349
base: main
Are you sure you want to change the base?
Conversation
exports
fieldtypes
, default
, and module-sync
in exports
field
@fisker let me know where you would like to have the conversation about the other conditions. I will call out 1 issue with this implementation: If you have {
"require": "./require.js",
"import": "./module.mjs",
"module-sync": "./sync-module.mjs"
} This will be sorted as {
"module-sync": "./sync-module.mjs",
"require": "./require.js",
"import": "./module.mjs"
} This is wrong because This means that if a package developer intentionally wants to use a module with top-level await in the |
Raise an issue. |
Will merging this cause new issues? Or is this a useful stepping stone? Is the status quo broken currently? |
types
, default
, and module-sync
in exports
fieldtypes
and default
in exports
field
I think either moving Let's leave |
@GeorgeTaveras1231 Are you fine with this change now? |
@fisker Yea this is okay I've been looking more into the So having the following is valid /// tsconfig.json
{
"compilerOptions": {
// Configure node resolution
"module": "NodeNext",
"moduleResolution": "NodeNext",
}
} /// package.json["exports"]
{
"node": "./node-only.js",
"types": "./fallback-types.d.ts"
} Where you may have a file Separately, // package.json["exports"]
{
"types@>=5.2": "./ts5.2/subpath/index.d.ts",
"types@>=4.6": "./ts4.6/subpath/index.d.ts",
"types": "./tsold/subpath/index.d.ts",
"default": "./dist/subpath/index.js"
} Using the code in this PR will break this example ☝🏽 I don't want to prevent your sense of progress so it's up to you how you want to frame this. I will open an issue proposing a solution for the other known conditions and will give some thought to the issues with the |
|
There is nothing to doubt, they made it very clear since the begining, if it doesn't work. Should be their problem. |
@fisker good finds. It's certainly odd the way it works and how that relates to the recommendation to place it first. It takes more effort to properly add type variants this way. Instead of {
"node": "./node-only.js",
"types": "./fallback.d.ts"
} will require writing {
"types": {
"node": "./node-only.d.ts",
"default": "./fallback.d.ts"
},
"node": "./node-only.js"
} But oh well 🤷🏽 |
@GeorgeTaveras1231 are you supportive of this change (regardless of the conversation in #336)? It looks good to me but I want to make sure this meets a minimum criteria for you, and won't introduce any regressive behaviour. If you think this good I'll merge then take a look at #350. |
# Conflicts: # index.js
@keithamus I would only change this to fall back gracefully if users are using the This could be handled easily with small impact to scope in two ways
This is the only thing I see possibly introducing regression issues for users. Otherwise, this is ok. 👌 |
Versioned type conditions support added. b73d970 |
Fixes #294
Fixes #239
In this PR:
types
above subpathes if exists)Move 'module-sync' to above 'require'I don't mean to close #336, but I think we should discuss about other condition orders first before we take further actions. This PR just picking the low-hanging fruits first.