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

Make modular variant of the library available to Web Workers #1514

Closed
lawrence-forooghian opened this issue Nov 22, 2023 · 3 comments
Closed
Assignees

Comments

@lawrence-forooghian
Copy link
Collaborator

lawrence-forooghian commented Nov 22, 2023

Users running Ably inside a Web Worker will have the same bundle size concerns that v2’s modular variant of the library aims to address. So, we should make the modular variant available for use in Web Workers. I'd suggest that we consider getting rid of the current Web Worker build of the library and instead just use the normal web bundle, detecting whether we're running inside a Web Worker at runtime.

We also need to provide the modular variant of the library for use in Web Workers so that they can use Vcdiff functionality, which was removed from the default web bundle (and hence the Web Worker bundle) in #1512.

@lawrence-forooghian
Copy link
Collaborator Author

Do you have any thoughts on this, @owenpearson? Do you think that getting rid of the Web Worker-specific build would be a good way forward?

Copy link

sync-by-unito bot commented Nov 22, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3952

lawrence-forooghian added a commit that referenced this issue Nov 28, 2023
A summary of the discussion on #1492:

- the modular API should be the only way to pass optional functionality
  to the SDK

- this means we need to replace the existing ClientOptions.plugins
  mechanism, which is currently used to pass a Vcdiff decoder

- since the modular variant of the SDK only exists for web at the
  moment, we will bundle Vcdiff decoding into all other platforms (in
  which bundle size is not much of a concern)

- on web, if you want deltas, you have to use the modular variant of the
  SDK

So, we remove the ClientOptions.plugins mechanism and introduce a
tree-shakable Vcdiff module, which bundles the vcdiff-decoder library
(meaning that users no longer need to directly import this library).

Note that this means that, currently, it is no longer possible to use
deltas inside a Web Worker. We’ll address this in #1514.

The README example of configuring a channel to use deltas is copied from
the README of the vcdiff-decoder library.

(Once ably-js v2 is released, we should update the instructions in the
vcdiff-decoder library’s README to make it clear they only apply to v1.
I’ve raised #1513 for this.)

Resolves #1492.
lawrence-forooghian added a commit that referenced this issue Nov 28, 2023
A summary of the discussion on #1492:

- the modular API should be the only way to pass optional functionality
  to the SDK

- this means we need to replace the existing ClientOptions.plugins
  mechanism, which is currently used to pass a Vcdiff decoder

- since the modular variant of the SDK only exists for web at the
  moment, we will bundle Vcdiff decoding into all other platforms (in
  which bundle size is not much of a concern)

- on web, if you want deltas, you have to use the modular variant of the
  SDK

So, we remove the ClientOptions.plugins mechanism and introduce a
tree-shakable Vcdiff module, which bundles the vcdiff-decoder library
(meaning that users no longer need to directly import this library).

Note that this means that, currently, it is no longer possible to use
deltas inside a Web Worker. We’ll address this in #1514.

The README example of configuring a channel to use deltas is copied from
the README of the vcdiff-decoder library.

(Once ably-js v2 is released, we should update the instructions in the
vcdiff-decoder library’s README to make it clear they only apply to v1.
I’ve raised #1513 for this.)

Resolves #1492.
lawrence-forooghian added a commit that referenced this issue Nov 28, 2023
A summary of the discussion on #1492:

- the modular API should be the only way to pass optional functionality
  to the SDK

- this means we need to replace the existing ClientOptions.plugins
  mechanism, which is currently used to pass a Vcdiff decoder

- since the modular variant of the SDK only exists for web at the
  moment, we will bundle Vcdiff decoding into all other platforms (in
  which bundle size is not much of a concern)

- on web, if you want deltas, you have to use the modular variant of the
  SDK

So, we remove the ClientOptions.plugins mechanism and introduce a
tree-shakable Vcdiff module, which bundles the vcdiff-decoder library
(meaning that users no longer need to directly import this library).

Note that this means that, currently, it is no longer possible to use
deltas inside a Web Worker. We’ll address this in #1514.

The README example of configuring a channel to use deltas is copied from
the README of the vcdiff-decoder library.

(Once ably-js v2 is released, we should update the instructions in the
vcdiff-decoder library’s README to make it clear they only apply to v1.
I’ve raised #1513 for this.)

Resolves #1492.
VeskeR added a commit that referenced this issue Dec 13, 2023
Removes dedicated Web Worker build from webpack. Now automatically
detects whether we are running in a Web Worker context where needed.

Resolves #1514
@VeskeR VeskeR closed this as completed Jan 5, 2024
@VeskeR
Copy link
Contributor

VeskeR commented Jan 5, 2024

Done in #1550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants