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

Publish wasm #301

Closed
Boshen opened this issue Apr 20, 2023 · 15 comments
Closed

Publish wasm #301

Boshen opened this issue Apr 20, 2023 · 15 comments
Assignees

Comments

@Boshen
Copy link
Member

Boshen commented Apr 20, 2023

No description provided.

@Boshen Boshen self-assigned this Apr 20, 2023
@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2023
@sxzz
Copy link

sxzz commented Oct 10, 2023

Hi, I would like to know if there is a reason to close this issue. Are there any plans to release wasm version?

@Boshen
Copy link
Member Author

Boshen commented Oct 10, 2023

Hi, I would like to know if there is a reason to close this issue. Are there any plans to release wasm version?

I haven't found the time to properly maintain the wasm version. What's your usecase?

@sxzz
Copy link

sxzz commented Oct 10, 2023

I'd like to add Oxc parser to my AST Explorer

@Boshen Boshen reopened this Oct 10, 2023
@0xdevalias
Copy link

0xdevalias commented Dec 1, 2023

I noticed that the playground's package.json loads it as such:

Yet there doesn't seem to be a npm/wasm-web in the main repo?

Edit: Actually, I see now, it's the package.json has scripts to build it:

@0xdevalias
Copy link

0xdevalias commented Dec 1, 2023

What's your usecase?

@Boshen We were also exploring whether it would be a suitable parser in wakaru (cc // @pionxzh):

I haven't found the time to properly maintain the wasm version

@Boshen Off the top of your head, what are the current issues with it that require further maintenance/etc? Do you consider it not up to date/usable/etc?

@Boshen
Copy link
Member Author

Boshen commented Dec 1, 2023

What's your usecase?

@Boshen We were also exploring whether it would be a suitable parser in wakaru (cc // @pionxzh):

I haven't found the time to properly maintain the wasm version

@Boshen Off the top of your head, what are the current issues with it that require further maintenance/etc? Do you consider it not up to date/usable/etc?

Things could work if you intend to write everything in Rust, otherwise it's not going to work on the JS side. We lack all the things you need on the JS side after looking at your requirements.

@pionxzh
Copy link

pionxzh commented Dec 1, 2023

We will need the wasm binding for js parser and the AST query and run them on JS side.

So the main blocker is that there is no enough resources and maintainers for wasm version?

@Boshen
Copy link
Member Author

Boshen commented Dec 1, 2023

We will need the wasm binding for js parser and the AST query and run them on JS side.

So the main blocker is that there is no enough resources and maintainers for wasm version?

AST query and run them on JS side

We don't have a AST visitor on the JS side.

So the main blocker is that there is no enough resources and maintainers for wasm version?

Kind of, it's gonna be a lot harder to maintain because there are currently no TypeScript types for the AST on the JS side.

@magic-akari
Copy link
Collaborator

We don't have a AST visitor on the JS side.

Is using a WASM plugin a good idea?

@Boshen
Copy link
Member Author

Boshen commented Dec 1, 2023

To be honest I'm still not sure whether the scope of this project should expand to supporting wasm and napi ...

@taosx
Copy link

taosx commented Jan 3, 2024

While I appreciate the effort to keep the scope focused, I believe the oxc ecosystem could benefit from supporting multiple use cases with its components. That way it would attract new contributors and potentially alleviate some of the maintenance burden. This would also be advantageous for the community, as it would eliminate the need to duplicate efforts in developing lexers, parsers, traversers, etc.

In my case, I'm working on rewriting some JS/TS, from both internal JS and external systems (over network). oxc came to mind as a potential solution.

@Boshen
Copy link
Member Author

Boshen commented Jan 30, 2024

Done! https://www.npmjs.com/package/@oxc-parser/wasm

I used wasm-pack build --target web for the build, probably need something like https://github.com/nshen/vite-plugin-wasm-pack to get it working with vite, otherwise vite will load the wasm file as a HTML file causing a CompileError: WebAssembly.instantiate(): expected magic word error.

@Boshen Boshen closed this as completed Jan 30, 2024
@sxzz
Copy link

sxzz commented Jan 30, 2024

Thanks for your excellent work! However, the usage of docs may be wrong.

parseSync(code, { filename: "test.ts" });
> Error: expected instance of ParserOptions

The parser options cannot be a plain object.


If we pass a class, there's an error once get/set value.

const parserOptions = new ParserOptions()
parserOptions.filename = options?.filename || 'foo.ts'
> Error: null pointer passed to rust

@Boshen
Copy link
Member Author

Boshen commented Jan 31, 2024

@sxzz I released @oxc-parser/wasm@0.0.4 and updated the README https://www.npmjs.com/package/@oxc-parser/wasm

wasm FFI is really confusing, I'm still unsure whether I fixed it or not, but "it works on my machine" at least.

@sxzz
Copy link

sxzz commented Jan 31, 2024

Great, it works now.

P.S. Oxc parser is already supported by my AST Explorer version.

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

6 participants