-
Notifications
You must be signed in to change notification settings - Fork 1
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
Migrate from glimmer.js to svelte #19
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chadian
force-pushed
the
svelte
branch
2 times, most recently
from
May 27, 2022 20:16
8a8029a
to
aaf72d9
Compare
chadian
force-pushed
the
svelte
branch
6 times, most recently
from
August 23, 2022 16:29
4c921a2
to
963f0da
Compare
chadian
changed the title
Implement Vorfreude using Svelte
Migrate from glimmer.js to svelte
Aug 23, 2022
Bumps [bestzip](https://github.com/nfriedly/node-bestzip) from 1.1.4 to 2.1.7. - [Release notes](https://github.com/nfriedly/node-bestzip/releases) - [Commits](nfriedly/node-bestzip@v1.1.4...v2.1.7) Signed-off-by: dependabot[bot] <[email protected]>
Using hashes to track routes in urls is better for chrome extensions. This is because the default of providing a route at /settings for example doesn't map in extension land to a .html There is probably a way of intercepting route changes in extensions for urls and redirecting them but this would require escalated privledges and be harder to test. The other method of generating a prerendered .html file for every route almost worked except svelte's routing doesn't recognize a route at its .html location once it's loaded. It wants to deal with goto("/settings"), it doesn't recognize goto("/settings.html"). The hacky workaround I have here works pretty well. Every route change that happens it goes and replaces the current route with a corresponding hash representation. If someone reloads the page the hash representation needs to be mapped back to its corresponding route and then navigated to that route by svelte's `goto`. Upon entering that route it will again have its url replaced with its hash match. This method also helps encapsulate the swapping of the routes to be friendly for local dev server or extension. In the case of the extension the hash is at "index.html#route" and when being served by the local dev server it is replaced with "/#route". While this is hacky it is consistent and allows for everything to be handled entirely "in app". If this app were to increase the number of routes it had to manage then this hash mapping would become less sustainable and maybe more research into how other svelte apps handle this challenge would be warranted.
If there was already a chrome tab opened then going to the options would not open a new tab at #settings nor would it update the existing opened tab to #settings, resulting in the options button linked from the browser's extension page essentially noop'ing. This dedicated settings.html does a local js redirect to index.html#settings and that way every new tab opened by the browser's extension option page will end up at index.html#settings
This means that the bg will be rendered before any js and css is loaded and parsed, hopefully reducing the amount of "white" flash
This commit adds a route that is as an ugly hack for when "index.html" loads and it tries to load the corresponding route. Without this "index.html" route the router can't find a matching route, throws an error, but still ends up at the default route (so the user doesn't notice the issue) but it leaves an ugly error in the console. By having an "index.html" route which is a shortcoming of being able to serve from static files like within extensions, this route kicks things off by navigating to the root route "/".
chadian
force-pushed
the
svelte
branch
8 times, most recently
from
October 2, 2022 18:48
56dd93f
to
14ee81b
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request migrates Vorfreude from glimmer.js to svelte (and addresses #6). Jumping from where glimmer.js was back when this project started to where it is now was too big of a leap to the point where it felt similar to a rewrite. The glimmer.js project doesn't feel as stable now, I ran into contradictory documentation and it looks like a few of the conventions are in flight as rfcs are changing. Considering this, along with the fact that Svelte is more stable and offered a new opportunity to learn, I decided to go ahead with Svelte.
It'll be interesting to compare what sort of bugs crop up from the migration as well as any benefits like performance or overall bundle size.
object-fit
withobject-position
and flex box instead offixed
/absolute
andbackground-image
(check for resize performance, too)chrome
foldermanifest.json
relative build artifacts (ie: icons, etc) are loaded correctlyTakeaways from the migration
While glimmer.js has stagnated, it's bigger sibling Ember.js has a lot of out of the box that was lacking in Svelte(Kit), although Svelte(Kit) also had a few things that Ember could learn from.
useState
in react, and a little more explicit thattracked
with Ember since$
and the store interface feels more like "just javascript", ie: being able to use thesubscribe
method to subscribe to changes is nice and when used in templates$store
is syntax sugar to tracking those changes in the DOM. Also the arbitrary javascript of react combined with similar template helpers of ember makes svelte work really well ({#if}{else}
in svelte vs{{#if}}
in ember vs weird ternary orcondition && result
in react). Defining a component interface via ES Moduleexport
s feels odd, like it betrays the semantics of modules and expectations aroundexport
🤷.testing-library
with svelte and jest/js-dom along with SvelteKit's playwright left a lot to be desired. Playwright is nice in that it's "more real" in simulated browser interactions but ember's abstractions around haven't failed me yet. Playwright is great, but having to have different setups, jest/jsdom and playwright, for unit/component and acceptance test, respectively, it a bit more work and requires an understanding of different APIs and mental models of how the environment they're running in. With ember, you're always running in the browser, you're always using the test'em runner, and the apis are consistent across both. Overall though, the Svelte testing is much quicker.All in all Svelte and SvelteKit look very promising. Much of it feels quick to pick up and the APIs seem barebones enough that you only reach for what you need and when you do the learning curve is incremental in a way that mostly works and feels natural. Some of the infrastructure and ecosystem around Svelte and SvelteKit seem like they still need more work but it does seem like it's setup in a way that it can be extensible and improve (ie: there was an extension adapter for building browser extensions but it failed out of the box with an unresolved issue that was listed on the GitHub).
There are other areas where Svelte should shine even more, like animations, but I didn't have a reason to explore these. After working around build and routing issues SvelteKit does feel like a good choice and hopefully provides a bit more opportunity for this little app to grow even more.