Changelog: swc v1.2.53

Bugfixes#

bundler: Complex reexports within cycles (#1576)#

Previously there was some edge cases which is not properly handled by the swc bundler. The bug ocurred only when it's reexported using export *, was in a cylcle of dependency and requires some more complex conditions. It's is now fixed.

regnerator: Fix for delegating yields (#1580)#

There was a bug related to delegating yields (yield *) and it affected codes like

function* a() {
yield 5;
return 7;
}
function* b() {
let x = yield* a();
yield x + 1;
}
expect([...b()]).toEqual([5, 8]);

It's fixed by @devongovett.

Correct helper name (#1578)#

swc used incorrect helper name in some cases. It's fixed by @grimly

fixer: Fix for yields in ternaries (#1577)#

Previously swc miscompiled (yield foo) ? "bar" : "baz" as yield foo ? "bar" : "baz".

It's fixed by @devongovett.

codegen: Fix for rest patterns (#1573)#

Affected code looks like

function myFunc({ ...data }: { field: string }) {}

bundler: Various bugfixes (#1572)#

It includes bugfixes for complexly nested export *-s and the fix for a dead-code-elimination bug.

Fix for scope of functions (#1559)#

swc compiled

var Test = (function () {
var Test = (function () {
var Test = 2;
return Test;
})();
return Test;
})();

into

var Test = (function () {
var Test = (function () {
var Test1 = 2;
return Test; // <- this is wrong
})();
return Test;
})();

which is wrong, but the bug is now fixed and it emits

var Test1 = (function () {
var Test2 = (function () {
var Test3 = 2;
return Test3;
})();
return Test2;
})();

Fixed by @devongovett.

Fix for unknown object property accesses (#1567)#

swc now does not compile {}.foo as undefined anymore. Previously swc wrongly compiled it as such if optimizer is enabled.

Fixed by @mischnic.

Fix for parens of sequence expressions in callee and params (#1566)#

Previsously swc miscompiled

let x = ({}, () => 2)();

as

let x = {
}, ()=>2
();

which is clearly wrong.

Fixed by @devongovett.

this = globalThis in imported functions (#1561)#

import foo from "foo";
foo.bar();

is now compiled with module: commonjs as

const foo = require("foo"); // This is bit different.
(0, foo).bar();

to make this in bar point the module.

Fixed by @Austaras.

Block scoping of class declarations (#1569)#

const g = 20;
function baz() {
{
class g {}
}
return g;
}

is now

const g = 20;
function baz() {
{
class g1 {}
console.log(g1);
}
return g;
}

instead of previous

const g1 = 20; // <- this is wrong
function baz() {
{
class g1 {}
}
return g; // <- this is wrong
}

Fixed by @devongovett.