Changelog: swc v1.2.25

Bugfixes#

codegen of block comment (#1062)#

Previously, swc injected a newline after block comments.

This is wrong behavior, as it can break some codes. Especially, the code below is broken.

return /*****/ function () {};

It was compiled as

return /*****/
function () {};

which is equal to

return /*****/;
function () {};

due to automatic semicolon insertion and it's broken as the return value is changed and function () {} is a function declaration, not a function expression.

meta properties (#1053)#

swc now compiles meta properties correctly.

class ArgumentValidationError extends Error {
constructor(public validationErrors: ValidationError[]) {
super("Argument Validation Error");
Object.setPrototypeOf(this, new.target.prototype);
}
}

common js: order of exports (#1057)#

Previously, swc does not follow the order declared in the soruce file while emitting imports and exports. As a result, cyclic imports were broken. This is now fixed, and

export * from "./http";
export { Scope } from "./interfaces";

is compiled as

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
var _interfaces = require("./interfaces");
var _http = require("./http");
Object.defineProperty(exports, "Scope", {
enumerable: true,
get: function () {
return _interfaces.Scope;
},
});
Object.keys(_http).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _http[key];
},
});
});

instead of

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
Object.defineProperty(exports, "Scope", {
enumerable: true,
get: function () {
return _interfaces.Abstract;
},
});
var _interfaces = require("./interfaces");
var _http = require("./http");
Object.keys(_http).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _http[key];
},
});
});

calling conditional expressions (#1051)#

This affects code like

(a) => (set) => (elemE(a, set) ? removeE : insertE)(a)(set);