Skip to main content

Changelog: swc v1.2.65

路 One min read

To see full list of patches, please visit


paths (from tsconfig.json) (#1858)#

The support for paths is implemented in v1.2.62 but actually there was a bug and it's now also tested from node side codes. Previously only rust-side tests existed.

Fixed by #1932

input source map (#1930)#

swc can now input sourcemap correctly.

Fixed by #1932

regenerator: Fix for helpers (#1924)#

Pass ordering was wrong and it could cause problem if the only helper used comes from regenerator pass.

Fixed by @IronLu233 and by #1931.

rest patterns in arrow functions (#1926)#

Now codes like

const foo = (...args) => {  console.log(args);};

will work.

Changelog: swc v1.2.64

路 3 min read

To see full list of patches, please visit


Optional chaining (#1882)#

Previously swc had a bug related to nested optional chaining expressions.

const button = renderedView.find(LoadingButton);button?.prop('onClick')?.({} as any);

Fixed by @kwonoj and by #1899.

Visitor bug (#1886)#

The type definition for object patterns were wrong and it's fixed by #1900.

codegen: private static properties (#1898)#

Export default function with async (#1799)#

Previously if you target old version and use async function in a named export default function-s, swc didn't create a variable with same name.

Affected code looks like

import React from "react";
export default function Foo() {  return (    <div      onClick={async (e) => {        await doSomething();      }}    ></div>  );}
Foo.displayName = "Foo";

Fixed by #1900.

optional chaining with single-line arrow (#1836)#

Previously code like

function bug() {  const arrowFn = (arg) => this.object[arg]?.();}

was broken because variables are wrongly injected.

Fixed by #1900.

decorator (#1278)#

swc now initializes decorators right before they are applied.

This change allows referencing the class from decorator.

type Klass<T = any> = { new (...args: any[]): T };function MyDecorator(klass: Klass): PropertyDecorator {  return () => {    // do something    console.log(klass);  };}
class MyClass {  @MyDecorator(MyClass) prop: "";}
console.log(new MyClass());

Fixed by #1905.

regenerator: Exeception (#1892)#

Old versions of swc incorrectly throwed an error for a specific code.

Fixed by @kwonoj and by #1906

regenerator: Respect module config (#1641)#

swc now emits dependency for regenerator-runtime as es import statement, which is technically wrong but works because bundlers handle it.

regenerator: unused codes (#1687)#

Previously swc emitted useless codes.

Fixed by #1909.

typeof undefined (#1843)#

Previously swc could break a program if it uses typeof in specific way.

Fixed by #1909.

proper helpers (#1682)#

Previously module transforms were too naive and as a result could break some code.

Fixed by #1909

export * with named overrides (#1714)#

swc now allows overriding export * with named exports.

Code like below will work properly.

import { customRender } from "./customRender";
// re-export everythingexport * from "@testing-library/react";
// override render methodexport { customRender as render };

decorators for class properties (#1913)#

Previsouly swc could break codes like

import { action } from "mobx";
class Store {  constructor() {    this.doSomething();  }
  @action  doSomething = () => {    console.log("run");  };}
const store = new Store();

Fixed by @IronLu233 and by #1914.

await expressions as callee#

Previously swc could break code like

new (await foo())();

Fixed by #1919.

Changelog: swc v1.2.63

路 2 min read


common js: Duplicate named exports (#1780)#

Previously swc had a bug in common js handler which can break codes like

// constant.tsexport enum Foo {}
// File1.tsexport { Foo } from "./constant";
// file2.tsexport { Foo } from "./constant";
// index.tsexport const BIZ = "biz";export * from "./file1";export * from "./file2";

Fixed by #1846 and by @IronLu233.

bundler: Infinite hang (#1756)#

Previously the bundler hang on some complex circular import scenario.

Fixed by #1872.

comments in empty file (#1878)#

Previously swc stored comments in a file without any code as trailng comments, which is counterintuitive.

Fixed by #1879 and by @dsherret

typescript: < and > in template literal types. (#1862)#

Previously the parser of swc failed to parse < and > used in template literals, like

type A = `<`;

Fixed by #1885 and by @SimonRask

typescript + react: declare module (#1865)#

Previsouly react fast refresh transform of swc were broken by typescript declare module statements, like

function useHooks() {  return useMemo(() => 1);}
declare module "x" {}

Fixed by #1875 and by @Austaras.

method with keyword as the name (#1838)#

Previsouly swc had a bug which breaks code if a keyword is used as a method name, like

class Foo {  let() {}}

Fixed by #1891 and by @Austaras

Visitor bugs (#906, #1625, #1819, #1888)#

Fixed by #1890


License of wasm (#1798)#

License of @swc/wasm and @swc/wasm-web is now Apache-2.0 AND MIT, not Apache-2.0/MIT. This may affect license checking tools.

Fixed by #1874

Changelog: swc v1.2.62

路 One min read


Comments (#1165)#

swc doesn't drop comments anymore.

modules: Var names (#1787)#

Previously swc had a bug which can break code if file name meets some condition.

Fixed by @cspotcode.

typescript: Object pattern (#1835)#

import { A } from "./a";import { B } from "./b";
const { A: AB } = B;
console.log(A, AB);

Previosuly swc dropped A because of bug in variable collector.

Fixed by @Austaras.

Fix helper used by module pass (#1829)#

Previously swc sometimes used wrong helper for module imports.

Fixed by @cspotcode.

fixer: call in new #1857#

new (foo())();

Previously swc incorrrectly striped (foo()) as foo().

Fixed by @motiz88.

optimizer: nullish coalescing operator (#1851)#

x ?? (x = "abc");

Preivousy the optmizer of swc incorrectly optimized it as x = "abc";. It's now fixed.


Supports for path aliasing (#702)#

swc now supports paths, which uses identical syntax for paths in tsconfig.json.

Better sourcemap (, , )#

Source map generated by swc is greayly improved.

Changelog: swc v1.2.61

路 2 min read


parser: Long numeric literals (#1803, #1806)#

swc now can handle very long numeric literals like




logical assignments (#1788)#

swc now transpiles

a ||= b;


a ??= b;


escapes in jsx properties (#1782)#

There was a bug which make using unicode chracters in jsx properties hard.

preset-env: Nullish assignments (#1812)#

Because some browsers support nullish coaelscing operator while not supporting nullish assignments, I patched swc to transpile assignments to assignment with nullish coaelscing operator.

Line terminators in literals (#1754)#

EcmaScript allows some strange chracters to be used in a string literal. Previously swc didn't allow it, but it's now fixed by @tmpfs.

optimizer: Side effects of while (#1825)#

Previsously the dead branch remover of swc was to aggressive and could break codes like

while ((p(), 1)) {}while ((await, 1)) {}

This is now fixed.

parser: Undefined unicode codepoints (#1813)#

For rust-side users of swc, the code below made program error with arithmetic overlfow.


Platform support#

old linux (#1809)#

swc now uses older version of glibc to support old linux environments.

Done by @Brooooooklyn

Changelog: swc v1.2.60

路 2 min read


super in decorated methods (#846)#

Previously swc emitted wrong code if a method call from super is used.

class SomeClass {  @dec  someMethod() {}}
class OtherClass extends SomeClass {  @dec  anotherMethod() {    super.someMethod();  }}

Codes like above now works properly.

dce: Fix for decorated classes (#1769)#

@decoratorclass Class {}
function decorator(cls: any) {  console.log(;}

Previously swc dropped a class if it's decorated and not instantiated. This is wrong because decorators can have side effects and now it's fixed.

bundler: Prevent hang (#1779)#

In certain complex import scenarios, the bundler of swc hanged while determinging cycle imports. This is now fixed and fairly complex imports are now handled by the bundler.

fixer: Binary expressions in unary operands (#1781, #1789)#

There was a regression related to parenthesis.

const n = ~~(Math.PI * 10);
const c = +(+1 / 4);console.log(c);

These was miscompiled but it's now fixed.

Support for export * with same name (#1780)#

swc now supports code like

// constant.tsexport enum Foo {}
// File1.tsexport { Foo } from "./constant";
// file2.tsexport { Foo } from "./constant";

Fix for double imports (#1757)#

Previously swc throwed an error for double imports like

import "testlibrary";import { aFunc } from "testlibrary";
console.log("aFunc: ", aFunc(1, 2));

It's now fixed.

Fix for async generator (#1752)#

Previously swc miscompiled await in async generators and codes like

async function* generate(): AsyncGenerator {  const results = await Promise.all([    Promise.resolve(1),    Promise.resolve(2),    Promise.resolve(3),  ]);  for (const result of results) {    console.log(`yield ${result}`);    yield result;  }}
async function printValues() {  const iterator = generate();  for await (const value of iterator) {    console.log(`iterator value: ${value}`);  }}

was broken. It's now fixed.

Changelog: swc v1.2.59

路 3 min read


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 {};console.log(fn());

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.

Changelog: swc v1.2.58

路 3 min read


codegen: \r\n in template literals. (#1707)#

This happens only if your target is es2016 or upper. This issue is reported via a deno issue, and

const content1 = `first line\r\nsecond line\r\nthird line`;
const content2 = `first linesecond linethird line`;
console.log({ content1, content2 });

now works properly.

fixer: null ?? (undefined && true). (#1709)#

This issue is reported via a deno issue. This is fixed by explicitly handling a ?? (b && c).

optimizer: Preserve optional chaining expressions. (#1688)#

({ notafunction: null }?.notafunction?.());
({ notafunction: null }?.notafunction());
({ notafunction: null }.notafunction?.());

swc preivously didn't handle optional chaining expresison propely and had break the codes above. It's now fixed.

optimizer: Side-effects of [x, y][0]. (#1674)#

Previously the optimizer of swc had a bug which breaks code like

let foo = "info";
var bar = [foo, (foo = "other")][0];
console.log(foo == "other");console.log(bar == "info");

It's now fixed.

parser: Non-identifier names in getters. (#1671)#

const thing = {  get "a-b"() {    return "abc";  },};console.log(thing["a-b"]);

Due to a bug, swc previously faild to parse the code above. It's now fixed.

parser: Class member named declare (#1671)#

class A {  private declare() {}}

The code above now works properly.

compat: async-to-generator (#1721, #1722)#

swc now compiles

async function* lol() {  yield 1;  yield 2;}
async function main() {  for await (const x of lol()) {    console.log(x);  }}main();


(async function main() {  console.log(1);})();


react: Remove panic call (#1683)#

const config = {  test: /\.[jt]sx?$/i,  exclude: /[\\/]node_modules[\\/]/,  use: [    {      loader: "swc-loader",      options: {        jsc: {          target: "es5",          parser: {            tsx: true,            decorators: true,            syntax: "typescript",            dynamicImport: true,          },          transform: {            react: {              runtime: "automatic",            },          },          externalHelpers: true,        },      },    },  ],};

swc had a bug in new jsx pass which resulted in an exception thrown. It's now fixed.

parser: Type-only import equals (#1695)#

import type React = require("react");

This is valid syntax since typescript 4.2, but swc didn't support it.

Fixed by @g-plance.

compat: Private methods (#1694, #1702, #1711)#

Previously swc had a bug related to private class methods.

preset-env: Update compat data (#1704, #1719)#

The compatibility data was outdated.

typescript: Preserved module context (#1698, #1706)#

tsc emits

export {};


export type Foo = number;

while other tools do not preserve the information that the file is module.

Because swc prefers the bahavior of tsc over the one of babel, swc now emits export {} for type-only modules.

wasm-web: Support for bundlers (#1675)#

The @swc/wasm-web package now use correct command while publishing so it has correct data in package.json.

api: Types for react pass. (#1720)#

Fixed by @Brooooooklyn.

Changelog: swc v1.2.57

路 3 min read


Perfoemance (#1673)#

This pr adds lots of fast path for es2015 passes, and the addition of fast-paths removes lots of useless memcpy calls. The time used for es2015 -> es5 transforms is reduced about 33%. (It's now 50% faster).

Codegen of class expressions (#1660)#

Previously swc compiled

console.log(  class {    run() {}  });


console.log(  (function () {    var _class = /*#__PURE__*/ (function () {      "use strict";      function _class() {        _classCallCheck(this, _class);      }      _createClass(_class, [        {          key: "run",          value: function run() {},        },      ]);      return _class;    })();    return _class;  })());

which is not optimal.

Starting from swc v1.2.57, swc emits

console.log(/*#__PURE__*/ function() {        "use strict";        function _class() {            _classCallCheck(this, _class);        }        _createClass(...);        return _class;    }());

New features#

Pure comment for classes pass. (#1646)#

swc now emits /*#__PURE__*/ for classes to help javascript minifiers.

TypeScript: override with static (#1663)#

Implemented by @g-plane.

TypeScript: Support override in parameter properties (#1667)#

Implemented by @g-plane.


This section contains internal improvements, which are mostly done for the new typesciprt checker I'm working on.

Function declarations in ts modules (#1665)#

Previously, swc didn't identified F2s in below code.

module M {  export class A {    name: string;  }
  export function F2(x: number): string {    return x.toString();  }}
module N {  export class A {    id: number;  }
  export function F2(x: number): string {    return x.toString();  }}

This bug resulted in a bug of stc, the typescript type checker I'm working on.

Function declarations in arrow expressions (#1666)#

Previously, the ts_resolver pass did not distinguish two bar in code below. The bug does not affect swc users because the bug only occurs when two separate arrow expressions contains a function named identically.

var f3 = <T, U extends T>(x: T, y: U) => {  function bar<V extends T, W extends U>() {    var g = <X extends W, Y extends V>(a: X, b: Y): T => {      x = y;      return y;    };  }};var f4 = <U extends T, T>(x: T, y: U) => {  function bar<V extends T, W extends U>() {    var g = <X extends W, Y extends V>(a: X, b: Y): T => {      x = y;      return y;    };  }};

For of/in loops (#1672)#

Previously, the ts_resolver pass did not distinguish v in code below.

for (const v of new FooIterator()) {  const v = 0; // new scope}

This bug is theoritically possible to affect real world codes, but it would not. So it is listed on the misc section.