Skip to content

Enable --assume_function_wrapper Closure Compiler option #5795

@cpcallen

Description

@cpcallen

Is your feature request related to a problem? Please describe.

A feature request that will help with the problem of the size of blockly_compressed.js having grown substantially over the last two quarters.

Describe the solution you'd like

Enable the --assume_function_wrapper option in the options object passed to compile by buildCompiled in scripts/gulpfiles/build_tasks.js. This would (as of this writing) reduce the size of blockly_compressed.js from 907 to 623 KiB, and blockly_compressed.js.gz from 168 to 151 KiB.

Describe alternatives you've considered

Enabling ADVANCED_OPTIMIZATIONS would have an even greater effect, but would (absent additional work to prevent this) result in most of the export properties (and class .prototype properties) being renamed, rendering our API hopelessly broken.

Additional context

The one issue to be resolved is that --assume_function_wrapper causes the top-level Blockly export (i.e., the one created by the call to goog.module.declareLegacyNamespace() in core/blockly.js) to be renamed from $.Blockly to $.X (where X is, by chance literally an X, but could be any short 1–2 letter name), breaking the UMD wrapper.

We will need to determine how best to arrange for the UMD wrapper to return the Blockly exports object despite this renaming.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions