-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Make
Finalizer
inline literals (#8285)
**Related issue:** - Closes #8284
- Loading branch information
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_minifier/tests/fixture/issues/8284/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"hoist_funs": true, | ||
"defaults": true, | ||
"toplevel": true, | ||
"passes": 0 | ||
} |
36 changes: 36 additions & 0 deletions
36
crates/swc_ecma_minifier/tests/fixture/issues/8284/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(function (global, factory) { | ||
typeof exports === "object" && typeof module !== "undefined" | ||
? factory(exports) | ||
: typeof define === "function" && define.amd | ||
? define(["exports"], factory) | ||
: ((global = | ||
typeof globalThis !== "undefined" ? globalThis : global || self), | ||
factory((global.Sentry = {}))); | ||
})(this, function (exports) { | ||
"use strict"; | ||
function isGlobalObj(obj) { | ||
return obj && obj.Math == Math ? obj : undefined; | ||
} | ||
const GLOBAL_OBJ = | ||
(typeof globalThis == "object" && isGlobalObj(globalThis)) || | ||
// eslint-disable-next-line no-restricted-globals | ||
isGlobalObj(globalThis) || | ||
(typeof self == "object" && isGlobalObj(self)) || | ||
(typeof global == "object" && isGlobalObj(global)) || | ||
(function () { | ||
return this; | ||
})() || | ||
{}; | ||
function getGlobalObject() { | ||
return GLOBAL_OBJ; | ||
} | ||
const WINDOW$6 = getGlobalObject(); | ||
function supportsFetch() { | ||
if (!("fetch" in WINDOW$6)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
console.log(supportsFetch()); | ||
}); |
12 changes: 12 additions & 0 deletions
12
crates/swc_ecma_minifier/tests/fixture/issues/8284/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var global1, factory; | ||
global1 = this, factory = function(exports1) { | ||
function isGlobalObj(obj) { | ||
return obj && obj.Math == Math ? obj : void 0; | ||
} | ||
"use strict"; | ||
console.log("fetch" in ("object" == typeof globalThis && isGlobalObj(globalThis) || isGlobalObj(globalThis) || "object" == typeof self && isGlobalObj(self) || "object" == typeof global && isGlobalObj(global) || function() { | ||
return this; | ||
}() || {})); | ||
}, "object" == typeof exports && "undefined" != typeof module ? factory(exports) : "function" == typeof define && define.amd ? define([ | ||
"exports" | ||
], factory) : factory((global1 = "undefined" != typeof globalThis ? globalThis : global1 || self).Sentry = {}); |