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

Blazor JS interop across module formats #20461

Closed
guardrex opened this issue Nov 10, 2020 · 5 comments · Fixed by #20538
Closed

Blazor JS interop across module formats #20461

guardrex opened this issue Nov 10, 2020 · 5 comments · Fixed by #20538

Comments

@guardrex
Copy link
Collaborator

@GeorgeS2019 asked on #19873 (comment) ...

@guardrex Can we have Blazor JS Isolation examples using different module format?

  • The Asynchronous Module Definition (AMD) format
  • The CommonJS (CJS) format
  • The ES Module (ESM) format.
  • The System.register format
  • The Universal Module Definition (UMD) format

My general feeling is that we're pressed for time with the current workload well into 2021, and these approaches ...

  • Aren't really pivotal for coverage of Blazor concepts.
  • Exist in external doc sets.

Even if we took this on, I think it would have to be a new JS interop topic that shows how each module format can be used in a Blazor scenario with the same example in a SxS format.

I've marked this for triage so that management can consider it and decide if it should be taken on. Thanks for asking @GeorgeS2019.

@GeorgeS2019
Copy link

@guardrex As anyone who want to believe that Blazor will empower c# developer to do web development, we want Microsoft ASPNetCore team to provide a comprehensive solution that SHOW blazor JS Isolation is able to handle all possible JS Module format scenarios.

The JS Isolation solution is A very GOOD promising START.

The more we work on it, the more we realize, there are still questions that limit our abilities to implement JS Isolation

For example. in the documentation, it is important to state that the current Blazor JS Isolation is ONLY LIMITED to the following FORMAT. We are working with the community to get help to handle OTHER FORMATS. Your feedback is important so we will prioritize the typical use cases.

In my view, the typical use cases, are having NodeModues installed in wwwroot directory and we need Blazor JS Isolation to play nice with these NodeModules e.g. using CommonJS format module that involve "require" ==> which unfortunately does not WORK YET in current implementation of Blazor JS Isolation ( If I understand correctly, and I hope I am wrong about that).

@javiercn
Copy link
Member

@GeorgeS2019 I'm not sure I completely understand what you are asking.

There is no JS isolation support for anything other than importing ES modules, which is what the browser supports.

If you are asking for support for JS isolation in combination with other module formats, that's not really the goal of the JS isolation support that we currently ship. I would suggest you file an issue in the asp.net core repository instead if you want to see support for other module formats (whatever that means) so that it can be considered for an addition in a future release.

@guardrex
Copy link
Collaborator Author

With that, I'm going to close this for action here.

@GeorgeS2019
Copy link

@javiercn @guardrex

Thanks for clarifying that the Blazor JS Isolation adheres to the ESM module format.

=> Is that clearly documented in the official Blazor JS Isolation currently only the ESM format is supported right now.
=> By stating that, it helps the majority of JavaScript developers evaluating migrating projects to Blazor to plan more effectively.
=> How to span the CJS to ESM gap => by taking this into consideration, it helps to convince these non Blazor developers that the team implementing JS Isolation has considered important use cases (e.g. Work in Progress in evaluating how to address the CJS to ESM gap). I believe, this will give more credibility to the Blazor vision - thinking ahead of needs for others joining the Blazor as the choice for web development.

@guardrex
Copy link
Collaborator Author

guardrex commented Nov 12, 2020

Good idea @GeorgeS2019 ...

Is that clearly documented in the official Blazor JS Isolation currently only the ESM format is supported right now.

I can address that aspect with a quick one-liner at the tops of EDIT at the bottoms of ... our two JS interop topics ... in a short section. I propose ...

## JS modules

For JS isolation, JS interop works with the browser's default support for [EcmaScript modules (ESM)](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Modules) ([ECMAScript specification](https://tc39.es/ecma262/#sec-modules)).

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

Successfully merging a pull request may close this issue.

4 participants