feat: support rspack wasi with node.js#9872
Merged
h-a-n-a merged 6 commits intoweb-infra-dev:mainfrom Apr 3, 2025
Merged
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
CodSpeed Performance ReportMerging #9872 will not alter performanceComparing Summary
|
h-a-n-a
approved these changes
Apr 3, 2025
Contributor
|
Thanks! |
hardfist
reviewed
Apr 3, 2025
| let path = dunce::canonicalize(path)?; | ||
| Ok(path.assert_utf8()) | ||
| // Comes from rspack_resolver | ||
| use std::path::Component; |
Contributor
There was a problem hiding this comment.
is this wasi only and should be put into cfg_if!?
Contributor
Author
There was a problem hiding this comment.
hardfist
reviewed
Apr 3, 2025
| .get_named_property::<JsObject>("prototype")? | ||
| .get_named_property::<Function>("toString")?; | ||
| .get_named_property_unchecked::<JsObject>("prototype")? | ||
| .get_named_property_unchecked::<Function>("toString")?; |
Contributor
Author
There was a problem hiding this comment.
I'm not sure but from my experiments:
.get_named_property_unchecked::<JsObject>("prototype")returns anExternalin wasm rather thanJsObject.- But
_uncheckedin.get_named_property_unchecked::<Function>("toString")?is actually needless.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Here are some final works to make rspack wasi available in node.js. Now you can run rspack wasi on rspack/rolldown benchmark (remember to use
NAPI_RS_FORCE_WASI=1):globalThis.Object.prototypeis anExternalother thanJsObject.canonicalizefromrspack_resolverbecausefs::canonicalizedoesn't support wasm.tokio::spawnblocking the program.BUT PAY ATTENTION:
build:cli:dev:wasm, you will get random memory errors. Currently I don't figure it out yet.shutdownAsyncRuntimein js side because rayon thread pool also blocks the program. I'd like to handle these two cases in next pr.Checklist