Skip to content

[Pre6] Blazor build output friendly JavaScript bundlers #35631

Open
@maraf

Description

@maraf

PR dotnet/runtime#116300 (preview 6)

By default, blazor build (or publish) output is not compatible with javascript bundlers (tools like webpack or rollup that use babel to transpile javascript code). The reason for it that we depend on several files (some javascripts, .NET runtime compiled to WebAssembly code and some managed assemblies packed as WebAssembly files).

The PR adds an msbuild property WasmBundlerFriendlyBootConfig, by setting it to true, .NET build (or publish) produces an output that is not directly executable in the browser but is compatible with javascript tools.

The package.json & rollup.config.mjs contains sample setup of npm project with rollup that can compile all javascript files into a single one and handle additional .NET files by copying them to the npm build output.

Replacing files plugin with url we can end-up with having everything in a single file. The WebAssembly code will be base64 encoded in the javascript. The size will explode (like 3x). It's definitely not something typical blazor app should be using and I'm sure about including it in the docs. It's more of an edge case (for a bit edge scenario of using javascript bundler with blazor).

I'll be working on updating my sample in next days https://github.com/maraf/dotnet-wasm-react.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

10.0

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions