-
Notifications
You must be signed in to change notification settings - Fork 24
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: demote browser export #11
Conversation
🦋 Changeset detectedLatest commit: 9105002 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
241f269
to
e84a1ad
Compare
Exports are resolved in order, i.e. the first match is used. I'm not sure why the browser export is using the raw src, however this causes issues with Jest when configured with jsdom, as it will resolve to this file and not be able to transpile it. Jest also throws a type error as discussed on remix-run/remix#3402
e84a1ad
to
2f9ecb9
Compare
CC/ @chaance @jacob-ebey @mjackson |
I've been digging for over two hours and this is clearly the fix. Is there any progress on this PR? 😇 EDIT: Solving it with patch-package for now. |
nudge |
Is there a source/reference for this? |
|
I don't believe this is "the fix" everyone is after here. Generally, any non-standard conditions like "browser" are put above the "require", "import", and "default" conditions. Reasoning being some bundlers (like esbuild) don't allow you to disable the default conditions, and instead configure conditions to check before the defaults. This honestly sounds like a Jest issue of loading the wrong conditions for where they are executing. You aren't actually running Jest in the browser, so they should not be attempting to load the browser condition. Moving browser below the standard conditions will mean that the "browser" condition will never be picked, even when building for / targeting the browser. |
Thanks @penx! I missed that when I looked through those docs. I agree with @jacob-ebey here - that snippet sounds to me like It does feel like Jest either (1) should not pick up the I think we should split off the moving |
Extracted the lifting of |
Instead of demoting the |
Prefer require, import and types exports over browser.
Exports are resolved in order, i.e. the first match is used.
I'm not sure why the browser export is using the raw src, however when Jest is configured with
testEnvironment: "jsdom"
, it will resolve to this file causing 2 issues:@remix-run/web-fetch
causes tests to error after upgrade to jest 28 remix#3402Also: