fix(identifier): avoid double escaping slash#18075
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61793 |
|
commit: |
Shouldn't it the same if we generate a js/ts file that only export a string? Update: Like this fisker@afa88d7 |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
Maybe we can have a rollup or Babel plugin to "minify" these strings by generating at bundle time the smaller escapes.
Thank you. I tried on this branch, we have a Babel plugin to rewrite imports from |
0053089 to
abb2a7a
Compare
|
Now that Babel 8 requires Node.js >= 22.18 which comes with ICU 77.1 supporting Unicode 16, if we want to shrink the size of this big regex which is also rarely used. A potential approach is to replace it with the following format new RegExp (
"[\\p{Identifier_Start}<code points assigned Identifier_Start in Unicode 17.0+>]",
"u"
)The new format will not contain double-digit hex points in practical because anything < 256 is well-defined and stable prior to Unicode 16. It should drastically reduce the regex size while maintaining conformance to the latest Unicode standard. The downsize of this approach is that if you run Babel parser in a Node.js |
I would be fine with this. For |
Good question, yes and ideally the transpiled result should be as same as the transpiled result of the |
|
I'm concerned that when Unicode 18 is introduced, the parser will behave inconsistently across different engine versions. |
To clarify, what I mean in is |
To keep this PR focused, I will keep this PR as-is and experiment a bit and open a new PR if this approach is applicable. |
|
I'm finishing the preset-modules update, then let's release. |
In this PR we avoid double escaping slash
\when generating the JSON data. The overall file size will slightly increase by a few bytes because JSON does not support\x, but I think it is worthy of change as the JSON file frees us from manually copy-pasting JS source codes.