Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions crates/oxc_transformer/src/options/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,8 @@ impl TryFrom<BabelEnvOptions> for EnvOptions {
unicode_property_escapes: o.can_enable(ES2018UnicodePropertyRegex),
dot_all_flag: o.can_enable(ES2018DotallRegex),
named_capture_groups: o.can_enable(ES2018NamedCapturingGroupsRegex),
// FIXME
look_behind_assertions: false, // o.can_enable("esbuild-regexp-lookbehind-assertions"),
// FIXME
match_indices: false, // o.can_enable("esbuild-regexp-match-indices"),
look_behind_assertions: o.can_enable(ES2018LookbehindRegex),
match_indices: o.can_enable(ES2022MatchIndicesRegex),
set_notation: o.can_enable(ES2024UnicodeSetsRegex),
},
es2015: ES2015Options {
Expand Down
34 changes: 34 additions & 0 deletions crates/oxc_transformer/src/options/es_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum ESFeature {
ES2018NamedCapturingGroupsRegex,
ES2018UnicodePropertyRegex,
ES2018DotallRegex,
ES2018LookbehindRegex,
ES2018ObjectRestSpread,
ES2018AsyncGeneratorFunctions,
ES2018OptionalCatchBinding,
Expand All @@ -47,6 +48,7 @@ pub enum ESFeature {
ES2022ClassProperties,
ES2022PrivatePropertyInObject,
ES2022ClassStaticBlock,
ES2022MatchIndicesRegex,
ES2024UnicodeSetsRegex,
ES2025RegexpModifiers,
ES2025DuplicateNamedCapturingGroupsRegex,
Expand Down Expand Up @@ -539,6 +541,22 @@ pub fn features() -> &'static FxHashMap<ESFeature, EngineTargets> {
(Edge, Version(79u32, 0u32, 0u32)),
])),
),
(
ES2018LookbehindRegex,
EngineTargets::new(FxHashMap::from_iter([
(Chrome, Version(62u32, 0u32, 0u32)),
(Safari, Version(16u32, 4u32, 0u32)),
(OperaMobile, Version(46u32, 0u32, 0u32)),
(Samsung, Version(8u32, 0u32, 0u32)),
(Node, Version(8u32, 10u32, 0u32)),
(Firefox, Version(78u32, 0u32, 0u32)),
(Deno, Version(1u32, 0u32, 0u32)),
(Electron, Version(3u32, 0u32, 0u32)),
(Opera, Version(49u32, 0u32, 0u32)),
(Ios, Version(16u32, 4u32, 0u32)),
(Edge, Version(79u32, 0u32, 0u32)),
])),
),
(
ES2018ObjectRestSpread,
EngineTargets::new(FxHashMap::from_iter([
Expand Down Expand Up @@ -733,6 +751,22 @@ pub fn features() -> &'static FxHashMap<ESFeature, EngineTargets> {
(Edge, Version(94u32, 0u32, 0u32)),
])),
),
(
ES2022MatchIndicesRegex,
EngineTargets::new(FxHashMap::from_iter([
(Chrome, Version(90u32, 0u32, 0u32)),
(Safari, Version(15u32, 0u32, 0u32)),
(OperaMobile, Version(64u32, 0u32, 0u32)),
(Samsung, Version(15u32, 0u32, 0u32)),
(Node, Version(16u32, 0u32, 0u32)),
(Firefox, Version(91u32, 0u32, 0u32)),
(Deno, Version(1u32, 8u32, 0u32)),
(Electron, Version(13u32, 0u32, 0u32)),
(Opera, Version(76u32, 0u32, 0u32)),
(Ios, Version(15u32, 0u32, 0u32)),
(Edge, Version(90u32, 0u32, 0u32)),
])),
),
(
ES2024UnicodeSetsRegex,
EngineTargets::new(FxHashMap::from_iter([
Expand Down
11 changes: 11 additions & 0 deletions tasks/compat_data/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# Compat Data

Get engine compatibility Data from https://github.com/compat-table/compat-table/

Code extracted from https://github.com/babel/babel/tree/main/packages/babel-compat-data

## Adding a new feature

- Find the feature from https://github.com/compat-table/compat-table/blob/gh-pages/data-es2016plus.js
- Add the feature in `./es-features.js`
- `pnpm install`
- `cargo run -p oxc_compat_data`
2 changes: 0 additions & 2 deletions tasks/compat_data/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const getLowestImplementedVersion = (
ok &&= !exclude(test.name);
return ok;
});

const envTests = tests.map(({ res }) => {
const versions = envsVersions[env];
let i = versions.length - 1;
Expand Down Expand Up @@ -110,7 +109,6 @@ const generateData = (environments, items) => {
item.targets = targets;
}

console.log(items);
return items;
};

Expand Down
42 changes: 42 additions & 0 deletions tasks/compat_data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,27 @@
"electron": "3.0"
}
},
{
"name": "LookbehindRegex",
"babel": null,
"features": [
"RegExp Lookbehind Assertions"
],
"es": "ES2018",
"targets": {
"chrome": "62",
"opera": "49",
"edge": "79",
"firefox": "78",
"safari": "16.4",
"node": "8.10",
"deno": "1",
"ios": "16.4",
"samsung": "8",
"opera_mobile": "46",
"electron": "3.0"
}
},
{
"name": "ObjectRestSpread",
"babel": "transform-object-rest-spread",
Expand Down Expand Up @@ -910,6 +931,27 @@
"electron": "15.0"
}
},
{
"name": "MatchIndicesRegex",
"babel": null,
"features": [
"RegExp Match Indices (`hasIndices` / `d` flag) / constructor supports it"
],
"es": "ES2022",
"targets": {
"chrome": "90",
"opera": "76",
"edge": "90",
"firefox": "91",
"safari": "15",
"node": "16",
"deno": "1.8",
"ios": "15",
"samsung": "15",
"opera_mobile": "64",
"electron": "13.0"
}
},
{
"name": "UnicodeSetsRegex",
"babel": "transform-unicode-sets-regex",
Expand Down
13 changes: 13 additions & 0 deletions tasks/compat_data/es-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ const es2018 = [
babel: 'transform-dotall-regex',
features: ['s (dotAll) flag for regular expressions'],
},
{
name: 'LookbehindRegex',
babel: null,
features: ['RegExp Lookbehind Assertions'],
},
{
name: 'ObjectRestSpread',
babel: 'transform-object-rest-spread',
Expand Down Expand Up @@ -279,6 +284,14 @@ const es2022 = [
babel: 'transform-class-static-block',
features: ['Class static initialization blocks'],
},
{
name: 'MatchIndicesRegex',
babel: null,
features: [
'RegExp Match Indices (`hasIndices` / `d` flag) / constructor supports it',
// ignore "shows up in flags"
],
},
].map(f('ES2022'));

const es2024 = [
Expand Down
16 changes: 16 additions & 0 deletions tasks/compat_data/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#![allow(clippy::print_stdout)]
use std::process::Command;

use oxc_compat_data::generate;
use oxc_tasks_common::project_root;

fn main() {
let cwd = project_root().join("tasks/compat_data");

if !cwd.join("compat-table").exists() {
println!("Cloning compat-table ...");
Command::new("pnpm").current_dir(&cwd).args(["run", "init"]).output().unwrap();
}

let output = Command::new("pnpm").current_dir(cwd).args(["run", "build"]).output().unwrap();
if !output.status.success() {
println!("{}", String::from_utf8(output.stderr).unwrap());
}

generate();
}
8 changes: 2 additions & 6 deletions tasks/transform_conformance/snapshots/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: d20b314c

Passed: 77/87
Passed: 78/87

# All Passed:
* babel-plugin-transform-class-static-block
Expand All @@ -12,6 +12,7 @@ Passed: 77/87
* babel-plugin-transform-arrow-functions
* babel-preset-typescript
* babel-plugin-transform-react-jsx-source
* regexp


# babel-plugin-transform-typescript (2/9)
Expand Down Expand Up @@ -175,8 +176,3 @@ x Output mismatch
x Output mismatch


# regexp (7/8)
* all-regex-plugins-enabled-by-targets/input.js
x Output mismatch