Skip to content

native_wasm_bindgen feature to use native JS regexp & reduce WASM bundle size #944

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

Closed
samdenty opened this issue Jan 8, 2023 · 3 comments

Comments

@samdenty
Copy link

samdenty commented Jan 8, 2023

Describe your feature request

It would be nice if there was a native_wasm_bindgen feature that made this crate use the JS RegExp constructor via wasm_bindgen, instead of shipping a whole regex library to the browser.

I saw sometime simliar mentioned here - #913 (comment)

Would you be willing to accept a new feature on this crate that accomplished this? Or is it out of scope @BurntSushi

@samdenty samdenty changed the title native-wasm-bindgen feature to use native JS regexp & reduce WASM bundle size native_wasm_bindgen feature to use native JS regexp & reduce WASM bundle size Jan 8, 2023
@BurntSushi
Copy link
Member

Sorry, just to make sure I understand here, you're suggesting adding a feature that completely disables the regex engine and instead just defers to JS regexes but with the same API as this crate?

That's a total non-starter. It's not even just a matter of scope, but it's just completely inappropriate as far as I can tell. JS regexes have very different semantics than the regex crate. There's a lot of overlap, but also a fair bit of difference as well. Chief among them is that you cannot guarantee that they run in linear time.

I think it would be better if you popped up a level and focused on the actual problem at hand. Probably the solution to that problem is outside of this crate. Perhaps making a wrapping API that does the switching for you automatically. Or something else. I don't know.

@BurntSushi
Copy link
Member

I saw this mentioned here - #913 (comment), but it doesn't look like it got far.

Also, I don't think what you're proposing was mentioned in that comment. That comment is talking about const regexes. I don't think any point in that conversation suggested replacing the regex crate internals with the actual JS regexp engine in any case.

@samdenty
Copy link
Author

samdenty commented Jan 8, 2023

I'll create a separate crate then with the same API as this regex crate, using js regexes then.

@samdenty samdenty closed this as completed Jan 8, 2023
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