Changelog: swc v1.2.38

Bugfixes#

Parenthesis with comments (#1203)#

Previously [swc][] miscompiled

function isModuleWrapper(node: Expression) {
return (
// It's an anonymous function expression that wraps module
(node.type === "FunctionExpression" && !node.id) ||
node.type === "ArrowFunctionExpression" ||
isModuleId(node) ||
(node.type === "ArrayExpression" &&
node.elements.length > 1 &&
isModuleId(node.elements[0]))
);
}

as

function isModuleWrapper(node) {
return; // It's an anonymous function expression that wraps module
(node.type === "FunctionExpression" && !node.id) ||
node.type === "ArrowFunctionExpression" ||
isModuleId(node) ||
(node.type === "ArrayExpression" &&
node.elements.length > 1 &&
isModuleId(node.elements[0]));
}

This is now fixed fundamentally. The parenthesis remover pass now checks if a comment exists for inner node.

bundler: Stack overflow / circular imports (#1196, #1205)#

Now dependencies of circular imports of exports are handled correctly and topo sort algorithm is now applied correctly. The pr fixes number of bugs of deno bundle.

bundler: Handle swc helpers (#1199)#

Now if you use bundler with [swc], the helpers of [swc][] will be efficiently emitted.

Caching of import.meta (#1201)#

Thanks to @nayeemrmn, multiple usage of import.meta does not create multiple import.meta object.

resolver: hoist class decls (#1200)#

Although class declarations are not hoisted, it's a top-level item and should be handled before function bodies.

I mean,

(() => {
function foo() {
return new Bar();
}
class Bar {}
})();

should be treated as

(() => {
function foo__1() {
return new Bar__1();
}
class Bar__1 {}
})();