Announcing swc v1.1.0
#
Pluginswc
now supports custom plugins written in javascript and friends! Note that .d.ts
file for ast nodes and Visitor
is provided.
#
PerformanceOne of difference of swc
with babel
is performance. I optimized swc
binary in many ways and here's the benchmark result ran on my MacBook Pro (2.3GHz, 16GB Memory)
:babel
does same tasks as "swc (es5)" while :plugin
does tasks of "swc (es3)" and javsacript-based traversal of all ast nodes. swc
is much faster than babel even though swc
does more work.
#
Example pluginLet's write a transform which removes console calls such as console.log()
.
You are done. You can turn on swc's optimizer with jsc.transform.optimizer
to remove void 0.
See: https://github.com/swc-project/plugin-strip-console
#
Parser#
PerformanceAgain, swc
is fast.
#442)#
Optional chaining (swc
now supports optional chaining from typescript 3.7.
As this is official syntax, this is enabled by default if you configure { syntax: "typescript" }
in .swcrc
.
#
Error recoveryswc_ecma_parser
did not supported any error recovert when v1.0.0
was released. As it made debugging hard, I implemented lot of error recovery logic. Note that I'll keep improving error recovery while swc
matches the grade of tsc.
I stored reference errors of each file in ecmascript parser's test suite.
This is an example of reference.
#
SpanSpan of error becomes much more accurate. Swc has an error reporting test which tests many tests from test262, the official ecmascript test suite.
#
.swcrc.swcrc
file is improved.
#
Multiple entriesStarting with v1.0.47
, you can specify multiple entries in .swcrc
.
This make swc compile javascript files as common js module (uses require('foo')
) and compile typescript files as amd modules.