Changelog: swc v1.2.7


crash of spack (#872)#

The swc manages the span in a fairly unusual way. It manages span information by creating a global map and assigning a range in it. The global map should be protected with an atomic variable or mutex because swc supports threading.

To improve performance, area allocation is processed as one atomic operation and actual file data is protected using mutex, which was mixed with a bug that overlaps the span of multiple files. This bug later caused a crash in the process of printing javascript code, thus aborting the process. (Aborting is a limitation of neon)

I changed the code so that the two don't mix. As a multi-threading issue, I can't say it's 100% solved because it's hard to reproduce, but it's likely that it's fixed.

Paren expression in left side (#861)#

(x) = (6);

Previous versions of swc interpreted this code differently than it was.

In the case of JavaScript, grammar was so complicated that various tricks were involved when implementing parser. Among them, there is a trick to determine whether it is a pattern or an expression. It is, when an unknown token comes after the left parenthesis, it is first treated with an expression, and then if it is assignment to a variable or if it is a pattern it is parsed as pattern again. The bug occurred because there was a bug that processes '(x)' as 'x' in the process of parsing again.

TypeScript 4.0 support#

non-last rest element in tuple (#864)#

type Strings = [string, string];
type Numbers = [number, number];
// [string, string, number, number]
type StrStrNumNum = [...Strings, ...Numbers]; // works now

new assignment operators (#866)#

a &&= b;
a ||= b;
a ??= b;

labels in tuple types (#865)#

type Range = [start: number, end: number];