Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Options for Compiling

sseering edited this pageAug 31, 2017 ·16 revisions

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 outdir

The[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.

Options in the Browser

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>

Options for Modules

The default format option is 'bootstrap'.

  • modules='amd': each input module creates an output file in AMD format. egtraceur --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
  • 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.

Clone this wiki locally


[8]ページ先頭

©2009-2026 Movatter.jp