rollup should respect the preset while reading package.json exports #1371
Labels
bug
Something isn't working
enhancement
New feature or request
preset:cloudflare
preset:deno
preset:lagon
preset:vercel-edge
workaround available
Motivation
When building for worker runtimes such as cloudflare/vercel-edge, there's an issue where the rollup plugin node resolve will follow the default priority which is good for Node, but not for these environments, which means in these scenarios many dependencies needs to be alias manually to their browser version.
Describe the feature
Depending on the preset, we should alter rollup node-resolve
exportConditions
order priority.For example for Cloudflare like environments, we could try
workerd > browser > import > default > module > deno > node
.For deno we could try
deno > browser > import > default > workerd > module > node
It looks like there's a lot of edge cases and no convention defined, ie vercel uses
edge-light
, libsql useweb
andhttp
...We could run into an issue where we don't have the correct export no matter how much we try, hence why we should give the ability to customise this through Nitro options, as well as document it.
https://github.com/rollup/plugins/blob/master/packages/node-resolve/README.md
https://github.com/unjs/nitro/blob/main/src/rollup/config.ts
Edit : There's some convention defined there https://runtime-keys.proposal.wintercg.org/ , but no guarantee that libraries authors respect it.
Additional information
The text was updated successfully, but these errors were encountered: