-
-
Notifications
You must be signed in to change notification settings - Fork 619
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
feat: support wasm #9134
base: main
Are you sure you want to change the base?
feat: support wasm #9134
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
CodSpeed Performance ReportMerging #9134 will not alter performanceComparing 🎉 Hooray!
|
If Rust API is good enough, maybe we don't need to ship the js binding parts to browser, I'm not sure whether we need a light weight implementation or a full implementation, @h-a-n-a @chenjiahan what do you think? |
seems unnecessary cause the ntaivefs is used for native OS, we can just ship a browser_fs for browser side which even don't need std::fs |
This is necessary because:
So I just call |
I mean rspack/crates/rspack_fs/src/native_fs.rs Line 19 in 5a6ed31
I'm not sure which way is better |
not sure rspack_futures can be replaced with with tokio_stream and wether tokio_stream can be compatible with wasm
I agree persistent cache maybe not needed for browser at all if it's hard to be compatible |
@CPunisher do you plan to finish all tasks in this PR or separated into multi PRs |
I'm not sure whether |
I'm also considering, but I think both are ok. Because this feature consist of many small changes, it's very easy to separate it. But it seems that incomplete changes are useless. For example, incomplete stage 1 is not compilable and incomplete the whole feature is not avaliable for users. So what's your suggestion? |
that depends on how long would it take, I suggest when you can successfully compile rspack to wasm target(no need to actually run in browser) we can merge it first and introduce wasm target in CI so we wouldn't introduce wasm incompatible crate in the future. |
It would be great if a full implementation could be provided, which allows us to run Rsbuild on Stackblitz. |
Related: #4550
By following rolldown/rolldown#467, I have made an ugly MVP to run rspack in browser environment.
Since I find that support for wasm is a feature that involves lots of small changes in current codebase, I'd like to list all the known steps in the following tasklist and divide the process into 3 stages:
.wasm
files bynapi build
. In this stage we mostly add#[cfg(not(target_family = "wasm"))]
to distinguish platforms.node_binding
(wasm) in the browser. After this we can run some basic examples in the browser.@rspack/core
in the browser. Since rspack interface exposed bynode_binding
is missing lots of features, such as option nomalization, essential plugins, loader context, which make it hard to directly use, we also need to make this part avaliable. Actually I have not explored this stage in the MVP.Compile rspack to wasm target
async-scoped
depends on tokio multi-thread rt.Browsers::load_browserslist
parcel-bundler/lightningcss#895Run rspack node_binding in the browser
napi::bindgen_prelude::spawn
doesn't execute in wasm: change it tonapi::bindgen_prelude::block_on
in a new thread.Buffer
is unavailable in browser, see: https://emnapi-docs.vercel.app/reference/list.html#buffer-relatedtokio::spawn
may not execute at last@napi/wasm-runtime
. For example,read_dir
normally returns a list of entry object but we can't call any function in the object because it is transfered by serialization and deserialization.Run @rspack/core in the browser