swc
swc copied to clipboard
Use identical generator transform as `tsc`
Would you mind sharing some details about the reason behind the proposed change?
regenerator-runtime
is indeed a bit heavy (2.66 KiB after minified + gzipped), but it is also performant.
Here are some benchmark results I have done last year on Node.js 16.13.1:
(This one should be
Memory(MiB)
, not Time(ms)
)
- babel: regenerator-runtime used by babel-preset-env
- fast-async: https://github.com/MatAtBread/fast-async
- babel-plugin-transform-async-to-promises: https://github.com/rpetrich/babel-plugin-transform-async-to-promises
Benchmark suite: https://github.com/SukkaW/promise-performance-tests
Thank you!
I didn't know the performance difference.
I think we should also consider the output size
@SukkaW Can you share the code about the benchmark you did? Looks like the Finbonacci one is cirtical but not for others with performance and it takes more memory.
If users are using swc to bundle tiny libs, the 2.66kb might be a issue for bundle size of those libs. We might inline external helpers since they're not too large for the bundle
@SukkaW Can you share the code about the benchmark you did? Looks like the Finbonacci one is cirtical but not for others with performance and it takes more memory.
Sure! Here is the benchmark suite I forked from V8: https://github.com/SukkaW/promise-performance-tests
And here is the source code of the Fibonacci tests: https://github.com/SukkaW/promise-performance-tests/blob/master/lib/fibonacci-async.js
And here are the outputs:
- https://github.com/SukkaW/promise-performance-tests/blob/master/build/fibonacci-async-babel.js
- https://github.com/SukkaW/promise-performance-tests/blob/master/build/fibonacci-async-fast-async.js
- https://github.com/SukkaW/promise-performance-tests/blob/master/build/fibonacci-async-to-promises.js
- https://github.com/SukkaW/promise-performance-tests/blob/master/build/fibonacci-async-tsc.js
I tried the tests case and it breaks with some errors such as
ReferenceError: regeneratorRuntime is not defined
I feel this is the major problem that we need to manage polyfill dependencies after compilation, and make those polyfills work. tsc regenerator transform solves this problem. I wouldn't imagine tsc vs babel transform will have huge significant difference in browser as tsc has become the quite popular choice today
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.