Skip to content

[browser] Provide "single-file" deployment #86162

Closed

Description

@pavelsavara

Similar to WasmSingleFileBundle in wasi.
Bundle all the files inside one JS or maybe .wasm as separate, but not 20 files.
Enable users to use 3rd party solutions like webpack.

Currently we use ES6 dynamic import in runtime code.
In few places we disable webpack on it by /* webpackIgnore: true */, I'm not sure this is a problem.

Activity

  1. added this to the Future milestone on May 12, 2023
  2. self-assigned this
    on May 12, 2023
  3. RPGillespie6 commented on May 12, 2023

    @RPGillespie6

    It would be nice to have the option of bundling everything into a single distributable JS file, similar to OpenCV where the wasm and any dependencies are base64 encoded into a single file: https://docs.opencv.org/3.4/opencv.js

    The primary motivation is portability to non-.NET web applications. For example, I work for a medical software company where most of our on premises solutions are .NET (for example: https://radformation.com/autocontour/autocontour).

    We are interested in leveraging WebAssembly in order to bring medical image viewers originally written in C# to the browser. And so far, the results are really promising. It's just a bit of a pain to embed the C# into a page since you need to drop 20+ files into the webserver root and fetch at least 4:

    	<script type='module' src="./main.js"></script>
    	<script type='module' src="./dotnet.js"></script>
    	<link rel="preload" href="./mono-config.json" as="fetch" crossorigin="anonymous">
    	<link rel="prefetch" href="./dotnet.wasm" as="fetch" crossorigin="anonymous">
    

    Compared to OpenCV where we can start doing image contouring with a single dependency - opencv.js.

    It seems like most of the HTTP requests are coming from dotnet.json reading mono-config.json so seems like it would not be too hard to add a preprocessing step where mono-config.json is read at compile time and base64 encoded into dotnet.js.

    Download size is not an issue because for something like this - in most cases it would be downloaded once and then cached for subsequent page refreshes. So for this particular case I'm not really interested in building an "app" so much as I am interested in building a "library" that apps can use.

    For example, I would compile my CTImageViewer.cs to ctImageViewer.js which can be dropped into any web app and wired up to an HTML5 canvas, and bam, now that app can display CT images in browser.

  4. added
    in-pr
    on Jun 13, 2025
  5. locked and limited conversation to collaborators on Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-System.Runtime.InteropServices.JavaScriptin-pr

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions