Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/minifier): Fix react-ace #4183

Merged
merged 5 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
var M;
M || (M = {}), this.bar;
!function(M) {
this.bar;
}(M || (M = {}));
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var M;
import * as swcHelpers from "@swc/helpers";
M || (M = {}), swcHelpers.defineProperty({}, this.bar, 0);
!function(M) {
swcHelpers.defineProperty({}, this.bar, 0);
}(M || (M = {}));
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
var M;
M || (M = {}), this.bar;
!function(M) {
this.bar;
}(M || (M = {}));
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var M;
import * as swcHelpers from "@swc/helpers";
M || (M = {}), swcHelpers.defineProperty({}, this.bar, 0);
!function(M) {
swcHelpers.defineProperty({}, this.bar, 0);
}(M || (M = {}));
6 changes: 4 additions & 2 deletions crates/swc_ecma_minifier/src/compress/optimize/iife.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use rustc_hash::FxHashMap;
use swc_atoms::js_word;
use swc_common::{pass::Either, util::take::Take, Spanned, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::{contains_arguments, ident::IdentLike, undefined, ExprFactory, Id};
use swc_ecma_utils::{
contains_arguments, contains_this_expr, ident::IdentLike, undefined, ExprFactory, Id,
};
use swc_ecma_visit::VisitMutWith;

use super::{util::MultiReplacer, Optimizer};
Expand Down Expand Up @@ -586,7 +588,7 @@ where
return false;
}

if contains_arguments(body) {
if contains_this_expr(body) || contains_arguments(body) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3819,7 +3819,9 @@
var check = function(it) {
return it && it.Math == Math && it;
};
module.exports = check('object' == typeof globalThis && globalThis) || check('object' == typeof window && window) || check('object' == typeof self && self) || check('object' == typeof __webpack_require__.g && __webpack_require__.g) || this || Function('return this')();
module.exports = check('object' == typeof globalThis && globalThis) || check('object' == typeof window && window) || check('object' == typeof self && self) || check('object' == typeof __webpack_require__.g && __webpack_require__.g) || function() {
return this;
}() || Function('return this')();
},
1521: function(module, __unused_webpack_exports, __webpack_require__) {
var toObject = __webpack_require__(89343), hasOwnProperty = {}.hasOwnProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,9 @@
},
function(module, exports) {
var g;
g = this;
g = function() {
return this;
}();
try {
g = g || new Function("return this")();
} catch (e) {
Expand Down
Loading