Is there a way to tell Google Closure Compiler to *NOT* inline my local functions?

核能气质少年 提交于 2019-12-01 14:24:35

In this case, you would either need to make a custom build of the compiler or use the Java API.

However - disabling inlining is not enough to make this safe. Renaming and dead code elimination will also cause problems. This violates core assumptions of the compiler. This local function is ONLY referenced from within strings.

This code is only safe for the WHITESPACE_ONLY mode of the compiler.

Use the function constructor

var fnc = new Function("param1", "param2", "alert(param1+param2);");

Closure will leave the String literals alone.

See https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!