4 ms·
For cross-framework usage it'd be great if instead of being a render callback, this was distributed as an HTML custom element. Then you could easily use it in a
by spankalee 3y ago
For cross-framework usage it'd be great if instead of being a render callback, this was distributed as an HTML custom element. Then you could easily use it in any declarative template system, even React/JSX.
I tried to make a web components here:
https://lit.dev/playground/#gist=8cf935c3869bf4790653cd6fadfd2508 https://lit.dev/playground/#gist=8cf935c3869bf4790653cd6fadf...
But the webgpu-waveform module isn't loading. Looks like you have a hard-coded import of "../../react@18.2.0/index.js", which isn't going to be a portable import even for the React users. For the non-React users, they shouldn't have to install React to get the module loading.
Could you make two entrypoints, one for React, the other for plain JS?
- llamaLord 3y agoI mean, in a pinch you can just run a build to compile it down to a single JS bundle with zero external dependencies and then mount it into your app. Not ideal, but works.
- spankalee 3y agoBuild systems are not available everywhere, like in many online playgrounds. There's no reason not to have a browser-loadable package by default these days.
- aylmao 3y agoah, I made the dependency optional, since it all goes through an index.ts it still attemps to load React, true. I'll find a way around this, or maybe split the package into a react version and a vanilla version. Thanks for the feedback! I think you're right, a custom element would be nice to have