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

前端 未结 2 1442
无人及你
无人及你 2021-01-17 03:35

Here\'s what I\'m looking for:

  • I want to use the wonderful features of SIMPLE mode minification while disabling just one specific feat
相关标签:
2条回答
  • 2021-01-17 04:13

    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.

    0 讨论(0)
  • 2021-01-17 04:26

    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

    0 讨论(0)
提交回复
热议问题