Changelog: swc v1.2.47

Bugfixes#

bundler: No more infinite loop (#1369)#

This was reported by a Deno user at https://github.com/denoland/deno/issues/8224. It was hard to debug because there was no test case, but fix was simple.

bundler: Refinsed cjs support (#1349)#

You can now use regenerator with spack, the bundler for the swc project.

Previously some cjs modules are incorrectly compiled.

bundler: Support for node js builtin modules (#1349)#

The bundler now supports importing / reexporting node js builtin modules. It currently does not touch such imports / exports.

bundler: Various bugfixes (#1349, )#

Some more bugs are fixed.

sourceMappingURL is respected (#1236)#

swc now respectes //# sourceMappingURL= in the input file.

sourceMappingURL relative to input file (#1255)#

swc now resolves source maps from two location (to prevent regression). It will try relative path first, and tries to resolve from root if source map isn't found.

Second check is to preserve breaking existing tools.

parser: Generator function with jsx enabled (#1299)#

swc can now parse code like

export const iteratorMapGenerator = function* <T, R>(
values: IterableIterator<T>,
execute: IteratorExecution<T, R>
): IterableIterator<R> {};

correctly.

js api: Respect isModule: false (#1258)#

swc now supports parsing a file as script. It would be useful if you are using non-strict mode codes.

cjs: Fix for export default-ed classes (#1213)#

Previously swc miscompiled

import foo from "foo";
class OK {
constructor() {
console.log(foo);
}
}
export default class NotOK {
constructor() {
console.log(foo);
}
}

as

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true,
});
exports.default = void 0;
var _foo = _interopRequireDefault(require("foo"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule
? obj
: {
default: obj,
};
}
class OK {
constructor() {
console.log(_foo.default);
}
}
class NotOK {
constructor() {
console.log(foo); // <- this is wrong
}
}
exports.default = NotOK;

which is wrong because of the line commented. It's now fixed.

typescript: Support for type-only namespaces (#1361)#

swc now correctly removes the namespace TestClass from the code below.

export class TestClass {
public testMethod(args: TestClass.TestArgs) {
return args.param1;
}
}
declare namespace TestClass {
export interface TestArgs {
param1: boolean;
}
}

New features#

bundler: Support for json modules (#1368)#

Reported as axios import error, but actually it was a bug related to importing json files.

New platform support#

windows ia32 (#1367)#

Thanks to @Brooooooklyn, swc now supports windows-ia32.