Skip to content

Comments

fix(rolldown_plugin_replace): avoid crashing with invalid delimiters#7621

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-22-fix_rolldown_plugin_replace_avoid_crashing_with_invalid_delimiters
Dec 22, 2025
Merged

fix(rolldown_plugin_replace): avoid crashing with invalid delimiters#7621
graphite-app[bot] merged 1 commit intomainfrom
12-22-fix_rolldown_plugin_replace_avoid_crashing_with_invalid_delimiters

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Dec 22, 2025

We shouldn't crash even if an error happened here.

Copy link
Member Author


How to use the Graphite Merge Queue

Add the label graphite: merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

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

@sapphi-red sapphi-red marked this pull request as ready for review December 22, 2025 06:00
Copilot AI review requested due to automatic review settings December 22, 2025 06:00
@netlify
Copy link

netlify bot commented Dec 22, 2025

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 4fd7da9
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6948de5f1037da00083505dd

@netlify
Copy link

netlify bot commented Dec 22, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 73c6a54
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6948e7fcf7046b0008c69d32
😎 Deploy Preview https://deploy-preview-7621--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents crashes when invalid delimiters are provided to the replace plugin by making the plugin constructor return a Result type instead of panicking.

Key Changes

  • Modified ReplacePlugin::new() and ReplacePlugin::with_options() to return Result<Self, anyhow::Error> instead of Self
  • Changed regex creation with custom delimiters from .unwrap() to ? for proper error propagation
  • Added test coverage for the error case with invalid delimiters

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/rolldown_plugin_replace/src/plugin.rs Changed constructor methods to return Result and use ? for regex error handling
crates/rolldown_plugin_replace/Cargo.toml Added anyhow dependency for Result type
crates/rolldown_binding/src/options/plugin/binding_builtin_plugin.rs Updated binding to propagate errors from plugin construction
packages/rolldown/tests/builtin-plugin/replace.test.ts Added test case verifying error is thrown for invalid delimiters
crates/rolldown_plugin_replace/tests/form/*/mod.rs Updated all Rust test files to handle Result with .unwrap()
Cargo.lock Updated with anyhow dependency for rolldown_plugin_replace

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

Benchmarks Rust

  • target: main(d4f0b36)
  • pr: 12-22-fix_rolldown_plugin_replace_avoid_crashing_with_invalid_delimiters(73c6a54)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     60.5±0.97ms        ? ?/sec    1.02     61.7±1.09ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     67.1±1.15ms        ? ?/sec    1.01     67.5±1.15ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    104.7±1.64ms        ? ?/sec    1.01    106.2±1.50ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    117.0±2.39ms        ? ?/sec    1.01    117.9±1.20ms        ? ?/sec
bundle/bundle@threejs                                        1.00     38.4±0.90ms        ? ?/sec    1.00     38.6±0.46ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     42.2±0.97ms        ? ?/sec    1.01     42.7±0.93ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    387.8±4.28ms        ? ?/sec    1.00    386.6±4.36ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    449.4±5.88ms        ? ?/sec    1.01   455.0±10.17ms        ? ?/sec
scan/scan@rome_ts                                            1.00     83.7±2.65ms        ? ?/sec    1.01     84.5±1.73ms        ? ?/sec
scan/scan@threejs                                            1.00     28.2±0.36ms        ? ?/sec    1.01     28.4±0.46ms        ? ?/sec
scan/scan@threejs10x                                         1.00    291.8±3.73ms        ? ?/sec    1.01    294.9±3.82ms        ? ?/sec

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 22, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-22-fix_rolldown_plugin_replace_avoid_crashing_with_invalid_delimiters branch from ac8ca19 to 73c6a54 Compare December 22, 2025 06:40
@graphite-app graphite-app bot merged commit 73c6a54 into main Dec 22, 2025
35 checks passed
@graphite-app graphite-app bot deleted the 12-22-fix_rolldown_plugin_replace_avoid_crashing_with_invalid_delimiters branch December 22, 2025 06:51
This was referenced Dec 24, 2025
shulaoda added a commit that referenced this pull request Dec 24, 2025
## [1.0.0-beta.57] - 2025-12-24

✨ TypeScript Project References Support
- Rolldown now supports TypeScript project references when manually specifying a `tsconfig`
- See more details: https://rolldown.rs/options/tsconfig

💥 Rename `__export` to `__exportAll`
- Update `rolldown-plugin-dts` to the latest version for compatibility

### 💥 BREAKING CHANGES

- tsconfig: enable project references support in manual mode (#7545) by @shulaoda

### 🚀 Features

- add `CANNOT_CALL_NAMESPACE` warning (#7636) by @sapphi-red
- add import path for unresolved import diagnostics (#7625) by @sapphi-red
- optimize dynamic entry facade chunks by merging with common chunks when they are captured by common chunks (#7486) by @IWANABETHATGUY

### 🐛 Bug Fixes

- rename `__export` to `__exportAll` to be compatible with `cjs-module-lexer` (#7640) by @IWANABETHATGUY
- strip UTF-8 BOM when using text loader (#7635) by @sapphi-red
- rolldown_plugin_replace: avoid crashing with invalid delimiters (#7621) by @sapphi-red

### 🚜 Refactor

- export all filter functions (#7622) by @sxzz
- allow multiple help messages in diagnostics (#7624) by @sapphi-red

### 📚 Documentation

- add README.md to packages/rolldown (#7556) by @Copilot

### ⚡ Performance

- use fsevents on macOS for file watching (#7596) by @sapphi-red

### 🧪 Testing

- handle re-exports of external modules in CJS format (#7641) by @IWANABETHATGUY
- update integration to use vite's rolldown-canary branch (#7633) by @shulaoda

### ⚙️ Miscellaneous Tasks

- docs: fix Netlify ignore condition to detect docs changes across all PR commits (#7637) by @Copilot
- deps: update rollup submodule for tests to v4.54.0 (#7630) by @sapphi-red
- skip benchmarks for PRs with 'graphite: merge-when-ready' label (#7631) by @Boshen
- deps: update esbuild for tests to 0.27.2 (#7629) by @sapphi-red
- fix "update-test-dependencies" workflow (#7628) by @sapphi-red
- deps: update test262 submodule for tests (#7626) by @sapphi-red
- deps: update dependency oxlint to v1.35.0 (#7623) by @renovate[bot]

Co-authored-by: shulaoda <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants