Skip to content

Commit

Permalink
fix(es/minifier): Handle synthesized export default expression (swc-p…
Browse files Browse the repository at this point in the history
…roject#7707)

**Related issue:**

 - Closes swc-project#7634.
  • Loading branch information
Austaras authored and kdy1 committed Aug 15, 2023
1 parent c42c2ca commit 9813d53
Show file tree
Hide file tree
Showing 36 changed files with 447 additions and 476 deletions.
20 changes: 10 additions & 10 deletions crates/swc/tests/fixture/issues-2xxx/2717/output/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { _ as e } from "@swc/helpers/_/_ts_generator";
import { takeLatest as t, select as r } from "redux-saga/effects";
import { CHANGE_THEME as o, CHANGE_THEME_CUSTOM_PALETTE as s, CHANGE_THEME_SWITCH_MODE as a } from "core/actions/changeTheme";
export var selectThemeObject = function(n) {
return n.theme;
export var selectThemeObject = function(e) {
return e.theme;
};
export function saveTheme(n) {
var c, i, m;
export function saveTheme(t) {
var o, s, n;
return e(this, function(e) {
switch(e.label){
case 0:
return c = n.type, [
return o = t.type, [
4,
r(selectThemeObject)
];
case 1:
return i = e.sent(), window.localStorage.setItem("theme", JSON.stringify({
theme: i.theme,
mode: i.mode,
palette: i.palette
})), c === a && (m = window.document.querySelector("body")) && (m.classList.add("light" === i.mode ? "light" : "dark"), m.classList.remove("light" === i.mode ? "dark" : "light")), [
return s = e.sent(), window.localStorage.setItem("theme", JSON.stringify({
theme: s.theme,
mode: s.mode,
palette: s.palette
})), o === a && (n = window.document.querySelector("body")) && (n.classList.add("light" === s.mode ? "light" : "dark"), n.classList.remove("light" === s.mode ? "dark" : "light")), [
2
];
}
Expand Down
10 changes: 5 additions & 5 deletions crates/swc/tests/fixture/issues-7xxx/7546/output/1.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { ClassName } from "./some-file";
export default {
field: /*#__PURE__*/ function(ClassName1) {
field: /*#__PURE__*/ function(ClassName) {
"use strict";
_inherits(ClassName2, ClassName1);
function ClassName2() {
return ClassName1.call(this);
_inherits(ClassName1, ClassName);
function ClassName1() {
return ClassName.call(this);
}
return ClassName2;
return ClassName1;
}(ClassName)
};
2 changes: 1 addition & 1 deletion crates/swc/tests/fixture/sourcemap/003/output/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
export default function E() {
_class_call_check(this, E);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
export default function E() {
_class_call_check(this, E);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
import { Foo } from "./Foo.js";
var Bar = /*#__PURE__*/ function(Foo1) {
var Bar = /*#__PURE__*/ function(Foo) {
"use strict";
_inherits(Bar, Foo1);
_inherits(Bar, Foo);
var _super = _create_super(Bar);
function Bar() {
_class_call_check(this, Bar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
import { Foo } from "./Foo.js";
(function(Foo1) {
_inherits(Bar, Foo1);
(function(Foo) {
_inherits(Bar, Foo);
var _super = _create_super(Bar);
function Bar() {
return _class_call_check(this, Bar), _super.apply(this, arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
var m = require("./exporter");
module.exports = m.default, module.exports.memberName = "thing";
//// [exporter.js]
export default function() {};
export default function() {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
import Fab from "./index3";
var Bar = /*#__PURE__*/ function(Fab1) {
var Bar = /*#__PURE__*/ function(Fab) {
"use strict";
_inherits(Bar, Fab1);
_inherits(Bar, Fab);
var _super = _create_super(Bar);
function Bar() {
_class_call_check(this, Bar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
import { _ as _inherits } from "@swc/helpers/_/_inherits";
import { _ as _create_super } from "@swc/helpers/_/_create_super";
import Fab from "./index3";
var Bar = function(Fab1) {
_inherits(Bar, Fab1);
var Bar = function(Fab) {
_inherits(Bar, Fab);
var _super = _create_super(Bar);
function Bar() {
var _this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
export var el = null;
export default function A() {
_class_call_check(this, A);
};
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9813d53

Please sign in to comment.