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

An option to publish Blazor WASM as UMD library #37910

Closed
elringus opened this issue Oct 28, 2021 · 6 comments
Closed

An option to publish Blazor WASM as UMD library #37910

elringus opened this issue Oct 28, 2021 · 6 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@elringus
Copy link

Is your feature request related to a problem? Please describe.

I'm looking to compile C# to an environment-agnostic (UMD) JavaScript library to be used in both browser and server environments.

blazor.webassembly.js bundled with Blazor WASM distro is not UMD-compliant, as it attempts to access window and manipulate the DOM (eg, via document.createElement calls).

Describe the solution you'd like

A deploy/build option for Blazor WASM projects to produce a single file UMD-compliant JS library.

Additional context

Example use case: using C# libraries from VS Code web extension.

Similar issue: #37732 (the proposed solution to customize Blazor deployments won't work, as the issue is with the blazor.webassembly.js)

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 28, 2021
@javiercn
Copy link
Member

@elringus thanks for contacting us.

It's unclear to us what you are asking here. What do you propose Blazor does instead of accessing the window or using things like document.createElement?

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Oct 29, 2021
@ghost
Copy link

ghost commented Oct 29, 2021

Hi @elringus. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@elringus
Copy link
Author

@javiercn The bare minimum required for interop. I guess that will be invoking Program::Main so we can access IJSRuntime required to call JS methods from C#. Here is simplified use case: https://github.com/Elringus/WasmTest/blob/main/Program.cs

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Oct 29, 2021
@javiercn
Copy link
Member

@elringus Thanks for the additional details.

Unfortunately, that's not something we plan to work on in the near future. Our focus is to deliver a UI experience using C# and web technologies and we don't plan to offer an out of the box experience that doesn't involve UI.

This is something you'll have to create yourself by bootstrapping the Webassembly runtime in the same way we do, or the UNO platform does. It's not something that we from the ASP.NET team plan to work on.

@javiercn javiercn added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Oct 29, 2021
@ghost ghost added the Status: Resolved label Oct 29, 2021
@ghost
Copy link

ghost commented Nov 3, 2021

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@elringus
Copy link
Author

In case someone finds this looking for a similar use case, I've a made a solution, that compiles C# project into a single-file UMD library: https://github.com/Elringus/DotNetJS

@ghost ghost locked as resolved and limited conversation to collaborators Dec 19, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants