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

package.json duplicate browser exports #385

Closed
mkilpatrick opened this issue Aug 17, 2023 · 3 comments · Fixed by #386
Closed

package.json duplicate browser exports #385

mkilpatrick opened this issue Aug 17, 2023 · 3 comments · Fixed by #386

Comments

@mkilpatrick
Copy link

"browser" is defined at both the root and in exports which can cause issues in some bundlers. Specifically, this is an issue using Vite/Rollup in SSR mode and defining a worker condition. I'm not sure if this is specifically a Vite issue so I opened an issue with them, but either way it'd be more correct to clean up the browser field in this package. See the warning below.

https://publint.dev/[email protected]

@mkilpatrick mkilpatrick changed the title package.json duplicate exports package.json duplicate browser exports Aug 17, 2023
@Andarist
Copy link
Owner

I'm pretty sure that this is Vite bug. We need package.json#browser to support older browsers (like webpack 4 that is still widely used).

@sapphi-red
Copy link

sapphi-red commented Aug 18, 2023

What it's happening is the worker+module condition gets resolved (./dist/react-textarea-autosize.esm.js) and then the browser field maps that to ./dist/react-textarea-autosize.browser.esm.js.

There's a long thread in solid: solidjs/solid-start#263
In summary, this behavior has been there for a while and webpack and rollup (plugin-node-resolve) does the same thing (https://github.com/patdx/package-exports-test). Changing this will misalign with other bundlers and might break some packages.

I think browser field should be ignored when exports field exists but I'm not sure how we can solve this problem in a nice way.

@Andarist
Copy link
Owner

I think browser field should be ignored when exports field exists but I'm not sure how we can solve this problem in a nice way.

This isn't how it should work (I was surprised about it when I discovered it). See the thread here: https://twitter.com/AndaristRake/status/1622675620026101760 . So you are right - this would break things and we don't want that.

After a second thought - I actually might have broken it in: https://github.com/Andarist/react-textarea-autosize/pull/373/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R22 . Previously we had a specific file for the worker condition - it was just a copy of the one targeting node so the content was the same but the filename was different. This got deduplicated in this commit but that broke this.

Sorry for the confusion and thank you for the investigation! I'll see what I can do about this.

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 a pull request may close this issue.

3 participants