Skip to content

[Bug]: Panic occurred at runtime: " should an valid regexp" #10889

Open
@mt51

Description

@mt51

System Info

System:
OS: macOS 15.5
CPU: (11) arm64 Apple M3 Pro
Memory: 109.61 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v18.17.0/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
pnpm: 9.15.3 - ~/.nvm/versions/node/v18.17.0/bin/pnpm
Watchman: 2025.04.28.00 - /usr/local/bin/watchman
Browsers:
Chrome: 138.0.7204.93
Safari: 18.5
npmPackages:
@rspack/cli: ^1.4.2 => 1.4.2
@rspack/core: ^1.4.2 => 1.4.2
@rspack/plugin-react-refresh: ^1.4.3 => 1.4.3

Details

I'm using rspack to build my React project, but the build fails due to a regex used in one of the third-party component. And I created an empty project with npm create rspack@latest , and the same issue occurs when using the following regex.

Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues
Message: should an valid regexp: Syntax(

regex parse error:
    [-/\\^$*+?.()|[\]{}]
    ^^
error: unclosed character class

)
Location: crates/rspack_plugin_javascript/src/parser_plugin/initialize_evaluating.rs:228

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.

Reproduce link

No response

Reproduce Steps

1、npm create rspack@latest
2、add the following code in main.tsx

 const foo = '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'.replace(
    /[-/\\^$*+?.()|[\]{}]/g,
    '\\$&'
  );

3、npm run dev

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions