From f087388ebc6314c2852d553f4f4ea3074369dfbe Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 28 Jan 2023 23:23:26 -0800 Subject: Support running WASI (WebAssembly) files using `bun run` (#1929) * another micro bench * Support running WASI --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bundler.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/bundler.zig') diff --git a/src/bundler.zig b/src/bundler.zig index ec3de573b..336723da3 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -1404,6 +1404,17 @@ pub const Bundler = struct { .ts, .tsx, => { + // wasm magic number + if (source.isWebAssembly()) { + return ParseResult{ + .source = source, + .input_fd = input_fd, + .loader = .wasm, + .empty = true, + .ast = js_ast.Ast.empty, + }; + } + const platform = bundler.options.platform; var jsx = this_parse.jsx; @@ -1518,7 +1529,7 @@ pub const Bundler = struct { }, .wasm => { if (bundler.options.platform.isBun()) { - if (source.contents.len < 4 or @bitCast(u32, source.contents[0..4].*) != @bitCast(u32, [4]u8{ 0, 'a', 's', 'm' })) { + if (!source.isWebAssembly()) { bundler.log.addErrorFmt( null, logger.Loc.Empty, -- cgit v1.2.3