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!: Remove browser field from package.json #2255

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

wkelly17
Copy link
Contributor

Remove browser field from package.json of core packages so that worker export doesn't get mapped back the browser field by Vite, Rollup, Webpack etc;

BREAKING CHANGE: Jest was previously mentioned as the reason that wasn't removed, but Jest now supports package.json modules. That said, some other tooling might still not support esm exports.

Summary

A couple of years ago, it was noted that rollup, vite, and webpack map the worker export condition back to the browser field, which broke solid in certain edge runtimes (cloudflare) due to the need to load the server build of solid instead of the browser field. (notably, esbuild does not follow that behavior) Issues were opened with the respective bundlers, but vite closed as expected, and rollup didn't respond at the time. The fix as noted was to remove the browser field from pacakge.json, but it was noted that would break Jest and other non esm envs, which didn't support exports, but now they (Jest) do. (And esm adoption has continue to increase)
Full discussion of the issue here:
solidjs/solid-start#263

Recently, the cloudflare adapter for astro removed their esbuild step, which resulted in breaking the adapter for users of solid bringing this back to attention. Context here:
withastro/adapters#224

Jest however, now supports package.json exports:
https://jestjs.io/blog/2022/04/25/jest-28#packagejson-exports,
and allows configuring how the exports of a package.json are resolved:
https://jestjs.io/blog/2022/04/25/jest-28#packagejson-exports

How did you test this change?

Here is an example repo showing Jest working with solid, while I've remove the browser field in a patch:
https://github.com/wkelly17/Solid-Jest-repro

Besides Jest now working, this would fix workarounds for users of cloudflare + astro + solid, and I think for anyone trying to bundle for Cloudflare using anything other than esbuild (and maybe some other edge runtimes? uncertain).

The main question I'm not sure about is, are there any other common community packages besides Jest that would preclude from making this merge now that some upstream issues have solved?

… worker export doesn't get mapped back to removeBrowserPackageJson

BREAKING CHANGE: Jest was previously mentioned as the reason that wasn't removed, but Jest now supports package.json modules. That said, some other tooling might still not support esm exports.
Copy link

changeset-bot bot commented Aug 16, 2024

🦋 Changeset detected

Latest commit: 06113db

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
solid-js Minor
solid-element Major
test-integration Patch

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

@ryansolid ryansolid changed the base branch from main to next September 23, 2024 20:47
@ryansolid ryansolid merged commit 120bf06 into solidjs:next Sep 23, 2024
1 check passed
ryansolid added a commit that referenced this pull request Sep 24, 2024
* update dom-expressions to include client-side API placeholders in web/dist/server.js

* update dom-expressions version to temporary one from git for testing

* update lock file

* Add exports to solid-js/store's server build to match the client build, marking the additional export as not supported on the server side

* update dom-expressions

* fix!: Remove browser field from package.json (#2255)

* fix!: Remove browser field from package.json of core packages so that worker export doesn't get mapped back to removeBrowserPackageJson

BREAKING CHANGE: Jest was previously mentioned as the reason that wasn't removed, but Jest now supports package.json modules. That said, some other tooling might still not support esm exports.

* Create rare-birds-train.md

---------

Co-authored-by: Ryan Carniato <[email protected]>

* better handling of exports client/server

* Improve signal setter type for code completion of string literal unions. (#2297)

* fix

* fix test

* Create shy-islands-talk.md

---------

Co-authored-by: Ryan Carniato <[email protected]>

* update TS to NodeNext

---------

Co-authored-by: Joe Pea <[email protected]>
Co-authored-by: Will Kelly <[email protected]>
Co-authored-by: 狐狸 <[email protected]>
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.

2 participants