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

@oxc-parser/binding-wasm32-wasi returns parsed program as string #9783

Closed
hi-ogawa opened this issue Mar 14, 2025 · 4 comments
Closed

@oxc-parser/binding-wasm32-wasi returns parsed program as string #9783

hi-ogawa opened this issue Mar 14, 2025 · 4 comments

Comments

@hi-ogawa
Copy link
Contributor

reproduction: https://stackblitz.com/github/hi-ogawa/reproductions/tree/main/oxc-wasi-vite?file=src%2Fmain.js
(Github repo https://github.com/hi-ogawa/reproductions/tree/main/oxc-wasi-vite)

I tested @oxc-parser/binding-wasm32-wasi on browser and ParseResult.program is returned as raw string.

const lib = await import("@oxc-parser/binding-wasm32-wasi/parser.wasi-browser.js");
const result = lib.parseSync("test.js", `let foo`);
const program = result.program;
console.log(typeof program)  // => 'string'
@Boshen
Copy link
Member

Boshen commented Mar 14, 2025

I totally forgot about this. I was just wondering why I haven't removed @oxc-parser/wasm yet.

Draft PR: #9630

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 15, 2025

Oh right, @oxc-parser/binding-wasm32-wasi returning string is probably expected, but oxc-parser needs a proper wrapper entrypoint for browser/vite usage.


Additional note: My vite sample app currently relies on some hack https://github.com/hi-ogawa/reproductions/blob/0ca5023420efe071b553e65e99b175a0905d9d85/oxc-wasi-vite/vite.config.ts#L17. This could be a vite bug and also this can be probably worked around on napi-rs generation. I'm going to check this from both side.

@hi-ogawa
Copy link
Contributor Author

hi-ogawa commented Mar 17, 2025

I was just wondering why I haven't removed @oxc-parser/wasm yet.

Currently napi-rs's browser output is not as bundler agnostic as @oxc-parser/wasm/web, so this can potentially block some from moving it to oxc-parser easily. I made an issue about this on napi-rs napi-rs/napi-rs#2517.

For example, https://github.com/sxzz/ast-explorer uses @oxc-parser/wasm/web directly from CDN and that's not possible out-of-the-box with napi-rs output (though probably it's still possible by patching the js output during build on our own).

@Boshen
Copy link
Member

Boshen commented Mar 19, 2025

For example, https://github.com/sxzz/ast-explorer uses @oxc-parser/wasm/web directly from CDN and that's not possible out-of-the-box with napi-rs output (though probably it's still possible by patching the js output during build on our own).

Sad to say that using from CDN is no longer supported :-(

@Boshen Boshen closed this as completed Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants