Skip to content
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

wasm-bindgen snippets aren't included #40

Closed
siku2 opened this issue Sep 15, 2020 · 2 comments · Fixed by #42
Closed

wasm-bindgen snippets aren't included #40

siku2 opened this issue Sep 15, 2020 · 2 comments · Fixed by #42
Assignees
Labels
assets Build pipelines for specific asset types bug Something isn't working cli Trunk CLI application good first issue Good for newcomers

Comments

@siku2
Copy link
Contributor

siku2 commented Sep 15, 2020

wasm-bindgen has the ability to automatically include javascript files referenced in the code:

use wasm_bindgen::prelude::*;

#[wasm_bindgen(module = "/get-payload-script.js")]
extern "C" {
    #[wasm_bindgen(js_name = "getPayload")]
    pub fn get_payload() -> String;
}

It does this by including these referenced files in a directory called "snippets" which is located in the output directory.
They are then imported in the index.js file:

import { getPayload } from './snippets/js_callback/get-payload-script.js';

Trunk doesn't seem to handle this right now so these snippets aren't included in the output.

@thedodd thedodd added assets Build pipelines for specific asset types cli Trunk CLI application good first issue Good for newcomers bug Something isn't working labels Sep 15, 2020
@thedodd
Copy link
Member

thedodd commented Sep 15, 2020

This should actually be dead simple to fix. The pipeline which spawns the wasm-bindgen invocation should not only copy the wasm output to the dist dir, but also the snippets as well. As long as we copy the snippets dir over to the dist dir without modification, then all of the paths in the JS will continue to work normally.

@siku2 thanks for the report. I've been working on automating the release process for Trunk. Only a few small changes to knock out. I'll actually address this issue and release it as part of the 0.4.0 release.

@thedodd
Copy link
Member

thedodd commented Sep 16, 2020

@siku2 handling of JS snippets from wasm-bindgen is working quite nicely now! Let me know if you run into any issues. v0.4.0 is on its way out the door right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assets Build pipelines for specific asset types bug Something isn't working cli Trunk CLI application good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants