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 file not included in dependencies #365

Open
dotellie opened this issue Jan 31, 2024 · 2 comments
Open

WASM file not included in dependencies #365

dotellie opened this issue Jan 31, 2024 · 2 comments

Comments

@dotellie
Copy link

I'm using a Deno module that has some WASM code included (https://github.com/unyt-org/typescript-transpiler) and after running dnt, transpiler_bg.wasm is missing in the deps folder.

Working around this issue with

  async postBuild() {
    const res = await fetch(
      "https://deno.land/x/ts_transpiler@v0.0.2/js/transpiler_bg.wasm",
    );
    await Deno.writeFile(
      "npm/esm/deps/deno.land/x/ts_transpiler@v0.0.2/js/transpiler_bg.wasm",
      new Uint8Array(await res.arrayBuffer()),
    );
  }

works just fine, so I'm assuming that this could be a bug in dnt 😅

@dsherret
Copy link
Member

dsherret commented Feb 1, 2024

It's unfortunately not feasible/easy for dnt to analyze this and realize that it needs to include the Wasm file:

https://github.com/unyt-org/typescript-transpiler/blob/3b41add2bc4b961b6156ae694a4852be63a91b83/js/transpiler.generated.js#L413

We're working on adding Wasm imports to Deno and that would make the .wasm file part of the module graph, in which case dnt would be able to easily include it.

For now, I'd recommend that workaround, but also check the status code to ensure it fails when it can't reach the server:

// ex. something like
if (!res.ok) {
  console.error(await res.text());
  throw new Error(`Failed downloading: ${res.statusText}`);
}

@dotellie
Copy link
Author

dotellie commented Feb 1, 2024

Ah yep that makes a lot of sense. And good call on the error checking - I think I was in ugly code mode yesterday 😂 Thank you for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants