Closed willstott101 closed 1 year ago
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 get_original_function_name
. Trying to use js-source-scopes within here might be a bit confusing though, as that crate appears to depend on this one...
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: usize
parsing in code managing compressed source bundlesis_valid_javascript_identifier
no 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_start
andis_valid_continue
functions from swc@5a23949f swc_ecma_ast/src/ident.rs#L180 and unicode-id is what swc uses.Measurements
cargo build --release --examples --offline
read
example sizerewrite
example size