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

fix: leverage pkg.exports #22

Conversation

ctavan
Copy link
Contributor

@ctavan ctavan commented Jun 24, 2020

First of all: the pkg.exports spec defines that object key order is
being used when resolving for the targeted environment, see
uuidjs/uuid#462 (comment)

In order for webpack@5 to pick up the browser overrides they must
come before import and require, see
https://gist.github.com/sokra/e032a0f17c1721c71cfced6f14516c62 for
preliminary documentation.

To make full use of pkg.exports in node as well we can use package
self reference instead of local paths, see the discussion in
jkrems/proposal-pkg-exports#47

Unfortunately the browser testing tool polendina doesn't play nice with
self reference since it only looks for bare module specifiers in
node_modules and node_modules/polendina/node_modules, see
https://github.com/rvagg/polendina/blob/master/lib/webpack.config.js#L28-L39

We would need a way to set up an resolve.alias for webpack in
polendina to make package self reference work.

Edit: Polendina issue fixed through rvagg/polendina#8 (comment)

First of all: the `pkg.exports` spec defines that object key order is
being used when resolving for the targeted environment, see
uuidjs/uuid#462 (comment)

In order for `webpack@5` to pick up the `browser` overrides they must
come _before_ `import` and `require`, see
https://gist.github.com/sokra/e032a0f17c1721c71cfced6f14516c62 for
preliminary documentation.

To make full use of `pkg.exports` in node as well we can use package
self reference instead of local paths, see the discussion in
jkrems/proposal-pkg-exports#47

Unfortunately the browser testing tool polendina doesn't play nice with
self reference since it only looks for bare module specifiers in
`node_modules` and `node_modules/polendina/node_modules`, see
https://github.com/rvagg/polendina/blob/master/lib/webpack.config.js#L28-L39

We would need a way to set up an `resolve.alias` for webpack in
polendina to make package self reference work.
@ctavan ctavan force-pushed the use-self-reference-to-leverage-package-exports branch from 595cd46 to ecc4541 Compare June 24, 2020 11:49
@mikeal
Copy link
Contributor

mikeal commented Jul 16, 2020

I'm so sorry, this somehow slipped under my notifications and I never saw it. This looks great, I'll clean up the merge conflicts and get it in today.

@mikeal mikeal merged commit 0783607 into multiformats:master Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants