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

fix 14037 #14047

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/options.zig
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ pub const Loader = enum(u8) {
.napi,
.sqlite,
.sqlite_embedded,
// TODO: loader for reading bytes and creating module or instance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing the default behavior of a loader after implementing is a breaking change. so implementing this todo would be a separate loader. like we could do with { type: 'wasm' }. not important now.

.wasm,
=> true,
else => false,
};
Expand Down
20 changes: 20 additions & 0 deletions test/bundler/bundler_loader.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { fileURLToPath } from "bun";
import { describe } from "bun:test";
import { itBundled } from "./expectBundled";
import { join } from "path";
import fs from "node:fs";

describe("bundler", async () => {
for (let target of ["bun", "node"] as const) {
Expand Down Expand Up @@ -73,6 +75,24 @@ describe("bundler", async () => {
},
});

itBundled("bun/wasm-is-copied-to-outdir", {
target: "bun",
outdir: "/out",

files: {
"/entry.ts": /* js */ `
import wasm from './add.wasm';
import { join } from 'path';
const { instance } = await WebAssembly.instantiate(await Bun.file(join(import.meta.dir, wasm)).arrayBuffer());
console.log(instance.exports.add(1, 2));
`,
"/add.wasm": fs.readFileSync(join(import.meta.dir, "fixtures", "add.wasm")),
},
run: {
stdout: "3",
},
});

const moon = await Bun.file(
fileURLToPath(import.meta.resolve("../js/bun/util/text-loader-fixture-text-file.backslashes.txt")),
).text();
Expand Down
Binary file added test/bundler/fixtures/add.wasm
Binary file not shown.
Loading