-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Platform is not respected in module resolution #3867
Comments
You are confusing two separate things. In this context, The {
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/node/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/node/index.cjs"
},
"node": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/node/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/node/index.cjs"
}
},
"browser": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/browser/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/browser/index.cjs"
}
},
"worker": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/browser/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/browser/index.cjs"
}
}
}
},
...
} There is only one exported subpath (called I'm closing this issue because esbuild seems to be working correctly here. The problem here is that the package definition is broken. It looks like the change that broke it is here: perry-mitchell/ulidx#41. I recommend working with the package author to fix their package. I'm not familiar with how the |
I recently just learnt how TypeScript resolves types, so I will put some additional info here. First of all, in summary of what Evan said, the order of fields in For TypeScript, the
|
Thanks for info! I see that someone already reported it in ulidx repository. |
Problem:
I specify the platform to browser, but
esbuild
doesn't respect that and uses.
for module lookup inexports
.Looking for "." in "exports" map in "C:\projects\own\new-proj\consumer\node_modules\ulidx\package.json"
This results in node module being used instead of browser one and later it will fail with error
How to reproduce:
Just create this simple index.ts file:
and run:
Expected behavior:
esbuild should read
exports:browser
instead ofexports:.
The text was updated successfully, but these errors were encountered: