Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transformer): numeric separator plugin. #2795

Merged
merged 24 commits into from Mar 26, 2024
Merged

Conversation

rzvxa
Copy link
Collaborator

@rzvxa rzvxa commented Mar 23, 2024

@github-actions github-actions bot added the A-transformer Area - Transformer / Transpiler label Mar 23, 2024
Copy link

codspeed-hq bot commented Mar 23, 2024

CodSpeed Performance Report

Merging #2795 will improve performances by 3.13%

Comparing rzvxa:num-sep (dcbde1d) with main (56493bd)

Summary

⚡ 1 improvements
✅ 33 untouched benchmarks

Benchmarks breakdown

Benchmark main rzvxa:num-sep Change
parser_napi[checker.ts] 240.7 ms 233.4 ms +3.13%

@github-actions github-actions bot added A-parser Area - Parser A-ast Area - AST labels Mar 23, 2024
@github-actions github-actions bot added the A-codegen Area - Code Generation label Mar 24, 2024
@Dunqing
Copy link
Member

Dunqing commented Mar 24, 2024

You need to update the snapshot. Just run just coverage

@rzvxa
Copy link
Collaborator Author

rzvxa commented Mar 24, 2024

You need to update the snapshot. Just run just coverage

Thanks, Yeah I'm aware of the snapshot being different. My issue with this one is that I'm only passing one of 2 tests and since it is such a small thing I can't put my finger on the thing that causes this issue, Have to do some tracing to figure it out.

  # All Passed:
-* babel-plugin-transform-numeric-separator
 * babel-plugin-transform-optional-catch-binding
 * babel-plugin-transform-json-strings
 * babel-plugin-transform-shorthand-properties
@@ -515,6 +514,9 @@ Passed: 352/1369
 # babel-plugin-transform-logical-assignment-operators (5/6)
 * logical-assignment/null-coalescing/input.js
 
+# babel-plugin-transform-numeric-separator (1/2)
+* used-with-transform-es2015-literals/input.js
+
 # babel-plugin-transform-export-namespace-from (0/4)
 * export-namespace/namespace-default/input.mjs
 * export-namespace/namespace-es6/input.mjs

It seems like the snapshot already has these tests passing, Since they were implemented in codegen, It is broken since I'm passing 1 of 2 instead of 2 of 2 so updating snapshots shouldn't be necessary when I get it working.

@rzvxa
Copy link
Collaborator Author

rzvxa commented Mar 24, 2024

@Dunqing Sorry to bother you, Do you have any idea about this? I'm generating the same output as Babel but the test fails. Is there anything that I'm missing?

I'm getting this:

Original:

1_000;
0xA0_B0_C0;
0b1010_0001_1000_0101;
0o0_6_6_6;


Transformed:

1000;
0xA0B0C0;
41349;
438;

and Babel produces this:

1000;
0xA0B0C0;
41349;
438;

Here is the config used for the babel:

{
  "plugins": [
    "@babel/plugin-transform-numeric-separator",
    "@babel/plugin-transform-literals"
  ]
}

@Dunqing
Copy link
Member

Dunqing commented Mar 25, 2024

@Dunqing Sorry to bother you, Do you have any idea about this? I'm generating the same output as Babel but the test fails. Is there anything that I'm missing?

I'm getting this:

Original:

1_000;
0xA0_B0_C0;
0b1010_0001_1000_0101;
0o0_6_6_6;


Transformed:

1000;
0xA0B0C0;
41349;
438;

and Babel produces this:

1000;
0xA0B0C0;
41349;
438;

Here is the config used for the babel:

{
  "plugins": [
    "@babel/plugin-transform-numeric-separator",
    "@babel/plugin-transform-literals"
  ]
}

I will take a look soon

@Dunqing
Copy link
Member

Dunqing commented Mar 25, 2024

There are two problems that need to be solved

  1. The test lacks an output file, which is a babel problem fix: incorrect numeric-seperator tests babel/babel#16381
  2. Due to the lack of an output file, oxc transform_confromance will use the input file as the output file fix(tasks/transform-conformance) when the output file does not exist, the output content should be empty #2808

@rzvxa
Copy link
Collaborator Author

rzvxa commented Mar 25, 2024

@Dunqing Wow great work! It literally took me a day or so to look at the same code wondering why is it wrong, Never would've thought that the test case itself was incomplete.

I guess with this knowledge, We can think of this and #2797 as passing the tests since they are producing the same output as Babel.

@rzvxa rzvxa marked this pull request as ready for review March 25, 2024 15:26
Boshen pushed a commit that referenced this pull request Mar 25, 2024
Dunqing pushed a commit that referenced this pull request Mar 26, 2024
This PR updates the babel submodule in the justfile to take advantage of
[this PR](babel/babel#16381). Related to #2795
and #2797.
@Dunqing
Copy link
Member

Dunqing commented Mar 26, 2024

I think we can merge this after you have cleaned up the code and fixed the conflict.

charnog pushed a commit to charnog/oxc that referenced this pull request Mar 26, 2024
charnog pushed a commit to charnog/oxc that referenced this pull request Mar 26, 2024
This PR updates the babel submodule in the justfile to take advantage of
[this PR](babel/babel#16381). Related to oxc-project#2795
and oxc-project#2797.
@Dunqing
Copy link
Member

Dunqing commented Mar 26, 2024

Thank you!!

@Dunqing Dunqing merged commit 243131d into oxc-project:main Mar 26, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST A-codegen Area - Code Generation A-parser Area - Parser A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants