Preserve ProxyDummy function name after minification
This commit is contained in:
parent
c01a8c2f78
commit
74f36a093b
|
@ -77,7 +77,13 @@ export function proxyLazy<T = AnyObject>(factory: () => T, attempts = 5, isChild
|
|||
let isSameTick = true;
|
||||
if (!isChild) setTimeout(() => isSameTick = false, 0);
|
||||
|
||||
const proxyDummy = Object.assign(function ProxyDummy() { }, {
|
||||
// Define the function in an object to preserve the name after minification
|
||||
const dummyObj = {
|
||||
ProxyDummy() { }
|
||||
} as { ProxyDummy: any; };
|
||||
|
||||
const proxyDummy = dummyObj.ProxyDummy;
|
||||
Object.assign(proxyDummy, {
|
||||
[proxyLazyGet]() {
|
||||
if (!proxyDummy[proxyLazyCache]) {
|
||||
// @ts-ignore
|
||||
|
@ -99,6 +105,8 @@ export function proxyLazy<T = AnyObject>(factory: () => T, attempts = 5, isChild
|
|||
[proxyLazyCache]: void 0 as T | undefined
|
||||
});
|
||||
|
||||
delete dummyObj.ProxyDummy;
|
||||
|
||||
const proxy = new Proxy(proxyDummy, {
|
||||
...handler,
|
||||
get(target, p) {
|
||||
|
|
|
@ -58,7 +58,13 @@ export function proxyInner<T = AnyObject>(
|
|||
let isSameTick = true;
|
||||
if (!isChild) setTimeout(() => isSameTick = false, 0);
|
||||
|
||||
const proxyDummy = Object.assign(function ProxyDummy() { }, {
|
||||
// Define the function in an object to preserve the name after minification
|
||||
const dummyObj = {
|
||||
ProxyDummy() { }
|
||||
} as { ProxyDummy: any; };
|
||||
|
||||
const proxyDummy = dummyObj.ProxyDummy;
|
||||
Object.assign(proxyDummy, {
|
||||
[proxyInnerGet]: function () {
|
||||
if (proxyDummy[proxyInnerValue] == null) {
|
||||
throw new Error(errMsg);
|
||||
|
@ -69,6 +75,8 @@ export function proxyInner<T = AnyObject>(
|
|||
[proxyInnerValue]: void 0 as T | undefined
|
||||
});
|
||||
|
||||
delete dummyObj.ProxyDummy;
|
||||
|
||||
const proxy = new Proxy(proxyDummy, {
|
||||
...handler,
|
||||
get(target, p) {
|
||||
|
|
Loading…
Reference in a new issue