Changelog: swc v1.2.59


Fix for arguments in for loops (#1462)#

Previously the helper of swc was broken by this bug. It's now fixed and new version of @swc/helpers works properly.

regnerator: var in proper level (#1718)#

Previously swc might break codes like

async function scanUser(groups: { users: number[] }[]) {
await Promise.all( ({ users }) => {
for (const user of users) {
console.log("user", user);
await new Promise((resolve) => setTimeout(resolve, 30));
scanUser([{ users: [1, 2, 3, 4, 5] }, { users: [11, 12, 13, 14, 15] }]);

because the variable for iterator are recycled while it should not. It's now fixed by injecting variables at proper level.

escapes in jsx attribute values (#1661)#

The afffected code looks like

console.log(<h1 value="abc\nas">s</h1>);

regenerator: || handled properly (#1684)#

Previously swc had a bug related to await in rhs of || and code like

const cache = {};
async function getThing(key) {
const it = cache[key] || (await fetchThing(key));
return it;
function fetchThing(key) {
return Promise.resolve(key.toUpperCase()).then((val) => (cache[key] = val));

was miscompiled.

It's now fixed.

bundler: Complex circular imports (#1739)#

In a very complex cirular import scenario, the bundler may hang because of infinite recursions.

It's now fixed.

typscript: Arrow expr with class expr

The typescript type stripped of swc compiled arrow expressions with a class expression as a body wonrly.

The affected code looks like and it's now fixed.

const fn = () => class Bug {};

codegen: Unicode characters (#1744)#

Previously swc could break codes for old targets like

console.log("🤭 ü");

It's not fixed.

this in tagged template literals (#1742)#

swc, just like babel, had a bug related to this in tagged template literals. This bug could break code like

class Foo {
#tag() {
return this;
#tag2 = this.#tag;
constructor() {
const receiver = this.#tag`tagged template`;
console.log(receiver === this);
const receiver2 = this.#tag2`tagged template`;
console.log(receiver2 === this);
new Foo();

parser: TS1031

Previously swc wrongly emitted an error for

class Foo {
declare a: string;

Fixed by @Shinyaigeek.

API type definition #1746#

The typescript type checker will not report error for keepClassNames anymore.

bundler: Support for file names ending with period. (#1748)#

Previously the bundler failed to bundler [email protected]^2 because of a bug in the resolver.

Fixed by @tmpfs.

bundler: Updated list for core modules. (#1749)#

node.js added some core modules and using them with the bundler resulted in an error because it tried to resolve it in node_modules.

Fixed by @tmpfs.

codegen: Class with minify and higher target (#1764)#

Previously swc had a codegen bug related to a class with es2016+ target and minify enabled.

Fixed by @Shinyaigeek.

New platform support#

FreeBSD (#1758)#

@Brooooooklyn, the author of a wonderful rust library for creating node modules, added supports for FreeBSD.