Skip to content

Conversation

@holzgeist
Copy link
Contributor

This PR enables the bundling of this library as standalone package, e.g. for usage in the web part of livekit/client-sdk-flutter

holzgeist and others added 2 commits September 9, 2025 09:29
fix: properly bundle for browsers

fix: revert code changes

Reduce the intensity of the gray "flash" when enabling the `BackgroundProcessor` (livekit#96)

Version Packages (livekit#99)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Cache background image (livekit#100)

Version Packages (livekit#101)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@changeset-bot
Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: 65ff5f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@livekit/track-processors Minor

Not sure what this means? Click here to learn what changesets are.

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

@lukasIO
Copy link
Contributor

lukasIO commented Sep 15, 2025

thanks for the suggestion. I don't think removing livekit-client as a peer dependency altogether is the right option here though.

The flutter web lib is not type compatible with the JS version.

@holzgeist
Copy link
Contributor Author

Thanks for the review, I removed livekit-client during development, but re-added it during cleanup. It seems like I accidentally removed it during rebasing/merging

The types are compatible enough for some basic wiring. I'm currently in the process of cleaning up my video background plugin: https://github.com/holzgeist/flutter-livekit-background-effects/tree/main/livekit_background_effects_web

@lukasIO
Copy link
Contributor

lukasIO commented Sep 16, 2025

I see, I had another look at the current implementation and the package is already using tsup for bundling.

I'm not sure what exactly your change is proposing. What exactly is missing from the bundle today for it to work for your use case ?

@holzgeist
Copy link
Contributor Author

That's because I have very little idea about javascript bundling 🙈
I didn't know that tsup is a bundling tool too

The output file via tsup didn't run in the browser, so I assumed it was used for something different.

I'll try to play with tsup options tomorrow, maybe I'll succeed 😄 (e.g. a quick search showed the unused option platform which defaults to node, but has a browser variant..)

@lukasIO
Copy link
Contributor

lukasIO commented Sep 16, 2025

ah, I see what you mean. Yeah, for this we'll likely need to create single file build. Currently tsup sets the splitting option to true, which will likely fail for browser imports.
But even with that fix I'm not sure the internals here can properly access livekit-client dependencies.

when you say

The output file via tsup didn't run in the browser,

how are you currently importing the module?

@holzgeist
Copy link
Contributor Author

It looks like the iife output option combined with globalName does what I want. splitting only affects esm anyway, so it can stay like it is for my use case.

I import the script via a (programatically added) tag like this: <script src="URL" />, inspired by this flutter plugin: https://github.com/florent37/flutter_web_import_js_library

@lukasIO
Copy link
Contributor

lukasIO commented Sep 17, 2025

why wouldn't you use a dynamic import for the esm version?

@holzgeist
Copy link
Contributor Author

according to the meme story in the js import library I linked above and my own tries, it's not (yet?) possible to dynamically import javascript from dart code, even when compiling for web only

@holzgeist
Copy link
Contributor Author

Update: I might have found something (using your "dynamic import" wording to start looking for something more specific): https://api.dart.dev/dart-js_interop/importModule.html
I'll play with this (might take a while though, vacation is coming up)

@1egoman
Copy link
Contributor

1egoman commented Dec 10, 2025

I'm not sure the status of this, @holzgeist were you able to get your alternate solution to work? If not and you still are hoping this could get merged, feel free to post a message here and I'll give what you have here a shot locally.

Maybe a helpful note - if you are trying to integrate this package with the umd build of livekit-client (which is being built by rollup), then I think window.livekitClient (this is defined here, note that packageJson.name is livekit-client) should be set in a browser context and is where this package would need to look to get the loaded version of livekit-client.

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