-
Notifications
You must be signed in to change notification settings - Fork 458
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
Improve WASI support #898
Comments
I can build successfully on Windows by manually make following changes:
import { defineConfig } from 'rolldown'
export default defineConfig({
input: './index.js',
+ // set posix path for WASI, not native platform path
+ // map to C:\\Users\\toyobayashi\\Projects\\rolldown\\examples\\basic-vue
+ cwd: '/Users/toyobayashi/Projects/rolldown/examples/basic-vue',
resolve: {
// This needs to be explicitly set for now because oxc resolver doesn't
// assume default exports conditions. Rolldown will ship with a default that
// aligns with Vite in the future.
conditionNames: ['import'],
},
})
const __wasi = new __nodeWASI({
version: 'preview1',
env: process.env,
preopens: {
- '/': '/'
+ '/': 'C:\\'
}
})
const handler = new MessageHandler({
onLoad({ wasmModule, wasmMemory }) {
const wasi = new WASI({
version: 'preview1',
env: process.env,
preopens: {
- '/': '/'
+ '/': 'C:\\',
},
}); |
@toyobayashi Thanks. This should be a windows-specific problem. I guess we should give a sensible default value for windows. |
Just now I also built basic example successfully on macOS without modify anything (b5b06bf). Just ensure the Update: oh no! When set |
We observed this issue too, and this line is also strange: rolldown/crates/rolldown_binding/src/bundler.rs Lines 35 to 37 in 7b64957
|
Can confirm there are some compiler bugs in Rust. Switch to |
Sorry to say that #975 breaks building basic-example in unbuntu. I can't figure out why with the changed code should not affect wasm. |
So I was able to repair the symlink stuff for MacOS by using the same canonicalize logic that oxc-resolver uses in their fs implementation. It seems that dunce uses // modified from oxc-project/oxc-resolver/src/file_system.rs
#[cfg(not(target_family = "wasm"))]
{
dunce::canonicalize(path)
}
#[cfg(target_family = "wasm")]
{
let meta = std::fs::symlink_metadata(path)?;
if meta.file_type().is_symlink() {
let link = std::fs::read_link(path)?;
let mut path_buf = path.to_path_buf();
path_buf.pop();
for segment in link.iter() {
match segment.to_str() {
Some("..") => {
path_buf.pop();
}
Some(".") | None => {}
Some(seg) => {
// Need to trim the extra \0 introduces by rust std rust-lang/rust#123727
path_buf.push(seg.trim_end_matches('\0'));
}
}
}
Ok(path_buf)
} else {
Ok(path.to_path_buf())
}
} No luck yet on tracking down the need for RD_LOG to get WASI builds to run. I did notice I get a different panic if I force WASM to init the tracing-subscriber by skipping the short-circuit return None in the tracing subscriber.
|
I like the idea of rolldown and wanted to contribute to this issue by creating a $200 bounty on Opire. It's my way of being able to contribute my grain of sand since I don't have the knowledge to be able to help in any other way. |
@nabby27 thanks for the interest and support - for now we are focusing on the feature side since this will require some dedicated effort to be resolved. We will revisit this once we are close to feature complete. |
@yyx990803 Sure, don't worry, I fully understand that the main team is focused on other more important tasks, that's why I created this bounty in case any other developer wants to join the community and solve this issue. |
This is a followed up of #832.
With the hard work of @Brooooooklyn, we now are ok to compile to wasi successfully and run wasi rolldown successfully in some simple cases.
However, there are still a lot of hard and wired problems to be solved.
As #894 showed
Unsupported Operation
error was throwed in rust even in the basic example caseOther problems
rolldown/.github/workflows/reusable-wasi-test.yml
Lines 43 to 47 in 7b64957
rolldown/crates/rolldown_binding/src/bundler.rs
Lines 35 to 37 in 7b64957
fs
polyfill crosses the main thread/ web worker is usingAtomic.wait
, anystd::fs
operations within theasync fn
will blocktokio
current_thread
runtime forever.The text was updated successfully, but these errors were encountered: