-
Notifications
You must be signed in to change notification settings - Fork 29
Add support for js snippets #527
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool, didn't know this feature existed! Thanks for working on this.
I created a test package and it works as expected.
Just have one suggestion, but otherwise it's good to go :)
&format!("/build/{}", wasm_file_name.to_str().unwrap()), | ||
ServeFile::new(build_artifact_path.join(wasm_file_name)), | ||
) | ||
.nest_service("/build", ServeDir::new(build_artifact_path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it's a good idea to include the entire build artifact folder here. It can contain a lot of different files from many different binaries.
While this is for dev only, I think it would be best if we emulated the same environment as the packaged bundle, which wouldn't include the entire build folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it as a problem, it just means that we correctly route to any file that is needed in the folder. This makes us more robust to potential changes in the file layout.
The main reason I did it this way is that we don't know up front which snippets are included by wasm-bindgen, and that the snippet directories include the hash of the files. I think it would be quite complicated to get that information, for very little gain.
Oh, can you also add an entry to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
wasm-bindgen has a feature called js snippets, see https://rustwasm.github.io/wasm-bindgen/reference/js-snippets.html. This PR makes bevy cli take these files into account both when serving and bundling.