mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 13:22:07 +00:00
Changes bun to properly support WebAssembly imports using the web standard
"webassembly" type attribute instead of the non-standard "wasm" type.
## Changes
- Modified js_printer.zig to output `type: "webassembly"` for .wasm files
(following web standards)
- Added "webassembly" -> .wasm mapping to options.zig to support both forms
- Restructured import attribute handling to always preserve web standard
attributes (css, json, webassembly) while only preserving Bun-specific
attributes when on Bun platform
- Added comprehensive tests for WebAssembly import attribute behavior
## Before
```javascript
import module from './module.wasm' with { type: 'webassembly' };
// Transpiled to:
import module from './module.wasm'; // ❌ attribute stripped
```
## After
```javascript
import module from './module.wasm' with { type: 'webassembly' };
// Transpiled to:
import module from './module.wasm' with { type: 'webassembly' }; // ✅ preserved
```
This ensures full compliance with WebAssembly ES module integration spec
while maintaining backward compatibility.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>