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

update dom-expressions, solid-js/web, solid-js/html, solid-js/store to make the exports isomorphic #2269

Merged
merged 4 commits into from
Sep 23, 2024

Conversation

trusktr
Copy link
Contributor

@trusktr trusktr commented Sep 1, 2024

Depends on:

Summary

This PR will make exports between client and server match ("isomorphic"), to stop people from running into build errors.

We will update the dom-expressions version in this PR once this dom-expressions PR is merged:

The dom-expressions PR adds a version of client-side APIs to server.js that throw when they are used on the server side. This bring the exports of server.js closer to parity with client.js so that we can avoid issues like:

Furthermore we update solid-js/store to also have matching exports between server and client.

How did you test this change?

Copy link

changeset-bot bot commented Sep 1, 2024

⚠️ No Changeset found

Latest commit: 617a64a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coveralls
Copy link

coveralls commented Sep 1, 2024

Pull Request Test Coverage Report for Build 10658254921

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.342%

Totals Coverage Status
Change from base Build 10586064173: 0.0%
Covered Lines: 4196
Relevant Lines: 4429

💛 - Coveralls

Comment on lines +22 to 26
// Types for these come from dom-expressions/src/server.d.ts
// These override the functions from dom-expressions that throw on the serverside.
export function render() {}
export function hydrate() {}
export function insert() {}
Copy link
Contributor Author

@trusktr trusktr Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions override the error-throwing functions that are now exported from dom-expressions, making this particular set of functions be no-ops instead of throwing errors.

All the other newly-added functions in dom-expressions (see here) continue to throw errors if they are not overriden here, which is non-breaking.

Removing the set of functions here could be breaking if anyone is already depending on them being no-ops, but the new functions added to dom-expressions/src/server.js never existed there or here for server code, so the introduction of those new error-throwing functions cannot be breaking because no one used them before.

If desired, those additional functions in dom-expressions can be overriden here to make them no-ops instead of error-throwing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me and honestly I think I'm ok even making them throw if called. I don't see any reason why these should ever be called on the server with a server build.

@@ -37,7 +37,7 @@
"babel-plugin-jsx-dom-expressions": "^0.38.5",
"coveralls": "^3.1.1",
"csstype": "^3.1.0",
"dom-expressions": "0.38.5",
"dom-expressions": "https://gitpkg.vercel.app/trusktr/dom-expressions/packages/dom-expressions?update-exports",
Copy link
Contributor Author

@trusktr trusktr Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a quick way to install a package from any github repo, including sub-folders, useful for testing.

See https://gitpkg.vercel.app

  • update dom-expressions version before merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests are passing. Anything I may not have thought of that needs testing?

@trusktr trusktr changed the title update dom-expressions to include client-side API placeholders in web/dist/server.js update dom-expressions, solid-js/web, solid-js/store to make the exports isomorphic Sep 1, 2024
…d, marking the additional export as not supported on the server side
@trusktr trusktr changed the title update dom-expressions, solid-js/web, solid-js/store to make the exports isomorphic update dom-expressions, solid-js/web, solid-js/html, solid-js/store to make the exports isomorphic Sep 1, 2024
@@ -103,6 +117,10 @@ export function createMutable<T>(state: T | Store<T>): T {
return state as T;
}

export function modifyMutable<T>(state: T, modifier: (state: T) => T) {
notSup();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw? Or should it be a no-op? I think that a no-op could be misleading, f.e. someone would think it worked, then log values only to see they didn't change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fair a lot of these methods still work on the server but just don't do anything. Like modifyMutable being missing is an oversight and should just function the same as in the client.

@ryansolid ryansolid changed the base branch from main to next September 23, 2024 20:53
@ryansolid ryansolid merged commit d83e57c into solidjs:next Sep 23, 2024
1 check passed
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.

3 participants