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] introduce typescript modules #59392

Merged
merged 4 commits into from
Sep 27, 2021
Merged

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Sep 21, 2021

Goals

Introduce typescript and break up the code to multiple, better encapsulated modules.

  • use EMSDK nodejs for the build
  • use rollup.js to produce ES6 IFFE because emscripten doesn't know how to consume ES6 modules on input.
  • the ts output file runtime.iffe.js is compiled with emcc and AOT as --pre-js
  • package.json references explicit versions of dev-time only dependencies. They are not necessary on link time.
  • dependencies are resolved with npm ci in CI pipeline to make sure we get exactly same version as in lock file.
  • we also run npm audit in CI so that we are sure we don't have new security issue in the CI.
  • we have small rollup plugin which checks sha256 hash of the output and doesn't overwrite it if it's the same. So that incremental build/link is not broken.
  • ignore_pdb_load_errors is now Module.config option

Non-goals

  • just library_mono.js , the rest will be in follow up PRs
  • functional changes
  • later: lint, renames, more cleanup
  • API change toward embedders like Blazor
  • sourcemaps

@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Sep 21, 2021
@pavelsavara pavelsavara added this to the 7.0.0 milestone Sep 21, 2021
@ghost
Copy link

ghost commented Sep 21, 2021

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

Issue Details

null

Author: pavelsavara
Assignees: -
Labels:

arch-wasm

Milestone: 7.0.0

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

src/mono/wasm/runtime/rollup.config.js Outdated Show resolved Hide resolved
src/mono/wasm/runtime/src/mono/cwraps.ts Outdated Show resolved Hide resolved
src/mono/wasm/runtime/src/mono/heap.ts Outdated Show resolved Hide resolved
src/mono/wasm/runtime/src/mono/init.ts Outdated Show resolved Hide resolved
src/mono/wasm/runtime/src/mono/init.ts Outdated Show resolved Hide resolved
@am11
Copy link
Member

am11 commented Sep 24, 2021

Would this make it possible to make WasmEnableES6 default to true with this change?

<WasmEnableES6 Condition="'$(WasmEnableES6)' == ''">false</WasmEnableES6>

WasmEnableES6 results in importable ES6 module for dotnet in deno environment. It's also compatible in browser (since WASM and ES6 are mutually supported everywhere).

@pavelsavara
Copy link
Member Author

pavelsavara commented Sep 25, 2021

Would this make it possible to make WasmEnableES6 default to true with this change?

<WasmEnableES6 Condition="'$(WasmEnableES6)' == ''">false</WasmEnableES6>

WasmEnableES6 results in importable ES6 module for dotnet in deno environment. It's also compatible in browser (since WASM and ES6 are mutually supported everywhere).

I would love to, but I need to work thru all the consequences. Our unit test infrastructure and also the way how external projects like ASP.NET/Blazor consume us. So most likely it would not be in this PR.

But it's on my wish list too.

- use nodeJs from EMSDK
- use rollup.js for packing code as ES6 IFFE for emcc consumption
- incremental build Co-authored-by: Radek Doulik <[email protected]>
- types Co-authored-by: Daniel Genkin <[email protected]>
@pavelsavara
Copy link
Member Author

OSX failure is unrelated timeout.

@pavelsavara pavelsavara marked this pull request as ready for review September 25, 2021 16:11
@pavelsavara
Copy link
Member Author

@radical I introduced new file to AOT inputs. I don't know how it would impact VS/workloads. We will probably remove or rename all the other .js files too in next PR. Would something break in the meantime ?

src/mono/wasm/build/WasmApp.Native.targets Outdated Show resolved Hide resolved
src/mono/wasm/runtime/src/mono/init.ts Show resolved Hide resolved
src/mono/wasm/build/WasmApp.Native.targets Outdated Show resolved Hide resolved
@radical
Copy link
Member

radical commented Sep 25, 2021

cc @Thays to try this with the debugger tests.

@pavelsavara pavelsavara merged commit ca2cb03 into dotnet:main Sep 27, 2021
@pavelsavara pavelsavara changed the title [draft][wasm] introduce typescript modules [wasm] introduce typescript modules Sep 27, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
@pavelsavara pavelsavara deleted the wasm_ts4 branch January 4, 2022 13:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants