mirror of
https://github.com/facebook/react.git
synced 2026-02-25 22:45:00 +00:00
52 lines
1.8 KiB
JavaScript
Executable File
52 lines
1.8 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
// -*- mode: js -*-
|
|
'use strict';
|
|
|
|
var transform = require('../main').transform;
|
|
|
|
require('commoner').version(
|
|
require('../package.json').version
|
|
).resolve(function(id) {
|
|
return this.readModuleP(id);
|
|
}).option(
|
|
'--harmony',
|
|
'Turns on JS transformations such as ES6 Classes etc.'
|
|
).option(
|
|
'--target [version]',
|
|
'Specify your target version of ECMAScript. Valid values are "es3" and ' +
|
|
'"es5". The default is "es5". "es3" will avoid uses of defineProperty and ' +
|
|
'will quote reserved words. WARNING: "es5" is not properly supported, even ' +
|
|
'with the use of es5shim, es5sham. If you need to support IE8, use "es3".',
|
|
'es5'
|
|
).option(
|
|
'--strip-types',
|
|
'Strips out type annotations.'
|
|
).option(
|
|
'--es6module',
|
|
'Parses the file as a valid ES6 module. ' +
|
|
'(Note that this means implicit strict mode)'
|
|
).option(
|
|
'--non-strict-es6module',
|
|
'Parses the file as an ES6 module, except disables implicit strict-mode. ' +
|
|
'(This is useful if you\'re porting non-ES6 modules to ES6, but haven\'t ' +
|
|
'yet verified that they are strict-mode safe yet)'
|
|
).option(
|
|
'--source-map-inline',
|
|
'Embed inline sourcemap in transformed source'
|
|
).process(function(id, source) {
|
|
// This is where JSX, ES6, etc. desugaring happens.
|
|
// We don't do any pre-processing of options so that the command line and the
|
|
// JS API both expose the same set of options. We do extract the options that
|
|
// we care about from commoner though so we aren't passing too many things
|
|
// along.
|
|
var options = {
|
|
harmony: this.options.harmony,
|
|
sourceMap: this.options.sourceMapInline,
|
|
stripTypes: this.options.stripTypes,
|
|
es6module: this.options.es6module,
|
|
nonStrictEs6module: this.options.nonStrictEs6module,
|
|
target: this.options.target
|
|
};
|
|
return transform(source, options);
|
|
});
|