Skip to main content

Changelog: swc v1.2.94

· 2 min read

To see full list of patches, please visit https://github.com/swc-project/swc/milestone/195?closed=1

Improvements#

Improved performance#

swc is now even faster than before. It uses faster Mutex implementation for global locks, and does not do syscall if it's not required. I also removed some useless memory operations like memmove.

Done by #2329 and #2356.

Additionally, some duplicated passes are removed by #2347 and #2367.

bundler: Concurrent bundling#

Although the bundler of swc is designed to be run in parallel, concurrent mode was not enabled because I was busy working on other bugs.

Implemented by #2356.

jsx: Allow directives in any statement#

This is required to use mdx-loader with swc.

Implemented by #2377.

Bugfixes#

parser: Error for array patterns#

Previously swc allowed

const [a b] = arr

but now it's an error.

Implemented by @g-plane and by #2365.

parser: Error for array expressions#

Previously swc allowed

const arr = [a b]

but now it's an error.

Implemented by @g-plane and by #2366.

minifier: inlining of iife#

Previously, swc replaces parameters of an IIFE if the corresponding argument is an identifier or a literal. But replacing identifier can cause problems, so swc now only replaces with literals.

Fixed by #2355

minifier: inlining and shorthand#

Previously, if the minifier of swc decides to inline something which is used only once in a shorthand, swc revmoed the node without modifying the usage part in a shorthand property.

minifier: new String#

swc had some assumptions about code, just like the old version of the google closure compiler. The assumption was that a property of string is never modified. But the rule does not fit real-world codes, and the assumption broke some code.

Fixed by #2341

dead_branch_remover bug (#2328)#

Previously, swc could break code like

switch (true) {  case true:    console.error("true (expected branch)");    break;
  case false:    console.error("false (dead branch)");    break;
  default:    console.error("default (dead branch)");    break;}

Fixed by @mischnic and by #2373

bundler: trivial bug#

The code for handling configs had a trivial bug.

Fixed by @amoshydra and by #2335.