Changelog: swc v1.2.48


Parsing of generics (#1405)#

The parser of swc failed to parse below code if tsx is enabled.

function foo<P extends RouteParams = RP, S extends State = RS>(
name: string,
path: string,
...middleware: RouterMiddleware<P, S>[]
): Router<P extends RP ? P : P & RP, S extends RS ? S : S & RS>;

This is reported by a deno team member via discord and now it's fixed.

await (await foo)() (#1395)#

swc now doesn't break code like below.

await(await foo)();

Catch parameters (#1413)#

swc previously miscompiled code like below.

var e = 1;
try {
throw 2;
} catch {

This was the case because the hygiene passs didn't do caclulated renaming operations while handling a catch clause. It's now fixed.

Bundler bugfixes#

Correct handling of export defaults (#1373)#

Previously the bundler miscompiled some export-default-ed functions if it depends on hoisting.

Affected code looks like

import log from "./log.js";
export default async function cli() {
log("It works!");

but it's now fixed.

Performacne improvements#

Parser performance improvement (#1411)#

This pr was intended to reduce wasted memry space and it resulted in 10% performance boost of the parser.

New features#

New jsx transforms (#1408)#

Config api is almost identical with the one of babel.

preset-env with custom config path (#1374)#

Thanks to @mcnicholls, swc now supports using .browserlistrc or package.json in any path for determining environment.

See docs for more details.


Reduction of binary size (#1418)#

Thanks to @Brooooooklyn, the binary size of swc is reduced.