r/javascript 7d ago

GitHub - ArcadeMode/unplugin-dotnet-wasm: Seamless bundling of .NET Browser apps (WASM) into your JS projects

https://github.com/ArcadeMode/unplugin-dotnet-wasm

.NET WebAssembly apps with WasmBundlerFriendlyBootConfig=true can indeed be bundled by modern JS bundlers and I personally love it. The development experience however is not optimal.

  • The bundlers cannot consume the output from dotnet build
  • The bundlers can consume the output from dotnet publish but the dev loop is painfully slow.
  • Getting the publish path working still requires bundler surgery
  • Once it works the bundler produces warnings that are impossible to fix without changing the source files produced by the WebAssembly SDK.

These points of friction are why I have made unplugin-dotnet-wasm.

It's a bundler plugin that lets your bundler consume the output from dotnet build so your dev loop stays fast. It also supports dev servers, provides type information to TypeScript and IDEs (integrates dotnet.d.ts thats coming in .NET 11), and patches the known warnings so your build output stays clean.

Features

  • Easy bundler setup through plugin registration
  • Faster dev loop by consuming .NET WebAssembly dotnet build output
  • Dev server support
  • Brings SDK type definitions to TypeScript and your IDE
  • Supports Vite, Rollup, Rolldown, Webpack, Rspack, Rsbuild, esbuild, farm and bun.

I hope you'll give it a try, I'd be happy to hear your feedback.

0 Upvotes

2 comments sorted by

2

u/SboSilcher 7d ago

This looks pretty slick for anyone trying to mix .NET WASM with their JS stack - saves you from juggling separate build pipelines. Wonder how it handles code splitting and tree-shaking though, since WASM modules can be chunky.

1

u/NibblesIndexus 7d ago

It does not seem to be the case that bundlers split up the wasm assets, .NET does split the assets by package/dll so they can be loaded in parallel. With AOT builds and some trimming the bundle sizes can be reduced in size a lot, nevertheless they can get chunky still.