feature request: support conditional exports (package.json `exports` field)
See original GitHub issueLove the style
support, but would really helpful for conditional exports to also be legible to postcss-import
:
{
...,
"exports": {
".": "./dist/index.js",
"./*": "./dist/lib/*/index.js",
"./styles": "./dist/styles/index.css",
"./styles/*": "./dist/styles/*/index.css",
"./package.json": "./package.json"
},
...,
}
The main reason I suggest this is because I cannot specify an @import "my-package/styles"
statement in a way that is supported by both esbuild (supports standardized package.json exports
, but not nonstandard style
) and postcss-import
(where situation is reversed). my-package/styles
is the only thing that works for esbuild, but my-package
is the only thing that works for postcss-import
.
I would recommend following the Node doctrine of “if exports
exists, it overrides anything else” (i.e. style
field). Also thank you for maintaining this project, it is a core part of modern development workflows IMO, only reason I suggest the enhancement.
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:5
Top GitHub Comments
The module we use for resolution doesn’t support
exports
yet; so that’s a technical blocker: https://github.com/browserify/resolve/issues/222.Presumably, we’d want to support some kind of style-specific conditional export as well, so you could export both JS and CSS at
.
, similiar to how using bothmain
&style
works today. Does esbuild have anything like this?Relevant: https://nodejs.org/api/packages.html#community-conditions-definitions