Commit Graph

10 Commits

Author SHA1 Message Date
Dunqing 79e6d775fb fix(minifier): preserve RegExp feature detection (#24712)
> **PR stack (3 of 3)**
> 1. #24739
> 2. #24742
> 3. **#24712 (this PR)**
>
> Review #24739 and #24742 first. This PR is based on #24742, so GitHub shows only the RegExp behavior change.

Stacked on #24742, which exposes strict engine-target capabilities to side-effect analysis.

RegExp constructor calls used for engine feature detection were removed by DCE when their pattern was valid according to the current Oxc RegExp parser. A pattern can be valid at build time but still throw a `SyntaxError` on the configured runtime, so removing the call changes the result of surrounding `try`/`catch` checks.

RegExp purity now requires both syntactic validity and support from every configured target. Consumers without concrete targets remain conservative, while an explicit target allows the minifier to remove constructors known to be safe for those engines.

Target-independent flag validation and pattern compatibility checks now live in `oxc_regular_expression`; side-effect analysis only maps target support to unsupported flags and patterns. String patterns, modern flags, named groups, property escapes, lookbehind, modifiers, invalid flags, and lone-surrogate strings are covered. A RegExp literal with replacement flags is removable only when the target supports both those flags and the dedicated `ES2015RegExpConstructorCanAlterFlags` compatibility feature. Explicitly targeting `esnext` opts into current features.

## Example

Input:

```js
export function supportsUnicodeRegExp() {
  try {
    new RegExp("\\p{Ll}", "u");
    return true;
  } catch {
    return false;
  }
}
```

Before:

```js
export function supportsUnicodeRegExp() {
  try {
    return true;
  } catch {
    return false;
  }
}
```

After:

```js
export function supportsUnicodeRegExp() {
  try {
    new RegExp("\\p{Ll}", "u");
    return true;
  } catch {
    return false;
  }
}
```

Verified with all `oxc_regular_expression`, `oxc_compat`, `oxc_ecmascript`, and `oxc_minifier` tests; the no-feature/`side_effects`/`constant_evaluation` `oxc_ecmascript` matrix; affected-crate clippy; formatting; and diff checks.

Fixes rolldown/rolldown#10279.

Implemented with AI assistance (OpenAI Codex and Claude). The contributor remains responsible for reviewing, understanding, and submitting these changes under the repository AI usage policy.
2026-07-21 14:15:24 +00:00
Boshen c16082c448 feat(tasks/compat_data): integrate node-compat-table (#16831)
Node version changes:

* TemplateLiterals: 8.10 -> 10.0
* Classes: 5.0 -> 6.0
* ObjectSuper: 5.0 -> 6.0
* Spread: 5.0 -> 6.0
* TypeofSymbol: 0.12 -> 4.0
* OptionalChaining: 16.9 -> 16.1
* PrivatePropertyInObject: 16.9 -> 16.4

fixes #11941
fixes https://github.com/rolldown/rolldown/issues/7293
2025-12-18 10:21:48 +00:00
Boshen 523a30a016 style(all): apply oxfmt default options (#16091)
Embrace the defaults!

---------

Co-authored-by: Yuji Sugiura <y.sugiura.0316@gmail.com>
2025-11-25 15:56:24 +09:00
leaysgur a8e5181ab7 chore(infra): dogfooding oxfmt (#14979)
Fixes #14803

- Added `oxfmt` and `oxfmtrc.jsonc`
- Remove `dprint` plugin and useless ignore paths
- Apply `dprint` again
- Apply `oxfmt`
2025-10-28 01:16:46 +00:00
Boshen 588acd55b4 feat(transformer): add ES2026 target for explicit resource management (#14330)
## Summary

fixes #12796

* Added target `ES2026`
* Moves the explicit resource management feature from proposals to ES2026, as it is now a finalized ECMAScript 2026 feature.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2025-10-05 07:12:53 +00:00
Song Gao cf3415b0e4 chore(doc): replace main/master to tag/commit to make the url always accessible (#7298) 2024-11-16 21:00:30 +08:00
Boshen b57d00d6fb fix(tasks/compat_data): fix misplaced features (#7284)
closes #7279
2024-11-14 16:36:16 +00:00
Boshen 22898c855a feat(transformer): warn BigInt when targeting < ES2020 (#7184)
closes #5822
2024-11-07 08:29:03 +00:00
Boshen a579011e37 feat(transformer): add features ES2018NamedCapturingGroupsRegex and ES2018LookbehindRegex (#7182) 2024-11-07 07:39:33 +00:00
Boshen ad3a2f518e feat(tasks/compat_data): generate our own compat table (#7176) 2024-11-07 07:39:33 +00:00