-
Notifications
You must be signed in to change notification settings - Fork 341
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
feat(plugins): inject API on window.__TAURI__ #383
Conversation
Note that this does not read the |
I don't know if that's what you mean with your commend but i'd prefer to make the injection optional somehow. If the user uses more than one or two plugins this can lead to a pretty big binary size increase, at least when the larger plugins are used. Especially since we'll probably always add new plugins. Also, if we keep some kind of global config (a non-global config would be fine too imo) we could inject the "main" tauri code in tauri itself and remove it from the plugins, because it looks like that at least the smaller plugins are 90% just tauri's ipc code. |
Currently the global script is always embedded in the binary. To get around that, we'd need to use feature flags or do something clever with the build scripts. Parsing the Tauri config from a plugin build script is a big problem because we can't know the path to the file (without relying on the CLI to be used). Each plugin script increases almost 5KB in the binary. |
Hmm, right. Maybe we should make it a setting on the Builders? Or since most plugins only use an maybe just go with the current approach for now and think about it a bit over the remaining alpha time. |
We can't reduce the binary size by adding runtime options for this, it'll only speed up the app load. For size optimizations we need to resolve it at compile time. |
Right, of course... Sunday brain lag 😂 |
we'll probably have to rethink this with the new ipc again anyway, but what about using I feel like i'm overthinking this... |
You mean that instead of |
Ahh I see, that happens because we're not distributing the |
i may have had another intrusive thought 😅 Do you think it'd be viable to deprecate the mirrors in favor of this? Once the npm packages are out i'd imagine most will use these, or those who use withGlobalTauri today will already use this PR. |
my 2 cents is that we should respect |
As for mirros, I don't quite like'em so I agree with anything that helps deprecate them. |
Tbh I hate this global window API thing.. I only readded it because Amr said it is required for now for WASM consumers (I hope we can provide actual WASM bindings in the future with tauri-bindgen). Using this approach you lose type check, autocomplete etc, it sucks.
I don't think there's an easy way to do this unless I'm missing some dark magic with Rollup. |
I was thinking writing the same code twice, one that uses the npm package and one that uses the global tauri object, but maybe we could use something like this https://github.com/aMarCruz/rollup-plugin-jscc#usage to reduce the duplication |
I couldn't get jscc to work 100% because of aMarCruz/rollup-plugin-jscc#13 |
Alright, lets just go with this and think about improving it some other time. |
No description provided.