ChangeLog: swc v1.2.31

Domain change#

The swc project now uses, instead of Thank you contributors!


(spack) export * in entry (1083)#

Previously, export * from './a' only worked in non-entry files. It's a common pattern to export everything from main module, so I think it's an important improvement.

let with for in/of (#1086)#

Previously, swc miscompiled the code shown below.

const b = [];
let a;
for (a in b) {

The bug is realted to left hand side in the for-in loop.

File names in the source map is preserved (#1091)#

This is about feeding source code into swc after processing using other tools with source map support.

@lujjjh kindly found the cause and proposed solution.

(spack) Fixed imports (#1076)#

The spack had a bug related to packages without main field in package.json.

optional chaining (#1092)#

Starting with the version, swc can compile


into the correct output, namely

a === null || a === void 0 ? void 0 : a.b.c();

logical operators and function calls (#1093)#

Previously, swc erroneously removed the parenthesis which wraps fnA || fnB. This is now fixed.

const fnA = () => {
console.log("Output from function A");
const fnB = () => {
console.log("Output from function B");
const x = (fnA || fnB)();

regenerator scoping issue (#1036)#

I had a hard time debugging this, because all pass work correctly. It was pass ordering issue, and I fixed pass ordering. The bug affects user who used an array pattern ([a,,c]) or an object pattern ({ a: foo }) within async function.

Example of the affected code is show below.

const x = async function () {
await Promise.all(
[[1], [2], [3]].map(async ([a]) => Promise.resolve().then(() => a * 2))