Skip to content

feat(rust): move string_wizard to the repo - #2572

Merged
hyfdev merged 1 commit into
mainfrom
11-03-feat_rust_move_string_wizard_to_the_repo
Nov 4, 2024
Merged

hyfdev merged 1 commit into
mainfrom
11-03-feat_rust_move_string_wizard_to_the_repo

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 3, 2024 •

Copy link
Copy Markdown
Member

Description

To have a quick development loop, it's better to move the string_wizard in the repo so we could modify it in time.

hyfdev commented Nov 3, 2024 •

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @hyf0 and the rest of your teammates on Graphite Graphite

@netlify

netlify Bot commented Nov 3, 2024 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit b3c1906
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/67284b8807ba050008945fef

@hyfdev
hyfdev marked this pull request as ready for review November 3, 2024 13:45
@hyfdev
hyfdev force-pushed the 11-03-feat_rust_move_string_wizard_to_the_repo branch from 8297982 to f8ad1f2 Compare November 3, 2024 13:49
@IWANABETHATGUY IWANABETHATGUY added the on hold: to be discussed Waiting for team to discuss this issue label Nov 3, 2024
@IWANABETHATGUY

Copy link
Copy Markdown
Member

I remember that you said that #1364 (comment), maybe we should discuss it in the meeting.

@github-actions

github-actions Bot commented Nov 3, 2024 •

Copy link
Copy Markdown
Contributor

Benchmarks Rust

  • target: main(4b1d7a7)
  • pr: 11-03-feat_rust_move_string_wizard_to_the_repo(b3c1906)
group                                                               pr                                     target
-----                                                               --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol                     1.02     62.9±1.26ms        ? ?/sec    1.00     61.7±1.52ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify              1.03     88.0±1.36ms        ? ?/sec    1.00     85.6±1.03ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify-sourcemap    1.01    104.0±2.56ms        ? ?/sec    1.00    103.1±1.73ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap           1.02     70.7±1.28ms        ? ?/sec    1.00     69.4±1.38ms        ? ?/sec
bundle/bundle@rome-ts                                               1.02    111.7±1.36ms        ? ?/sec    1.00    109.7±1.18ms        ? ?/sec
bundle/bundle@rome-ts-minify                                        1.06    230.5±7.72ms        ? ?/sec    1.00    218.3±9.05ms        ? ?/sec
bundle/bundle@rome-ts-minify-sourcemap                              1.01    260.3±8.00ms        ? ?/sec    1.00    257.5±3.60ms        ? ?/sec
bundle/bundle@rome-ts-sourcemap                                     1.01    125.5±2.76ms        ? ?/sec    1.00    124.0±1.07ms        ? ?/sec
bundle/bundle@threejs                                               1.00     38.0±0.80ms        ? ?/sec    1.00     37.9±1.53ms        ? ?/sec
bundle/bundle@threejs-minify                                        1.03    101.4±2.60ms        ? ?/sec    1.00     98.6±2.55ms        ? ?/sec
bundle/bundle@threejs-minify-sourcemap                              1.02    114.7±3.89ms        ? ?/sec    1.00    112.0±1.95ms        ? ?/sec
bundle/bundle@threejs-sourcemap                                     1.01     46.1±0.40ms        ? ?/sec    1.00     45.4±0.39ms        ? ?/sec
bundle/bundle@threejs10x                                            1.04    400.1±6.79ms        ? ?/sec    1.00    385.7±5.53ms        ? ?/sec
bundle/bundle@threejs10x-minify                                     1.02  1284.3±10.62ms        ? ?/sec    1.00  1258.8±15.52ms        ? ?/sec
bundle/bundle@threejs10x-minify-sourcemap                           1.00  1518.4±17.61ms        ? ?/sec    1.00  1513.6±14.00ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                                  1.02    464.1±5.41ms        ? ?/sec    1.00    453.9±6.57ms        ? ?/sec
remapping/remapping                                                 1.00     27.8±0.14ms        ? ?/sec    1.06     29.5±0.49ms        ? ?/sec
remapping/render-chunk-remapping                                    1.00     68.5±0.29ms        ? ?/sec    1.01     69.3±0.29ms        ? ?/sec
scan/scan@rome-ts                                                   1.01     89.3±1.05ms        ? ?/sec    1.00     88.2±1.77ms        ? ?/sec
scan/scan@threejs                                                   1.00     28.2±0.31ms        ? ?/sec    1.00     28.2±1.53ms        ? ?/sec
scan/scan@threejs10x                                                1.01    286.1±4.11ms        ? ?/sec    1.00    282.3±4.48ms        ? ?/sec

@hyfdev

hyfdev commented Nov 3, 2024 •

Copy link
Copy Markdown
Member Author

I remember that you said that #1364 (comment), maybe we should discuss it in the meeting.

Feel free to add this in discussion section.

hyfdev commented Nov 3, 2024

Copy link
Copy Markdown
Member Author

Merge activity

  • Nov 3, 10:15 AM EST: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..

@hyfdev
hyfdev force-pushed the 11-03-feat_rust_move_string_wizard_to_the_repo branch from f8ad1f2 to b3c1906 Compare November 4, 2024 04:20
@hyfdev
hyfdev added this pull request to the merge queue Nov 4, 2024
Merged via the queue into main with commit 2ace0eb Nov 4, 2024
@hyfdev
hyfdev deleted the 11-03-feat_rust_move_string_wizard_to_the_repo branch November 4, 2024 04:56
graphite-app Bot pushed a commit that referenced this pull request Oct 15, 2026
<!-- claude-projects-attribution: {"github_login":"Brooooooklyn"} -->
_Requested by **Brooklyn** · [project thread](https://claude.ai/code/project/chan_018s9RxRdtH424j2EhXdzV3N?thread=cmsg_018s9RxRdtH424j2EhXdzV3NQxbeR8Pt7qaqSQwoq9rEFo)_

<!-- routine:prune-tests:fold-rust-table-tests -->

Before: two Rust test modules were hand-unrolled lookup tables: 19 copy-pasted `dynamic_import_to_glob` tests, and three `relocate` tests that differed only in the target.

After: both are table-driven tests. Every row, comment and old test name is kept; the old name is the row label in the assertion message. Test code only: every hunk is inside a `#[cfg(test)] mod tests` block or under `tests/`.

Update after review: the two subset tests this PR first deleted (`source_utils` `test_contains_script_closing_tag_in_tagged_template` and `light_guess` `unknown_extensions`) are restored unchanged in e16c035, because they document that those cases are handled. The PR now only folds tables.

How: each row was defended by mutating product code with the most realistic regression only that row would catch, rebuilding, running, and reverting. Every row is the only guard for at least one mutation, so none was dropped, and evidence comments record that.

### Totals

| | Before | After |
|---|---|---|
| Files touched | – | 2 |
| Cases in the 2 touched test binaries | 67 | 48 |
| Cases deleted outright | – | 0 |
| Cases removed by folding (19 → 2 and 3 → 1, every row kept) | – | 19 |
| Net lines | – | −87 (+93 / −180) |
| Runtime saved (removed cases' summed duration) | – | ~0 s (every removed case reported `<0.000s>`) |

Whole suite at the merge-base could not be collected here (that needs the full workspace plus the NAPI binding). Counted instead: 522 `#[test]` / `#[tokio::test]` functions under `crates/`, plus fixture cases from 2,164 `_config.json` files (67 dot-prefixed, skipped); test262 and Vitest not counted.

### Per file

1. **`crates/rolldown_plugin_vite_dynamic_import_vars/src/dynamic_import_to_glob.rs`** (hand-unrolled lookup table, 19 → 2)
   - All 19 bodies were the same parse → `to_glob_pattern` → assert sequence (a port of `@rollup/plugin-dynamic-import-vars`). They become `converts_dynamic_import_expressions_to_globs` (16 rows) and `rejects_unsupported_dynamic_import_expressions` (3 rows).
   - M10–M13 each failed exactly one original test; after the fold the same mutations fail the folded test, and the message names the row.
2. **`crates/string_wizard/tests/magic_string.rs` › `relocate::refuses_to_move_a_selection_to_inside_itself{,2,3}`** (hand-unrolled lookup table, 3 → 1)
   - One loop over targets `[3, 4, 6]`. Each target alone guards one edge of `to >= start && to <= end` (M7, M8, M9), so all three are kept with an evidence comment. After the fold, M7, M8 and M9 all fail it.

### Kept after defense — do not re-nominate

- Every row of both `dynamic_import_to_glob` tables (M10 → `escapes_square_brackets`, M11 → `data_uri`, M12 → `throws_…non_add_operator`, M13 → `throws_…file_extension`).
- All three `refuses_to_move…` targets (3, 4, 6).
- `source_utils` `test_contains_script_closing_tag_in_tagged_template` and `_multiple_occurrences`, and `light_guess` `unknown_extensions` (kept on review: they document handled cases).

### Case counts

| File | Before | After | Delta | Expected delta |
|---|---|---|---|---|
| `dynamic_import_to_glob.rs` (crate lib binary) | 19 | 2 | −17 | −17 |
| `string_wizard/tests/magic_string.rs` | 48 | 46 | −2 | −2 |
| **Total** | **67** | **48** | **−19** | **−19** |

`rolldown_utils` (68) and `rolldown_ecmascript_utils` (18) lib binaries are back to their merge-base counts and pass. **0 new failures**, no pre-existing failures.

### Mutations

Each was applied alone, rebuilt, run, then reverted (`git status` clean afterwards).

| # | Location | Change | Failed before | Failed after |
|---|---|---|---|---|
| M7 | `crates/string_wizard/src/magic_string/movement.rs:35` | `to >= start` → `to > start` | `refuses…itself`, `zero_width_relocate_to_its_own_position_still_errors` | folded test, `zero_width…` |
| M8 | `movement.rs:35` | `to <= end` → `to < end` | `refuses…itself3`, `zero_width…` | folded test, `zero_width…` |
| M9 | `movement.rs:35` | `to == start \|\| to == end` | `refuses…itself2` | folded test |
| M10 | `dynamic_import_to_glob.rs:42` | stop escaping `[` and `]` | `escapes_square_brackets` | `converts_…` |
| M11 | `dynamic_import_to_glob.rs:9` | drop `data:` from `IGNORED_PROTOCOLS` | `data_uri` | `converts_…` |
| M12 | `dynamic_import_to_glob.rs:107` | accept any binary operator | `throws_…non_add_operator` | `rejects_…` |
| M13 | `dynamic_import_to_glob.rs:32` | drop the extension check | `throws_…file_extension` | `rejects_…` |
| M14 | `dynamic_import_to_glob.rs:89` | `arguments.is_empty()` → `len() < 2` | nothing (pre-existing gap, not touched here) | – |

M14 shows single-argument `.concat()` (e.g. `'./foo/'.concat(bar)`) is untested; this PR does not change that.

### What ran and what did not

- Ran, at origin/main (c9a8cda) and after: `cargo test --locked` for `rolldown_plugin_vite_dynamic_import_vars`, `string_wizard`, `rolldown_utils` and `rolldown_ecmascript_utils` (per-test durations via `--report-time`); `cargo clippy --locked -p <those crates> --all-targets -- --deny warnings`; `cargo fmt --all --check`; `git diff --check`. All clean, including after the restore commit.
- Not run: the full `just test-rust` (bundler fixtures and test262), the Node/Vitest suites (`just test-node`, needs the binding), `just lint-repo` / `just lint-node` (no non-Rust files changed).

### Excluded pull requests

All 162 open PRs on 2026-10-14 were fetched and every file they touch (1,889 files) was skipped; neither file here is touched by any of them.

### Age check (cutoff: 30 days, 2026-09-14)

| Test(s) | First added |
|---|---|
| `dynamic_import_to_glob` tests | 2024-08-01 (`40cf58b9b`, #1732; moved in `9cb5be8a4`, #7068) |
| `refuses_to_move…` tests | 2024-11-04 (`2ace0ebac`, #2572) |

None is in a permission, security or entitlement suite, and neither was added for a bug.

To revert: `git revert e16c035 6a233d9`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01PxVsmvB9xfZKfVnUonY8kf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage on hold: to be discussed Waiting for team to discuss this issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants