fix(ivy): make defineComponent tree shakable by Closure Compiler (#26425)
PR Close #26425
This commit is contained in:
@ -96,3 +96,16 @@ export function stringify(token: any): string {
|
||||
const newLineIndex = res.indexOf('\n');
|
||||
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convince closure compiler that the wrapped function has no side-effects.
|
||||
*
|
||||
* Closure compiler always assumes that `toString` has no side-effects. We use this quirk to
|
||||
* allow us to execute a function but have closure compiler mark the call as no-side-effects.
|
||||
* It is important that the return value for the `noSideEffects` function be assigned
|
||||
* to something which is retained otherwise the call to `noSideEffects` will be removed by closure
|
||||
* compiler.
|
||||
*/
|
||||
export function noSideEffects(fn: () => void): string {
|
||||
return '' + {toString: fn};
|
||||
}
|
Reference in New Issue
Block a user