**Description:**
In the default mode, `Box<T>` and `Vec<T>` should work just like them from std.
**Related issue:**
- This PR is part of https://github.com/swc-project/swc/pull/9230
**Description:**
This is a part of https://github.com/swc-project/swc/pull/9230. I
profiled the performance, and `thread_local` took too long to get the
address of the thread-local variable. So, I inlined the reference into
the allocator.
# Benchmark result
```
Gnuplot not found, using plotters backend
common/allocator/alloc/std/1000000
time: [4.9478 ms 4.9653 ms 4.9922 ms]
Found 17 outliers among 100 measurements (17.00%)
4 (4.00%) high mild
13 (13.00%) high severe
common/allocator/alloc/no-scope/1000000
time: [5.4821 ms 5.4938 ms 5.5068 ms]
Found 17 outliers among 100 measurements (17.00%)
2 (2.00%) high mild
15 (15.00%) high severe
common/allocator/alloc/scoped/1000000
time: [3.1401 ms 3.1456 ms 3.1518 ms]
Found 12 outliers among 100 measurements (12.00%)
3 (3.00%) high mild
9 (9.00%) high severe
common/allocator/alloc/cached-no-scope/1000000
time: [5.0992 ms 5.1090 ms 5.1198 ms]
Found 11 outliers among 100 measurements (11.00%)
2 (2.00%) high mild
9 (9.00%) high severe
common/allocator/alloc/cached-scoped/1000000
time: [3.0191 ms 3.0230 ms 3.0273 ms]
Found 11 outliers among 100 measurements (11.00%)
2 (2.00%) low mild
1 (1.00%) high mild
8 (8.00%) high severe
```
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_runner os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
**Description:**
When a default branch appears before an exact match, the variable declaration should be recorded before deleting the default branch.
**Related issue:**
- Closes https://github.com/swc-project/swc/issues/8919
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_runner os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
**Description:**
This PR changes the AST node construction code to use `.into()` or `::from()` to make changing the boxed-ness of the AST node easier. I used `ast-grep` to make large changes across codebase.
**Description:**
This PR allows `ArrayLit`s to be converted to numbers in the
`cast_to_number` function. This allows expressions using arrays to be
converted to numbers. See some example expressions below that were
previously not able to be computed, but are now able to due to this
change.
```js
+[] // 0
+[[]] // 0
+[1] // 1
+[undefined] // 0
+[null] // 0
+[[1]] // 1
+[,] // 0
+[,,] // NaN
```
Regarding the implementation, arrays are converted to strings, and the
string is then parsed as a number. So arrays like `[]` and `[undefined]`
return `""` which then return `0` when parsed as a string. This is also
why arrays with more than one element can't be parsed because e.g. `[1,
2]` returns `"1,2"`. This procedure follows the ECMAScript
specification.
https://262.ecma-international.org/6.0/#sec-tonumberhttps://262.ecma-international.org/6.0/#sec-toprimitive
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_runner os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_runner os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_runner os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
**Description:**
The original code separately records the usage of variables and checks if there is a closure. Changed to only record variables used in a closure.
**Related issue:**
- Closes https://github.com/swc-project/swc/issues/8010
**Description:**
Given that decorators will be a part of JavaScript, as specified in the [proposal](https://github.com/tc39/proposal-decorators), we retain them in the output rather than reporting an error.
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_plugin_testing os:windows-latest runner:windows-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_timer os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_trace_macro os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_transform_common os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_typescript os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_visit_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_x_optimizer os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_ast os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_codegen_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_parser os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:swc_xml_visit os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (map[crate:testing_macros os:ubuntu-latest runner:ubuntu-latest]) (push) Has been cancelled
**Description:**
This PR makes `PluginCommentProxy` work by default in `test_fixture()`. This PR adds a scoped-local to `swc_common`, and uses it from `swc_ecma_transforms_testing`.
It can't be tested in the main repository, though. We cannot enable `plugin_mode` of `swc_common` in the main SWC repository.
**Related issue:**
- Closes https://github.com/swc-project/swc/issues/9149.
Publish (core) / Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} (18, map[host:macos-latest target:x86_64-apple-darwin]) (push) Has been cancelled
Publish (core) / Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} (18, map[host:windows-latest target:x86_64-pc-windows-msvc]) (push) Has been cancelled
Publish (core) / Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} (20, map[host:macos-latest target:x86_64-apple-darwin]) (push) Has been cancelled
Publish (core) / Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} (20, map[host:windows-latest target:x86_64-pc-windows-msvc]) (push) Has been cancelled
**Description:**
Actually it was slower.
```
Starting recording with the Time Profiler template. Launching process: full-4ec72b7d24d0fcd8.
Ctrl-C to stop the recording
Gnuplot not found, using plotters backend
Benchmarking es/minify/libraries/antd
Benchmarking es/minify/libraries/antd: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 5.2s.
Benchmarking es/minify/libraries/antd: Collecting 10 samples in estimated 5.1501 s (10 iterations)
Benchmarking es/minify/libraries/antd: Analyzing
es/minify/libraries/antd
time: [517.09 ms 521.65 ms 527.04 ms]
change: [-5.0960% -4.1320% -3.0084%] (p = 0.00 < 0.05)
Performance has improved.
Benchmarking es/minify/libraries/d3
Benchmarking es/minify/libraries/d3: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 7.3s or enable flat sampling.
Benchmarking es/minify/libraries/d3: Collecting 10 samples in estimated 7.3000 s (55 iterations)
Benchmarking es/minify/libraries/d3: Analyzing
es/minify/libraries/d3 time: [132.42 ms 132.66 ms 132.93 ms]
change: [-5.0809% -4.6687% -4.2423%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
1 (10.00%) high mild
Benchmarking es/minify/libraries/echarts
Benchmarking es/minify/libraries/echarts: Warming up for 3.0000 s
Benchmarking es/minify/libraries/echarts: Collecting 10 samples in estimated 8.8664 s (20 iterations)
Benchmarking es/minify/libraries/echarts: Analyzing
es/minify/libraries/echarts
time: [441.89 ms 442.98 ms 444.21 ms]
change: [-5.8436% -5.4580% -5.0604%] (p = 0.00 < 0.05)
Performance has improved.
Benchmarking es/minify/libraries/jquery
Benchmarking es/minify/libraries/jquery: Warming up for 3.0000 s
Benchmarking es/minify/libraries/jquery: Collecting 10 samples in estimated 7.2124 s (165 iterations)
Benchmarking es/minify/libraries/jquery: Analyzing
es/minify/libraries/jquery
time: [43.549 ms 43.624 ms 43.703 ms]
change: [-3.3699% -3.0686% -2.7597%] (p = 0.00 < 0.05)
Performance has improved.
Benchmarking es/minify/libraries/lodash
Benchmarking es/minify/libraries/lodash: Warming up for 3.0000 s
Benchmarking es/minify/libraries/lodash: Collecting 10 samples in estimated 6.5048 s (110 iterations)
Benchmarking es/minify/libraries/lodash: Analyzing
es/minify/libraries/lodash
time: [58.951 ms 59.114 ms 59.290 ms]
change: [-1.2723% -0.7019% -0.0217%] (p = 0.06 > 0.05)
No change in performance detected.
Found 1 outliers among 10 measurements (10.00%)
1 (10.00%) high severe
Benchmarking es/minify/libraries/moment
Benchmarking es/minify/libraries/moment: Warming up for 3.0000 s
Benchmarking es/minify/libraries/moment: Collecting 10 samples in estimated 5.5497 s (220 iterations)
Benchmarking es/minify/libraries/moment: Analyzing
es/minify/libraries/moment
time: [25.261 ms 25.313 ms 25.355 ms]
change: [-1.4771% -0.9851% -0.5957%] (p = 0.00 < 0.05)
Change within noise threshold.
Benchmarking es/minify/libraries/react
Benchmarking es/minify/libraries/react: Warming up for 3.0000 s
Benchmarking es/minify/libraries/react: Collecting 10 samples in estimated 5.1132 s (605 iterations)
Benchmarking es/minify/libraries/react: Analyzing
es/minify/libraries/react
time: [8.4265 ms 8.4431 ms 8.4624 ms]
change: [-1.3741% -1.0134% -0.6710%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 1 outliers among 10 measurements (10.00%)
1 (10.00%) high mild
Benchmarking es/minify/libraries/terser
Benchmarking es/minify/libraries/terser: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 5.6s or enable flat sampling.
Benchmarking es/minify/libraries/terser: Collecting 10 samples in estimated 5.5614 s (55 iterations)
Benchmarking es/minify/libraries/terser: Analyzing
es/minify/libraries/terser
time: [100.87 ms 100.98 ms 101.15 ms]
change: [-6.7656% -6.1477% -5.4618%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
1 (10.00%) high severe
Benchmarking es/minify/libraries/three
Benchmarking es/minify/libraries/three: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 9.3s or enable flat sampling.
Benchmarking es/minify/libraries/three: Collecting 10 samples in estimated 9.3499 s (55 iterations)
Benchmarking es/minify/libraries/three: Analyzing
es/minify/libraries/three
time: [170.12 ms 170.44 ms 170.81 ms]
change: [-6.9164% -6.4564% -5.9450%] (p = 0.00 < 0.05)
Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
1 (10.00%) high severe
Benchmarking es/minify/libraries/typescript
Benchmarking es/minify/libraries/typescript: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 9.3s.
Benchmarking es/minify/libraries/typescript: Collecting 10 samples in estimated 9.2642 s (10 iterations)
Benchmarking es/minify/libraries/typescript: Analyzing
es/minify/libraries/typescript
time: [927.57 ms 929.26 ms 930.85 ms]
change: [-4.4792% -4.1803% -3.9000%] (p = 0.00 < 0.05)
Performance has improved.
Benchmarking es/minify/libraries/victory
Benchmarking es/minify/libraries/victory: Warming up for 3.0000 s
Benchmarking es/minify/libraries/victory: Collecting 10 samples in estimated 7.0301 s (30 iterations)
Benchmarking es/minify/libraries/victory: Analyzing
es/minify/libraries/victory
time: [233.98 ms 234.44 ms 234.96 ms]
change: [-7.2681% -6.7396% -6.2554%] (p = 0.00 < 0.05)
Performance has improved.
Benchmarking es/minify/libraries/vue
Benchmarking es/minify/libraries/vue: Warming up for 3.0000 s
Benchmarking es/minify/libraries/vue: Collecting 10 samples in estimated 6.7241 s (110 iterations)
Benchmarking es/minify/libraries/vue: Analyzing
es/minify/libraries/vue time: [61.051 ms 61.124 ms 61.225 ms]
change: [-2.3890% -2.1697% -1.9536%] (p = 0.00 < 0.05)
Performance has improved.
```
**Related issue:**
- Closes#9126
**Description:**
by symbol name -> by whether it points to global undefined or not.
The updated test results all involve variables with `undefined` ident (although they are indeed uninitialized).
**Related issue:**
- Closes: https://github.com/swc-project/swc/issues/8567
**Description:**
Now, `TokenContext` is 1 byte, so we can increase the stack size for it.
```
Gnuplot not found, using plotters backend
Benchmarking es/parser/colors
Benchmarking es/parser/colors: Warming up for 3.0000 s
Benchmarking es/parser/colors: Collecting 100 samples in estimated 5.0243 s (561k iterations)
Benchmarking es/parser/colors: Analyzing
es/parser/colors time: [8.8652 µs 8.8821 µs 8.9013 µs]
change: [+0.3001% +0.6986% +1.0681%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 9 outliers among 100 measurements (9.00%)
4 (4.00%) high mild
5 (5.00%) high severe
Benchmarking es/parser/angular
Benchmarking es/parser/angular: Warming up for 3.0000 s
Benchmarking es/parser/angular: Collecting 100 samples in estimated 5.1460 s (1100 iterations)
Benchmarking es/parser/angular: Analyzing
es/parser/angular time: [4.5989 ms 4.6075 ms 4.6180 ms]
change: [+1.5999% +1.9780% +2.3764%] (p = 0.00 < 0.05)
Performance has regressed.
Found 8 outliers among 100 measurements (8.00%)
1 (1.00%) high mild
7 (7.00%) high severe
Benchmarking es/parser/backbone
Benchmarking es/parser/backbone: Warming up for 3.0000 s
Benchmarking es/parser/backbone: Collecting 100 samples in estimated 7.0775 s (10k iterations)
Benchmarking es/parser/backbone: Analyzing
es/parser/backbone time: [694.50 µs 695.84 µs 697.51 µs]
change: [-1.1099% -0.7438% -0.3658%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 13 outliers among 100 measurements (13.00%)
5 (5.00%) high mild
8 (8.00%) high severe
Benchmarking es/parser/jquery
Benchmarking es/parser/jquery: Warming up for 3.0000 s
Benchmarking es/parser/jquery: Collecting 100 samples in estimated 5.1340 s (1300 iterations)
Benchmarking es/parser/jquery: Analyzing
es/parser/jquery time: [3.9253 ms 3.9334 ms 3.9430 ms]
change: [+0.2515% +0.6374% +1.0228%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 10 outliers among 100 measurements (10.00%)
3 (3.00%) high mild
7 (7.00%) high severe
Benchmarking es/parser/jquery mobile
Benchmarking es/parser/jquery mobile: Warming up for 3.0000 s
Benchmarking es/parser/jquery mobile: Collecting 100 samples in estimated 5.3971 s (900 iterations)
Benchmarking es/parser/jquery mobile: Analyzing
es/parser/jquery mobile time: [5.9041 ms 5.9175 ms 5.9340 ms]
change: [-1.8844% -1.5663% -1.2247%] (p = 0.00 < 0.05)
Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
4 (4.00%) high mild
7 (7.00%) high severe
Benchmarking es/parser/mootools
Benchmarking es/parser/mootools: Warming up for 3.0000 s
Benchmarking es/parser/mootools: Collecting 100 samples in estimated 5.1747 s (1700 iterations)
Benchmarking es/parser/mootools: Analyzing
es/parser/mootools time: [3.0240 ms 3.0352 ms 3.0489 ms]
change: [-1.5654% -1.1553% -0.6819%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 7 outliers among 100 measurements (7.00%)
1 (1.00%) high mild
6 (6.00%) high severe
Benchmarking es/parser/underscore
Benchmarking es/parser/underscore: Warming up for 3.0000 s
Benchmarking es/parser/underscore: Collecting 100 samples in estimated 6.1976 s (10k iterations)
Benchmarking es/parser/underscore: Analyzing
es/parser/underscore time: [612.60 µs 614.58 µs 616.82 µs]
change: [-1.9306% -1.5582% -1.1803%] (p = 0.00 < 0.05)
Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
4 (4.00%) high mild
3 (3.00%) high severe
Benchmarking es/parser/three
Benchmarking es/parser/three: Warming up for 3.0000 s
Benchmarking es/parser/three: Collecting 100 samples in estimated 5.1445 s (300 iterations)
Benchmarking es/parser/three: Analyzing
es/parser/three time: [16.890 ms 16.951 ms 17.026 ms]
change: [-2.1520% -1.7192% -1.2254%] (p = 0.00 < 0.05)
Performance has improved.
Found 17 outliers among 100 measurements (17.00%)
3 (3.00%) high mild
14 (14.00%) high severe
Benchmarking es/parser/yui
Benchmarking es/parser/yui: Warming up for 3.0000 s
Benchmarking es/parser/yui: Collecting 100 samples in estimated 5.0417 s (1800 iterations)
Benchmarking es/parser/yui: Analyzing
es/parser/yui time: [2.8076 ms 2.8156 ms 2.8249 ms]
change: [-2.2730% -1.9284% -1.5384%] (p = 0.00 < 0.05)
Performance has improved.
Found 16 outliers among 100 measurements (16.00%)
5 (5.00%) high mild
11 (11.00%) high severe
Benchmarking es/parser/cal-com
Benchmarking es/parser/cal-com: Warming up for 3.0000 s
Benchmarking es/parser/cal-com: Collecting 100 samples in estimated 5.9664 s (400 iterations)
Benchmarking es/parser/cal-com: Analyzing
es/parser/cal-com time: [14.815 ms 14.888 ms 14.974 ms]
change: [-1.2376% -0.7153% -0.1968%] (p = 0.01 < 0.05)
Change within noise threshold.
Found 17 outliers among 100 measurements (17.00%)
1 (1.00%) high mild
16 (16.00%) high severe
Benchmarking es/parser/typescript
Benchmarking es/parser/typescript: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 10.5s, or reduce sample count to 40.
Benchmarking es/parser/typescript: Collecting 100 samples in estimated 10.496 s (100 iterations)
Benchmarking es/parser/typescript: Analyzing
es/parser/typescript time: [101.97 ms 102.32 ms 102.73 ms]
change: [-1.6102% -1.1640% -0.7126%] (p = 0.00 < 0.05)
Change within noise threshold.
Found 14 outliers among 100 measurements (14.00%)
4 (4.00%) high mild
10 (10.00%) high severe
```
**Description:**
- `TokenContexts` now uses smallvec, as the element type is very small (1 byte) now.
- Some codes are moved to allow CPU to cache code correctly.
**Description:**
`EsConfig` and `TsConfig` sound like a general configuration for the whole language, while actually it's only about parsing.
To avoid a breaking change, I created type aliases that will work without changing the code, while warning the users.
**Related issue:**
- Closes#9089.
**Description:**
In the fast path, we don't even use the buffer.
```
Benchmarking es/lexer/cal-com
Benchmarking es/lexer/cal-com: Warming up for 3.0000 s
Benchmarking es/lexer/cal-com: Collecting 100 samples in estimated 5.5395 s (900 iterations)
Benchmarking es/lexer/cal-com: Analyzing
es/lexer/cal-com time: [6.1799 ms 6.2010 ms 6.2250 ms]
change: [-4.4027% -3.9504% -3.5372%] (p = 0.00 < 0.05)
Performance has improved.
Found 17 outliers among 100 measurements (17.00%)
4 (4.00%) high mild
13 (13.00%) high severe
```
**Description:**
We don't need to push a character at a time. This profiling result does not include improvements from
https://github.com/swc-project/swc/pull/9076.
```
Benchmarking es/lexer/cal-com
es/lexer/cal-com time: [6.4555 ms 6.4936 ms 6.5368 ms]
```
**Description:**
Coverage gets better if we generate fewer source map entries. This PR only fixes the issue for `"coverageProvider": "v8"`. Much more work is required for the default coverage provider I guess.
**Related issue:**
- #3854
**Description:**
https://github.com/getsentry/rust-sourcemap/pull/91 should fix this
issue, but let's revert #9052 for now.
# Context
`swc_core` regressed.
Caught by https://github.com/vercel/next.js/pull/66902
```
⚠ Linting is disabled.
▲ Next.js 15.0.0-canary.34
✓ Checking validity of types
Creating an optimized production build ...
Panic: PanicInfo { payload: Any { .. }, message: Some(attempt to add with overflow), location: Location { file: "/Users/kdy1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/sourcemap-8.0.1/src/encoder.rs", line: 89, col: 13 }, can_unwind: true, force_no_backtrace: false }
Backtrace: 0: backtrace::backtrace::libunwind::trace
at /Users/kdy1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/libunwind.rs:93:5
backtrace::backtrace::trace_unsynchronized::<<backtrace::capture::Backtrace>::create::{closure#0}>
at /Users/kdy1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/mod.rs:66:5
backtrace::backtrace::trace::<<backtrace::capture::Backtrace>::create::{closure#0}>
at /Users/kdy1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/mod.rs:53:14
<backtrace::capture::Backtrace>::create
at /Users/kdy1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/capture.rs:176:9
<backtrace::capture::Backtrace>::new
at /Users/kdy1/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/capture.rs:140:22
1: next_swc_napi::init::{closure#0}
at packages/next-swc/crates/napi/src/lib.rs:85:29
2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/alloc/src/boxed.rs:2077:9
std::panicking::rust_panic_with_hook
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:799:13
3: std::panicking::begin_panic_handler::{{closure}}
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs
```
**Description:**
TsPropertySignature can not have params, type params, or an initializer.
**BREAKING CHANGE:**
Yes. Any users looking into these fields should stop - they are always empty.
---------
Co-authored-by: 강동윤 (Donny) <kdy1997.dev@gmail.com>
**Description:**
I mistakenly introduced a performance regression with https://github.com/swc-project/swc/pull/9032. It makes the minifier visit the initializer of variables multiple times - once while normal visiting and once in `hoist_props_of_vars`. This PR fixes it.
**Description:**
Handles
```js
var FRUITS = { MANGO: "mango" }, getMangoLabel = (label) => label[FRUITS.MANGO];
```
while hoisting properties. In the code above, the initializer of the second variable declarator should be visited after hoisting the first variable declarator. Otherwise `FRUITS.MANGO` cannot be handled.
**Related issue:**
- Closes#9030
**Description:**
This reverts commit cc8c1550dd because it caused a regression in the next.js canary.
- Canary version: `15.0.0-canary.12`
**Related issue:**
- Reverts #8986