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

[wasm] drop cjs follow-up #72990

Closed
5 of 8 tasks
pavelsavara opened this issue Jul 28, 2022 · 15 comments
Closed
5 of 8 tasks

[wasm] drop cjs follow-up #72990

pavelsavara opened this issue Jul 28, 2022 · 15 comments
Assignees
Milestone

Comments

@pavelsavara
Copy link
Member

pavelsavara commented Jul 28, 2022

  • move -s EXPORT_ES6=1 to compilation or defaults .rsp
  • rename samples like console-v8-es6 to console-v8
  • rename or remove folder runtime\es6
  • use v8 --module to
    • get rid of src\mono\sample\wasm\console-v8-es6\v8shim.cjs
    • make test-main.js ES6
    • src\mono\wasm\host\JSEngineHost.cs
  • remove imports.isGlobal from exports.ts

https://bugzilla.mozilla.org/show_bug.cgi?id=1247687

@pavelsavara pavelsavara added this to the 7.0.0 milestone Jul 28, 2022
@pavelsavara pavelsavara self-assigned this Jul 28, 2022
@ghost
Copy link

ghost commented Jul 28, 2022

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

Issue Details
  • move -s EXPORT_ES6=1 to compilation or defaults .rsp
  • rename samples like console-v8-es6 to console-v8
  • rename or remove folder runtime\es6
  • use v8 --module to
    • get rid of src\mono\sample\wasm\console-v8-es6\v8shim.cjs
    • make test-main.js ES6
    • src\mono\wasm\host\JSEngineHost.cs
Author: pavelsavara
Assignees: pavelsavara
Labels:

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

Milestone: 7.0.0

@firasdib
Copy link

Hi,

Unsure if this is a good issue to comment on, but the change of always compiling to ES6 seems to break my build. I can't use import.meta.url and would like to stick to the old behavior, but from my search, I have not found a way to revert back to the old behavior.

Could you please advise?

Thank you.

@pavelsavara
Copy link
Member Author

@firasdib we are not going back to CommonJS. I would like to learn more about your problem with import.meta.url so that I could try to advise you or to address the issue. Thank you.

@firasdib
Copy link

I am trying to run some compiled code in the browser, and it says I cannot use import.meta.url outside of a module. It also contains export statements which aren't understood by the browser, either.

Specifically I am trying to use this in a web worker.

@pavelsavara
Copy link
Member Author

Web workers in FF don't support ES6 yet and I think we don't support running dotnet on worker either.
The message maybe means that you loaded the file as plain JS not as module. Maybe via script tag ?

@firasdib
Copy link

It works fine with the older preview build (currently whats running on regex101), but I am unable to update due to this limitation.

The only way to load scripts in the worker is through importScripts(), not script tags.

Why can't you keep ES6 for your internal functions, but allow it to be compiled to cjs through a flag? ES6 was opt in before, but now its removed, making it not usable for me, which is extremely unfortunate.

@pavelsavara
Copy link
Member Author

Why can't you keep ES6 for your internal functions, but allow it to be compiled to cjs through a flag? ES6 was opt in before, but now its removed, making it not usable for me, which is extremely unfortunate.

  • Because it doubles our test surface.
  • It brings lot of additional complexity in detecting scriptDirectory on various JS engines
  • We are also planning further modularization of the runtime. With CJS we would have to bring our own RequireJS on the web.

@firasdib
Copy link

Can it not be transpiled to any version of ES?

Not sure what scriptDirectory is, should be fairly simple to specify manually if necessary where the wasm file is?

I will try to find a manual way of managing this, otherwise I'm stumped at how to keep supporting .NET on regex101...

@pavelsavara
Copy link
Member Author

pavelsavara commented Sep 20, 2022

Can it not be transpiled to any version of ES?

Could you take dotnet.js and transpile it on your end? It would be good to figure out if it could be done.

@firasdib
Copy link

I will fiddle with it and see what I can do!

@firasdib
Copy link

I managed to get it to work by transpiling it myself on my end. Now there seems to be a new issue where I can no longer bind my methods, Error: Could not find method: RegexMatches, which worked before. But thats another, unrelated issue (do feel free to point me in any direction, through!).

Thanks for your help with this!

@pavelsavara
Copy link
Member Author

I know that old parcelJs versions had an issue which damaged the dotnet.js internals during minification. Try latest.

@pavelsavara
Copy link
Member Author

@firasdib please share more details how you made it work. I think others may have similar issues.

@firasdib
Copy link

@pavelsavara Sorry for the late reply.

I had to include the file in my bundle and transpile it was part of my own code. I then had to mark a few items in it as externals, as webpack would otherwise complain that it could not find those dependencies.

It adds some overall time to the compilation, and throws a few errors, but it works.

@pavelsavara
Copy link
Member Author

🎉

image

@ghost ghost locked as resolved and limited conversation to collaborators Jul 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants