ChangeLog: swc v1.2.27
#
Bugfixes#1069)#
Import / export orders are preserved (Previously swc can break codes if you use es6 circular imports. As circular imports are not used widely, it was undetected.
The affected code looks like
Previously swc can break codes if you use es6 circular imports. As circular imports are not used widely, it was undetected.
The affected code looks like
Previously, swc injected a newline after block comments.
This is wrong behavior, as it can break some codes. Especially, the code below is broken.
It was compiled as
which is equal to
due to automatic semicolon insertion and it's broken as the return value is changed and function () {}
is a function declaration, not a function expression.
swc now compiles meta properties correctly.
Previously, swc does not follow the order declared in the soruce file while emitting imports and exports. As a result, cyclic imports were broken. This is now fixed, and
is compiled as
instead of
This affects code like
Due to a bug of the build script, unpacked size was too big. New version is published to reduce package size.
swc finally suports jsx pragma, which is required to use some libraries like emotion.sh.
I didn't know that it is valid syntax, but the code below is validl, and swc now supports it.
Dynamic imports are not widely supported, so it should be transcompiled.
is now compiled as
if the module config is common js.
this
is now correctly handled in the loops.
Also, you can now mutate the index variable while iterating.
e.g.
Previously swc miscompiled
into
which is wrong. Now it's fixed and swc emits correct output.
I fixed the code generator, parser, typescript stripper, fixer pass, resolver pass and hygiene pass to handle very large binary expressions.
As a result, swc can now compile very large binary expressions like those in seedlings
Previously, swc miscompiled
into
which is wrong. It should be
and swc now emits correct code.
I did very hard work on it, and many edge cases are fixed. I don't think it's production ready yet, but it will be in a near future.
As a side note, #1016 is about ecmascript imports and #1031 and #0134 are about complex reexports and common js support, respectively.
swc becomes faster and it will be much faster with the next version. Its performance is similar to it of esbuild, even though there are so many low-hanging fruits.
With napi-rs, swc becomes faster and install script is removed. npm i @swc/core
is enough!
Reflect
(#1011)#Thanks to @Brooooooklyn, swc now works just like official tsc while transpiling decorators.
Previously, parser of the swc did many crazy things. For example, while parsing keywords, it allocated an interned string for them, and convert them to cheap enums. And now, the cheap enums are created directly.
Fixing various crazy things like this, parser becomes 10% faster.
TypeScript pass got 5 times faster. Previously it was slow due to a design flaw, but is's now fixed.
TypeScript 4 allows
and swc now supports it.
Error messages were crpytic, mainly because I'm too lazy. Anyway, it's finally got improved.
becomes
Previously, swc spend all time moving the memory with memmove
. I've managed to remove some memmoves.
Also, panic cases are handled properly.
For example, I changed code from
to
This technique aids cpu cache issue.
It drastically reduces times used to memmove.
Some design flaws are fixed, it's fully parallelzed, and it does not transform files from node_modules.
Some useless allocations are removed, some memmoves are removed. Also, merging of reexports in spack now works in parallel manner.
Spack supports .swcrc
properly. Just like webpack + babel environment, the configuration is determined per-file. You can even mix tsx
, ts
, js
if you want.
Previously common js modules were improperly handled. After some very hard work, I managed to fix it and common js imports are transcompiled to compact code.
Spack generates clean code, just like the code below.
Spack is designed to emit bundle as smallest as possible when minified.
You can now use spack to bundle react projects. See an integration test for react in the swc main repository.
lodash-es
accesses exports
even if it's an es module. In order to handle name conflict, swc
prevously rename exports
to something different.
It's now handled more sensitively to avoid breaking codes.
Note: this applies to typescript decorators
Previously, decorators on a parameter which does not have initializer were broken.
It was undefined, which is wrong, and it's now an instance of Subject
.
Previously test?
in the code below was miscompiled. It's now fixed and swc
generates correct output.
While abstraction of the spack, I added much more test cases and fixed some tree-shaking bugs.
spack
now supprots cyclic dependencies between es modules.
This is a bugfix for a new feature introduced in [swc][]@v1.2.16
.
An example of affected code is
This is a bugfix for a new feature introduced in [swc][]@v1.2.15
.
An example of affected code is