-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Snippets generated even when not needed #3330
Comments
I understand your issue. There isn't a clean, small fix for it, because we don't know the target in the function where we could remove the files. Maybe we could disable the write-to-disk of all snippets on no-modules without |
link_to can actually help me remove couple of manual hacks from wasm-bindgen-rayon, but only if this behaviour is preserved. Now that it exists, I'm doing something like: fn _ensure_worker_emitted() {
// Just ensure that the worker is emitted into the output folder, but don't actually use the URL.
wasm_bindgen::link_to!(module = "/src/workerHelpers.worker.js");
} This is because I need the Worker to be emitted alongside the snippet JS so that I can use static construct If snippet wasn't emitted and I could only get a URL value from wasm-bindgen without the statically emitted |
Another alternative would be to extend |
@RReverser I plan to address this soon and would like to understand your use case a bit more. Unfortunately I have no clue about bundlers but I'm unsure what your exact requirements are and why you are relying on Would you mind going into more detail explaining things from first principle so even I, without any knowledge of the JS ecosystem, can understand the issue and your goal? |
It's used for emitting a Web Worker's entry point alongside the main JS - https://github.com/RReverser/wasm-bindgen-rayon/blob/a947bdce8ef1e4b5456b349bd5b3763fe2516e25/src/lib.rs#L55-L59 - which will be used via So that emitted file is still used, but shouldn't be imported from the main JS file. For bundlers, that URL must be statically known name as they will only recognise a pattern like |
I'm still unsure how this should end up in My understanding is that you somehow need a way to for Am I understanding this correctly or am I missing something? |
Yeah that's correct. I know it's a hacky behaviour, but unfortunately the entire support for threads in Wasm is a hack on top of a hack. My job in this case was/is to maintain a library that at least hides all of that as implementation details and let's users "just use" Rayon. If there will be a better way to emit JS files into the output directory, I'm happy to switch to a different, dedicated API. |
Seeing that I'm really unqualified to address this, could you come up with a detailed feature proposal for |
Sorry, I don't think I'll have much time soon :( I general terms though... Any macro similar to current behaviour of |
Alright, please let me know if there is something else I can do here. |
So the behaviour above will be broken in the next release of wasm-bindgen? Is there no way to keep it? |
As I said I'm happy to discuss adding a new feature to |
The PR #3069 introduced linked modules,
link_to!(module = "/test.js")
. Currently this is meant to use snippets only if the--split-linked-modules
is enabled, but not otherwise.Currently, snippets are always generated, even in the no-modules target, they can be safely deleted and ignored, but they shouldn't be generated in the first place.
This can be easily tried by using
link_to!(module = "/test.js")
and trying out the following commands.wasm-bindgen --target no-modules
wasm-bindgen --target web
wasm-bindgen --target no-modules --split-linked-modules
Happy to give a more comprehensive, easy to use example if desired.
Cc @lukaslihotzki.
The text was updated successfully, but these errors were encountered: