-
Notifications
You must be signed in to change notification settings - Fork 3
Description
While making the switch to CompressionStream in #51, it might be worth switching to a model where older protocol versions are dynamically imported if they are needed. This would improve bundle size for the majority of users who use the latest protocol version. For the rare cases where importing from an older protocol is needed, the dynamic import would barely be noticeable.
Either we turn all operations of the protocol into async operations (which would quite hard to work with).
Or, we could use something like https://github.com/quansync-dev/quansync to get faked sync dynamic imports of the non-default protocol version.
Another idea to get around the async coloring problem (that dynamic Imports would cause all protocol methods to become async) would be to simply redirect to an /import route if an older protocol version is used. This would achieve the same effect IF separating the imports from the main bundle, while still being backwards-compatible.
To implement this, change the following Giles to dynamically import the expected protocol version:
https://github.com/Greenheart/lifewheel/blob/main/src/components/LinkImport.svelte
https://github.com/Greenheart/lifewheel/blob/main/src/lib/import.ts
After dynamically importing the correct protocol version, it should be possible to use them as usual, except the import operations will havet to be async. Though that shouldn't be a problem.
CURRENT_PROTOCOL could change to only point at the latest version. And the other versions could get loaded via a helper async function getProtocol(version: number) that would cache the loaded protocol versions internally.