-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support alternatives in package.json exports #2974
Comments
The reason esbuild does it this way is because that's the way |
I have a bunch of packages in a monorepo that are disributed as typescript, with a mix of "exports": {
"./*": [
"./src/*.ts",
"./src/*.tsx",
"./src/*"
]
}, This gets the behavior to what you'd expect from importing from a file in the same package, where "exports": {
"./*": "./src/*"
}, Consumers would have to import with the full extension ( The approach I'm using works great in typescript, and as discussed works in webpack. In this context it feels weird that esbuild doesn't match typescript's behavior, since I'm entirely working with typescript files, but I understand that typescript isn't matching the spec here. Is there a spec-compliant way I can accomplish this with esbuild? My current plan is to work around this by writing a resolver plugin but I'd love to do this in a more blessed way if it exists. |
Looking forward to this one. My use case: "exports": {
"./*": [
"./src/*/index.ts",
"./src/*.ts"
]
}, This way both cases below will work: import { aModuleIndex } from "mydep/module"
import { aModuleFile } from "mydep/module/file" |
Also, if this is being considered, the package.json imports have the same issue. It would be great to have alternatives working for both of them. |
Looks like Webpack is changing their non-standard behavior to align with node: webpack/enhanced-resolve#400 and webpack/enhanced-resolve#429. I'm closing this issue because without Webpack, there isn't a strong case for diverging from the specification for this IMO. |
Most build systems support a list of options in the exports field in the package.json. Here's the documentation from webpack.
Screenshot from attached link:
My specific usecase is that I am trying to esbuild a yarn workspace. Packages in the workspace refer to other workspace packages. My production-build pipeline produces some new files that don't exist before running the build pipeline. I am unable to esbuild my workspace without generating these files. If I could use alternatives, I could support esbuilding my workspace without generating my production artifacts.
The text was updated successfully, but these errors were encountered: