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] Switch default modules to es6 #70746

Merged
merged 14 commits into from
Jun 24, 2022

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Jun 14, 2022

Motivation, benefits

  • TL;DR:
    • consistent in NodeJS and in browsers
    • module isolation
    • well defined exports/imports
    • dependencies resolution
    • dependencies detected during parsing, not during run
    • async dynamic imports awaitable
  • Why Modules cartoon
  • Supported everywhere for many years, everywhere where WASM is able to run.

Challenges, downsides

  • CommonJS module could be wrapped inside simple ES6 script. But not the other way around.
    • ES6 modules could be re-packaged by standard tools like webpack, rollup back to CJS or UMD.
    • libraries using another ES6 modules have to be also ES6 module (unless they re-pack with tools above).
  • Node.js 12 doesn't support it, but is end-of-life by 2022-04-30
  • After this PR will would still have way how to produce CommonJS, but is it worth supporting it ?

Changes in this PR

  • switched dotnet.js to be ES6 module by making <WasmEnableES6> default true
  • updated all samples
  • updated functional tests
  • updated debugger tests
  • updated test-main to
  • EXPORT_ES6=1 should not be in the emcc-link.rsp because it could not be removed by workload re-link when <WasmEnableES6> == false.

@pavelsavara pavelsavara added this to the 7.0.0 milestone Jun 14, 2022
@pavelsavara pavelsavara requested a review from maraf June 14, 2022 19:38
@pavelsavara pavelsavara self-assigned this Jun 14, 2022
@ghost
Copy link

ghost commented Jun 14, 2022

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

Issue Details

Motivation, benefits

  • TL;DR:
    • consistent in NodeJS and in browsers
    • module isolation
    • well defined exports/imports
    • dependencies resolution
    • dependencies detected during parsing, not during run
    • async dynamic imports awaitable
  • Why Modules
  • Supported everywhere for many years, everywhere where WASM is able to run.

Challenges, downsides

  • CommonJS module could be wrapped inside simple ES6 script. But not the other way around.
    • ES6 modules could be re-packaged by standard tools like webpack, rollup back to CJS or UMD.
    • libraries using another ES6 modules have to be also ES6 module (unless they re-pack with tools above).
  • Node.js 12 doesn't support it, but is end-of-life by 2022-04-30
  • After this PR will would still have way how to produce CommonJS, but is it worth supporting it ?

Changes in this PR

  • switched dotnet.js to be ES6 module by making <WasmEnableES6> default true
  • updated all samples
  • updated functional tests
  • updated debugger tests
  • updated test-main to
  • EXPORT_ES6=1 should not be in the emcc-default.rsp because it could not be removed by workload re-link when <WasmEnableES6> == false.
Author: pavelsavara
Assignees: pavelsavara
Labels:

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

Milestone: 7.0.0

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

pavelsavara commented Jun 16, 2022

  • I fixed and tested samples:
    browser
    browser-bench
    browser-cjs
    browser-legacy
    browser-nextjs
    browser-profile
    browser-webpack
    console-node-cjs
    console-node-es6
    console-node-ts
    console-v8-cjs
    console-v8-es6
    node-webpack
    mbr\browser

  • unit tests:
    src/tests/FunctionalTests/WebAssembly/Browser/HotReload/
    src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig
    src/mono/wasm/debugger/DebuggerTestSuite

  • I tested that it works in Blazor after the change

  • I tested that debugger works in Blazor

  • all WBT work, I think

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

pavelsavara commented Jun 17, 2022

For the dotnet.worker.js I created separate issue. #70891
Until it's fixed, the work on threading may need <WasmEnableES6>false</WasmEnableES6> switch.
FYI @lambdageek

For the templates, I did just basics. I plan to do more work on it as part of #70892
@radical

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

pavelsavara and others added 3 commits June 23, 2022 22:09
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

/azp run runtime-wasm

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pavelsavara
Copy link
Member Author

The Not found: AOT: image 'async_main_with_args_Release_True' found. failure is #70704

@pavelsavara pavelsavara merged commit 50c3df7 into dotnet:main Jun 24, 2022
@pavelsavara pavelsavara deleted the wasm_switch_to_es6 branch July 14, 2022 20:46
@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants