Skip to content

Commit

Permalink
support importing .wasm files / workers-rs support
Browse files Browse the repository at this point in the history
Following up from #107, this PR adds support for importing `.wasm` files. Specifically, it works directly on the output of [`workers-rs`](https://github.com/cloudflare/workers-rs). I'll test with other wasm outputs (like assemblyscript etc) later.
  • Loading branch information
threepointone committed Dec 14, 2021
1 parent ae4fe86 commit a852249
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-terms-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

support importing `.wasm` files / `workers-rs` support
5 changes: 3 additions & 2 deletions packages/wrangler/src/module-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ export default function makeModuleCollector(): {
build.onResolve(
// filter on "known" file types,
// we can expand this list later
{ filter: /.*\.(pem|txt|html)$/ },
{ filter: /.*\.(pem|txt|html|wasm)$/ },
async (args: esbuild.OnResolveArgs) => {
// take the file and massage it to a
// transportable/manageable format
const fileExt = path.extname(args.path);
const filePath = path.join(args.resolveDir, args.path);
const fileContent = await readFile(filePath);
const fileHash = crypto
Expand All @@ -46,7 +47,7 @@ export default function makeModuleCollector(): {
modules.push({
name: fileName,
content: fileContent,
type: "text",
type: fileExt === ".wasm" ? "compiled-wasm" : "text",
});

return {
Expand Down

0 comments on commit a852249

Please sign in to comment.