Skip to content
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

rollup should respect the preset while reading package.json exports #1371

Closed
1 task done
Hebilicious opened this issue Jul 2, 2023 · 2 comments · Fixed by #1401
Closed
1 task done

rollup should respect the preset while reading package.json exports #1371

Hebilicious opened this issue Jul 2, 2023 · 2 comments · Fixed by #1401

Comments

@Hebilicious
Copy link
Contributor

Hebilicious commented Jul 2, 2023

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 use web and http ...
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

  • Would you be willing to help implement this feature?
@Hebilicious Hebilicious changed the title [feature request] @rollup/plugin-node-resolve should respect NITRO_PRESET [feature request] @rollup/plugin-node-resolve should respect preset Jul 2, 2023
@Hebilicious Hebilicious added enhancement New feature or request and removed pending triage labels Jul 3, 2023
@Hebilicious Hebilicious changed the title [feature request] @rollup/plugin-node-resolve should respect preset [feature request] @rollup/plugin-node-resolve should respect preset while reading exports Jul 3, 2023
@Hebilicious Hebilicious changed the title [feature request] @rollup/plugin-node-resolve should respect preset while reading exports [feature request] rollup should respect preset while reading package.json exports Jul 3, 2023
@Hebilicious Hebilicious changed the title [feature request] rollup should respect preset while reading package.json exports rollup should respect preset while reading package.json exports Jul 3, 2023
@Hebilicious Hebilicious changed the title rollup should respect preset while reading package.json exports rollup should respect the preset while reading package.json exports Jul 3, 2023
@pi0
Copy link
Member

pi0 commented Jul 5, 2023

Related:

@Hebilicious
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants