-
-
Couldn't load subscription status.
- Fork 32
Remove regex dependency for faster runtime, and compile #55
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the tokenization was used in our old "find function name" heuristic which we are replacing with properly parsing the minified source in https://github.com/getsentry/js-source-scopes.
I would be very happy to just remove all that logic in a new breaking release if @mitsuhiko agrees.
|
If we end up killing the old function name heuristic (which for what it’s worth I’m absolutely fine with) we probably at least want to point people towards an example of how this is best done instead. We could potentially even have a highly inefficient way here to optionally (behind a feature flag) use the scope crate. |
|
Yeah the use of this identifier stuff is purely within |
|
yes, IMO this crate should be limited in scope to only sourcemaps. extracting function names (scope information) is a different concern. I think we can eventually remove that stuff in a breaking release. |
My motivations here are to learn about, and ideally improve the performance of, rust-based frontend tooling.
Behaviour Changes
The regex crate is used in two separate parts of this lib, in both cases I have ended up making behavioural changes - which I can undo to be more compatible if desired.
filename: &str->index: usizeparsing in code managing compressed source bundlesis_valid_javascript_identifierno longer returns true for invalid identifiers with valid prefixes (see commented test cases)unicode-id
I went ahead and used unicode-id as I stole the
is_valid_startandis_valid_continuefunctions from swc@5a23949f swc_ecma_ast/src/ident.rs#L180 and unicode-id is what swc uses.Measurements
cargo build --release --examples --offlinereadexample sizerewriteexample size