-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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] Node Support #54554
Closed
Closed
[WASM] Node Support #54554
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ed to be manually updated to be in the globalThis object
…he use strict PR)
…wever now native code for the tests fails
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. |
Closing PR as we decided to use the flag instead of |
ghost
locked as resolved and limited conversation to collaborators
Jul 23, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WORK IN PROGRESS
This PR adds the missing pieces for NodeJS support to MONO WASM!
How does it work
The main differences between this and running the console sample regularly for v8 is that dotnet.js is modularized so we use
require
to load it. We now also have apackage.json
andpackage-lock.json
files as well as thenode_modules
folder. Besides that, most changes to the code were related to various NodeJS related nuances such as the scoping ofthis
but are ignored by the browser.How to run locally
-os
flag (ex:./build.cmd mono -os Node -c Debug
) (make sure to have libs already built as browser. For some reason it fails when building libs for node but I am working on it). Note however that although this will build, since the libs are built for another target, they won't be reachable while running. However, builds will still succeed so generated code inspection is possible./p:TargetOS=Node
(ex:./dotnet.cmd publish /p:TargetArchitecture=wasm /p:TargetOS=Node Wasm.Console.Sample.csproj -c Debug
).\src\mono\sample\wasm\console\bin\{CONFIGURATION}\AppBundle
folder and run./run-node.cmd
orrun-node.sh
depending on your OS. You should see the regular console sample output. Note that you can also use the NPM test task to achieve the same result (i.e.npm test
).See the open question sections for a link to branch that successfully builds and runs in node.
TODO LIST
node --trace-warnings runtime.js --run Wasm.Console.Sample.dll
package.json
file and runnpm install
on itModularize
flag based on build targetTargetOS
for NodeJS[WASM] Converted mono-config.js to mono-config.json #53606, [WASM] Enabled strict mode on all JS files #54011, [WASM] Normalize runtime-test.js #54281) to cleanup the codeOpen Questions
-os Node
) or should it be an additional flag/parameter that is passed while building for Browser (i.e./p:ForNode=True
)? To see a working copy of the flag option see my other branch wasm-node-via-extra-flag