- Notifications
You must be signed in to change notification settings - Fork572
Options for Compiling
Various options control which EcmaScript features are allowed in the source and what kind of output will be generated. The compile options are enumerated inOptions.js. You can experiment with the options in theREPL page using the Options control in the upper right corner.
The command line (./traceur --help )supports these options by using--optionName, as well as a few more options:
Usage: traceur [options] [files] Options: -h, --help output usage information --out <FILE> Compile all input files into a single file --dir <INDIR> <OUTDIR> Compile an input directory of modules into an output directory --source-maps Generate source maps --longhelp Show all known options -v, --version Show version and exit --experimental Turns on all experimental features --script <fileName> Parse as Script (must precede modules) Examples: $ traceur a.js [args] $ traceur --out compiled.js b.js c.js $ traceur --dir indir outdirThe[files] arguments should just be the 'root' modules, traceur will pull the rest. So for example ifA.js requiresB.js requiresC.js, only listA.js on the command line.
To set options when compiling in the browser, usemetadata.traceurOptions, e.g.:
<script>// Create the System objectwindow.System=newtraceur.runtime.BrowserTraceurLoader();// Set some experimental optionsvarmetadata={traceurOptions:{properTailCalls:true,symbols:true,arrayComprehension:true,asyncFunctions:true,asyncGenerators:exponentiation,forOn:true,generatorComprehension:true}};// Load your moduleSystem.import('./myModule.js',{metadata:metadata}).catch(function(ex){console.error('Import failed',ex.stack||ex);});</script>
The default format option is 'bootstrap'.
- modules='amd': each input module creates an output file in AMD format. eg
traceur --dir src/util test-amd/ --modules=amd - modules='commonjs': each input module creates an output file in ?
- modules='instantiate': for systemjs bundling.
- modules='inline': All dependencies of the root modules and/or scripts are compiled into a long script that creates modules upon execution then runs the dependents.
- outputLanguage='es6': Preserve's ES6 formatting during inline.
traceur --modules=inline --outputLanguage=es6 --out ./out/some-lib.js -- ./src/root.js
- outputLanguage='es6': Preserve's ES6 formatting during inline.
- modules='bootstrap': All dependencies of the root modules and/or scripts are compiled in to functions that register the modules then execute any scripts.
The--moduleName <string> option allows you to set the__moduleName value; use"+" on the command line ortrue in code to cause the__moduleName to be the input file name. This option is not normally required.