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

remove all the embedded hackery #11545

Merged
merged 2 commits into from
Jan 8, 2024

Conversation

Rich-Harris
Copy link
Member

The start_embedded.js stuff feels a bit odd to me — we never needed to load multiple copies of client.js before, and I don't really see why the changes in #11340 would mean that we need to now. AFAICT all we need to do to get the tests passing as before is to ensure that we hydrate the correct element.

There's still a bunch of quirks around embedded mode (which IIRC is primarily meant to allow you to embed a single SvelteKit app in a larger app, i.e. it prevents you from triggering the host app's own router — not to allow multiple embeds on a single page) but those are unrelated to the current work and so can live for another day.

Copy link

changeset-bot bot commented Jan 8, 2024

⚠️ No Changeset found

Latest commit: 31e0be1

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

@Rich-Harris Rich-Harris merged commit 8a30909 into treeshakeable-client Jan 8, 2024
13 checks passed
@Rich-Harris Rich-Harris deleted the treeshakeable-client-no-embedded branch January 8, 2024 23:45
Rich-Harris added a commit that referenced this pull request Jan 8, 2024
* feat: make client router treeshakeable

This removes the `create_client` method in `client.js` in favor of having everything as exported functions at the top level. Slight rearrangements to make some things lazy or put it behind a `BROWSER ?` condition are necessary, but otherwise the code is almost completely untouched. This makes it even less likely we can ever unit test the client router, but I think that ship has sailed a long time ago and e2e tests are a much more robust and an outright better way to test this, so it's a non-issue.

* changeset

* fix PURE annotation positions

* POC for potential solution: force deduplication of modules by appending a query string

* refine embedded approach

use an increasing id -> things are still cached, but dynamically, and Vite plays ball, too

* hacking my way to victory

* tweak

* move whole startup logic into create_client

* these can be private functions now

* fix

* Update packages/kit/src/runtime/client/start_embedded.js

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>

* chore: apply state to history.state directly (#11521)

* chore: apply state to history.state directly

The serialization capabilities of history.state are basically identical to those of devalue.stringify . As such, the indirection of saving the data in the session storage isn't necessary, which also saves 1kb compressed / 3kb uncompressed because of the no longer needed devalue functions

* Apply suggestions from code review

---------

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>

* Reduce indirection in treeshakeable client (#11544)

* reduce indirection

* fix

* tweak error messages

* sigh

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>

* remove all the embedded hackery (#11545)

* remove all the embedded hackery

* ugh

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>

* reduce diff size

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
dummdidumm added a commit that referenced this pull request Jan 9, 2024
Rich-Harris pushed a commit that referenced this pull request Jan 9, 2024
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.

1 participant