Licensed to the Apache Software Foundation (ASF) under one or more

contributor license agreements. See the NOTICE file distributed with

this work for additional information regarding copyright ownership.

The ASF licenses this file to You under the Apache License, Version 2.0

(the “License”); you may not use this file except in compliance with

the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an “AS IS” BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

layout: docpage title: Compiler Options description: List of available compiler options permalink: /compiler/compiler-options

Compiler Options

List of available compiler options

Contents

General compiler options

JavaScript compiler options

Reduce output size You can use these options to reduce the size of your compiled application:

General compiler options

allow-abstract-classes

Determines if the abstract modifier may be used with classes. For more details, see Abstract Classes in ActionScript.

-allow-abstract-classes

allow-import-aliases

Determines if alias syntax for for imported symbols is allowed or not.

-allow-import-aliases

allow-private-constructors

Determines if the private namespace may be used with class constructors. For more details, see Private Constructors in ActionScript.

-allow-private-constructors

strict-identifier-names

Determines if names of identifiers must follow the strict rules of ActionScript 3.0, or if they may use the looser rules introduced in ECMAScript 5. Defaults to false.

-strict-identifier-names

JavaScript compiler options

closure-lib

Sets the path to a custom distribution of Google's Closure library, instead of the default version used by the compiler.

-closure-lib path/to/closure

html-output-filename

Specifies the file name of the HTML file generated by the compiler to load the Apache Royale application in the browser.

-html-output-filename custom.html

html-template

Specifies the path to an optional template for the HTML file generated by the compiler to load the Apache Royale application in the browser.

-html-template ./path/to/template.html

Maven configuration:

<htmlTemplate>${basedir}/target/javascript/bin/js-debug/jewel-example-index-template.html</htmlTemplate>

inline-constants

Determines if primitive constant values (such as numbers, booleans, and strings) will be inlined.

-inline-constants

Maven configuration:

<additionalCompilerOptions>-inline-constants=true;</additionalCompilerOptions>

js-compiler-option

Specifies one or more custom compiler options to pass to the Google Closure Compiler, which is used to create the release build of an Apache Royale application.

-js-compiler-option+="--variable_map_output_file gccvars.txt" -js-compiler-option+="--compilation_level SIMPLE_OPTIMIZATIONS"

Maven configuration:

<additionalCompilerOptions>-js-compiler-option=--variable_map_output_file gccvars.txt;-js-compiler-option+=--property_map_output_file gccprops.txt</additionalCompilerOptions>

js-default-initializers

Defaults to true. Enables or disables initialization of primitive (Number, Boolean, etc.) variables with default values in the generated JavaScript. Corresponds to AVM runtime implicit type intialization values.

Note that some reflection utility functions require this to be set to true in order for them to work correctly in JavaScript.

-js-default-initializers

Maven configuration:

<additionalCompilerOptions>-js-default-initializers=true;</additionalCompilerOptions>

js-dynamic-access-unknown-members

If the definition of a member cannot be resolved at compile time, emit dynamic access instead of normal member access. Ensures that dynamic members aren't renamed.

-js-dynamic-access-unknown-members 

Maven configuration:

<additionalCompilerOptions>-js-dynamic-access-unknown-members=true;</additionalCompilerOptions>

js-define

Defines a global constant at compile time for the JavaScript output. May be a boolean, number, string, or expression.

-js-define CONFIG::debugging true -js-define CONFIG::release false

For Boolean and numeric values, you may pass in literals like true, false, or 123. Format string values with nested quotes, like “‘hello’”, because the compiler will attempt to evaluate an expression when it encounters a quotation mark.

Maven configuration:

<defines>
    <property>
        <name>BUILD::buildNumber</name>
        <value>'"${buildTimestamp}"'</value>
    </property>
    <property>
        <name>BUILD::buildVersion</name>
        <value>'"${project.version}"'</value>
    </property>
</defines>

Then in AS3 you can do:

// Build Number
private static var _buildNumber :String = BUILD::buildNumber;

// Project Version
private static var _projectVersion :String = BUILD::buildVersion;

js-load-config

Specifies the locations of XML configuration files that define extra compiler options for JavaScript output.

-js-load-config path/to/project-config.xml

Maven configuration:

js-output

The path where the generated JavaScript output should be saved, if your are also using it for the .swf output path.

-js-output path/to/output

Maven configuration:

Use instead outputDirectory in configuration xml node

js-vector-emulation-class

A custom implemention to use instead of default emulation of the AVM2 Vector typed collection.

-js-vector-emulation-class=com.example.MyVectorClass

Maven configuration:

<additionalCompilerOptions>-js-vector-emulation-class=com.example.MyVectorClass;</additionalCompilerOptions>

jsx-factory

Customize the factory to use for JSX syntax. Defaults to React.createElement.

-jsx-factory=_jsx

Maven configuration:

<additionalCompilerOptions>-jsx-factory=_jsx;</additionalCompilerOptions>

keep-asdoc

Determines if asdoc comment annotations are kept in the generated JavaScript.

-keep-asdoc=false

Maven configuration:

<additionalCompilerOptions>-keep-asdoc=false;</additionalCompilerOptions>

remove-circulars

Tells the Apache Royale compiler to remove circular dependencies in the generated JavaScript, where possible.

-remove-circulars

Maven configuration:

<removeCirculars>true</removeCirculars>

show-binding-warnings

Set to false to remove all binding warnings.

-show-binding-warnings=false

Maven configuration:

<additionalCompilerOptions>-show-binding-warnings=false;</additionalCompilerOptions>

skip-transpile

(Advanced) Set to false to skip transpiling ActionScript and MXML to JavaScript, and only run the release build. Generally used by contributors to the compiler only. Default s to false.

-skip-transpile=true

Maven configuration:

<additionalCompilerOptions>-skip-transpile=true;</additionalCompilerOptions>

source-map

Emits a source map in the debug build for each ActionScript file. The default value is false.

-source-map

Maven configuration:

<additionalCompilerOptions>-source-map=true;</additionalCompilerOptions>

source-map-source-root

Sets a custom value for the sourceRoot property in the generated source map files. This option will be ignored if the source-map compiler option is false.

-source-map-source-root=my/custom/path

Maven configuration:

<additionalCompilerOptions>-source-map-source-root=my/custom/path;</additionalCompilerOptions>

targets

Specifies the target format of the code generated by the Apache Royale compiler. You can specify multiple targets.

-targets JSRoyale,SWF

The compiler supports the following values for “targets”:

  • “JSRoyale”
  • “JS”
  • “JSNode”
  • “JSNodeModule”
  • “SWF”

Maven configuration:

<targets>JSRoyale</targets>

warn-public-vars

Enables or disables warnings about using public variables when it may be considered dangerous to use them.

-warn-public-vars

Maven configuration:

<additionalCompilerOptions>-warn-public-vars=true;</additionalCompilerOptions>

Reduce size of release builds

The following compiler options may be used to reduce the output size of JavaScript release builds. However, using these options may also prevent certain coding patterns in ActionScript and JavaScript from working correctly, so use with caution.

There are two main ways to reduce the size of a release build:

  • Disable exported symbols. When a symbol is exported, it may be accessed by external JavaScript <script> elements in the same page. If a symbol is not exported, and it is not referenced elsewhere in the Royale project, the compiler may determine that it is “dead code” that should be removed from a release build.

  • Allow renaming of symbols. When a symbol is not allowed to be renamed in a release build, it may be accessed using dynamic string access, such as object["myProperty"]. If a symbol is not prevented from being renamed, the compiler may determine that it can change the name of the symbol to a shorter value to reduce the size of the release build. If a symbol is renamed, dynamic string access will not be possible without knowing the new name of the symbol.

Export public symbols

In a release build, determines if symbols in the public namespace will be exported or not. The default value is true.

-export-public-symbols=false

Maven configuration:

<additionalCompilerOptions>-export-public-symbols=false;</additionalCompilerOptions>

Export protected symbols

In a release build, determines if symbols in the protected namespace will be exported. The default value is false.

-export-protected-symbols=true

Maven configuration:

<additionalCompilerOptions>-export-protected-symbols=true;</additionalCompilerOptions>

Export internal symbols

In a release build, determines if symbols in the internal namespace will be exported. The default value is false.

-export-internal-symbols=true

Maven configuration:

<additionalCompilerOptions>-export-internal-symbols=true;</additionalCompilerOptions>

Prevent renaming of public symbols

In a release build, determines if symbols in the public namespace may be renamed or not. The default value is true.

-prevent-rename-public-symbols=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-public-symbols=false;</additionalCompilerOptions>

Related options:

When prevent-rename-public-symbols option is true, one or more the following options may be set to false to allow renaming of certain specific subsets of public symbols.

Prevent renaming of protected symbols

In a release build, determines if symbols in the protected namespace may be renamed or not. The default value is true.

-prevent-rename-protected-symbols=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-protected-symbols=false;</additionalCompilerOptions>

Related options:

When prevent-rename-protected-symbols option is true, one or more the following options may be set to false to allow renaming of certain specific subsets of protected symbols.

Prevent renaming of internal symbols

In a release build, determines if symbols in the internal namespace may be renamed or not. The default value is true.

-prevent-rename-internal-symbols=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-internal-symbols=false;</additionalCompilerOptions>

Related options:

When prevent-rename-internal-symbols option is true, one or more the following options may be set to false to allow renaming of certain specific subsets of internal symbols.

Prevent renaming of public static methods

In a release build, determines if static methods in the public namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-public-symbols compiler option is false.

-prevent-rename-public-static-methods=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-methods=false;</additionalCompilerOptions>

Prevent renaming of public instance methods

In a release build, determines if instance (non-static) methods in the public namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-public-symbols compiler option is false.

-prevent-rename-public-instance-methods=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-public-instance-methods=false;</additionalCompilerOptions>

Prevent renaming of public static variables

In a release build, determines if static variables in the public namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-public-symbols compiler option is false.

-prevent-rename-public-static-variables=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-variables=false;</additionalCompilerOptions>

Prevent renaming of public instance variables

In a release build, determines if instance (non-static) variables in the public namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-public-symbols compiler option is false.

-prevent-rename-public-instance-variables=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-public-instance-variables=false;</additionalCompilerOptions>

Prevent renaming of public static accessors

In a release build, determines if static accessors (getters and setters) in the public namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-public-symbols compiler option is false.

-prevent-rename-public-static-accessors=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-accessors=false;</additionalCompilerOptions>

Prevent renaming of public instance accessors

In a release build, determines if instance (non-static) accessors (getters and setters) in the public namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-public-symbols compiler option is false.

-prevent-rename-public-instance-accessors=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-public-instance-accessors=false;</additionalCompilerOptions>

Prevent renaming of protected static methods

In a release build, determines if static methods in the protected namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-protected-symbols compiler option is false.

-prevent-rename-protected-static-methods=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-methods=false;</additionalCompilerOptions>

Prevent renaming of protected instance methods

In a release build, determines if instance (non-static) methods in the protected namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-protected-symbols compiler option is false.

-prevent-rename-protected-instance-methods=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-protected-instance-methods=false;</additionalCompilerOptions>

Prevent renaming of protected static variables

In a release build, determines if static variables in the protected namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-protected-symbols compiler option is false.

-prevent-rename-protected-static-variables=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-variables=false;</additionalCompilerOptions>

Prevent renaming of protected instance variables

In a release build, determines if instance (non-static) variables in the protected namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-protected-symbols compiler option is false.

-prevent-rename-protected-instance-variables=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-protected-instance-variables=false;</additionalCompilerOptions>

Prevent renaming of protected static accessors

In a release build, determines if static accessors (getters and setters) in the protected namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-protected-symbols compiler option is false.

-prevent-rename-protected-static-accessors=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-accessors=false;</additionalCompilerOptions>

Prevent renaming of protected instance accessors

In a release build, determines if instance (non-static) accessors (getters and setters) in the protected namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-protected-symbols compiler option is false.

-prevent-rename-protected-instance-accessors=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-protected-instance-accessors=false;</additionalCompilerOptions>

Prevent renaming of internal static methods

In a release build, determines if static methods in the internal namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-internal-symbols compiler option is false.

-prevent-rename-internal-static-methods=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-methods=false;</additionalCompilerOptions>

Prevent renaming of internal instance methods

In a release build, determines if instance (non-static) methods in the internal namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-internal-symbols compiler option is false.

-prevent-rename-internal-instance-methods=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-internal-instance-methods=false;</additionalCompilerOptions>

Prevent renaming of internal static variables

In a release build, determines if static variables in the internal namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-internal-symbols compiler option is false.

-prevent-rename-internal-static-variables=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-variables=false;</additionalCompilerOptions>

Prevent renaming of internal instance variables

In a release build, determines if instance (non-static) variables in the internal namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-internal-symbols compiler option is false.

-prevent-rename-internal-instance-variables=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-internal-instance-variables=false;</additionalCompilerOptions>

Prevent renaming of internal static accessors

In a release build, determines if static accessors (getters and setters) in the internal namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-internal-symbols compiler option is false.

-prevent-rename-internal-static-accessors=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-static-accessors=false;</additionalCompilerOptions>

Prevent renaming of internal instance accessors

In a release build, determines if instance (non-static) accessors (getters and setters) in the internal namespace may be renamed or not. The default value is true. This option will be ignored if the prevent-rename-internal-symbols compiler option is false.

-prevent-rename-internal-instance-accessors=false

Maven configuration:

<additionalCompilerOptions>-prevent-rename-internal-instance-accessors=false;</additionalCompilerOptions>