Skip to main content

Changelog: swc v1.2.67

· 3 min read

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

New API: Minification.#

Note: Currently, it's far from perfect. I decided to focus on real-world usages and only rules used by famous open source libraries are implemented. If the bundle size of your project is not good enough, please let me know. Feel free to file an issue or email me if it's a secret. (kdy1997.dev@gmail.com)

See the documentation for more details.

Bugfixes#

License for node packages (#1966)#

It's now Apache-2.0 AND MIT instead of MIT.

Typings for parse options (#1971)#

Type definitions for options is updated to reflect real config struct in rust.

Fixed by @sosukesuzuki and by #1971.

TypeScript: Overloads of private methods (#1977)#

Preivously overloads of methods with a private name was miscompiled. This bug could break code like

export class QueryClient {  #executeQuery(_query);  #executeQuery(_query);  #executeQuery(query) {    return this.#connection.query(query);  }}

but it's now fixed.

Fixed by @dsherret and by #1977.

codegen: Import statement (#1690)#

Useless space is removed from the code from import statements.

Fixed by @nuintun and by #1975.

Patterns in method parameters (#1948)#

Code like below now works properly.

function fn1(arg1, { opt1, opt2 }, ...arg2) {  console.log(arg1, opt1, opt2, arg2);}
function fn2(arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) {  console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);}
const fn3 = (arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) => {  console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);};
class cls {  constructor(arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) {    console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);  }
  fn4(arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) {    console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);  }}
export default {  fn5(arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) {    console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);  },  fn7: function* (arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) {    console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);    yield null;  },  *fn6(arg1, { opt1, opt2 }, arg2, { opt3, opt4 }, ...arg3) {    console.log(arg1, opt1, opt2, arg2, opt3, opt4, arg3);    yield null;  },};

Fixed by @kwonoj and by #1964.

optimizer: Hang (#1901, #1946)#

Previously optimizer had a bug which makes swc hang if object spread is used.

Fixed by #1950.

Property access in decorated class (#1869)#

Previously there was a bug related to property accesses in a decorated class.

@someClassDecoratorclass TestClass {  static Something = "hello";
  static SomeProperties = {    firstProp: TestClass.Something,  };}
function someClassDecorator(c) {  return c;}

Fixed by #1950.

TypeScript: Correct detection of usages (reported via deno)#

// temp.tsimport { Foo } from "./temp2.ts";
const a: Foo = null;console.log(a);const b = { Foo: 1 };console.log(b.Foo);

Previously Foo in b.Foo was treated as a usage of Foo, but it's now fixed and it's correctly removed.

Fixed by #1945.

Namespaced import with other imports (#1938)#

Previously swc throwed an error for

import reducer, * as SocketStore from "./redux/stores/socket-store";

but it's wrong to do so.

Fixed by @kwonoj and by #1940.