Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pavelsavara opened this issue May 12, 2023 · 2 comments
Open

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

pavelsavara opened this issue May 12, 2023 · 2 comments
Assignees
Milestone

Comments

@pavelsavara
Copy link
Member

pavelsavara commented May 12, 2023

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.

@pavelsavara pavelsavara added this to the Future milestone May 12, 2023
@pavelsavara pavelsavara self-assigned this May 12, 2023
@ghost
Copy link

ghost commented May 12, 2023

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Bundle all the files inside one JS or maybe .wasm as separate, but not 20 files.

Author: pavelsavara
Assignees: pavelsavara
Labels:

arch-wasm, area-System.Runtime.InteropServices.JavaScript

Milestone: Future

@RPGillespie6
Copy link

RPGillespie6 commented May 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants