mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Add --es6module and --non-strict-es6module flags to jsx bin
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
// -*- mode: js -*-
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var transform = require('../main').transform;
|
||||
|
||||
@@ -14,15 +14,33 @@ require('commoner').version(
|
||||
).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) {
|
||||
var sourceType;
|
||||
if (this.options.es6module) {
|
||||
sourceType = 'module';
|
||||
}
|
||||
if (this.options.nonStrictEs6module) {
|
||||
sourceType = 'nonStrictModule';
|
||||
}
|
||||
|
||||
// This is where JSX, ES6, etc. desugaring happens.
|
||||
var options = {
|
||||
harmony: this.options.harmony,
|
||||
sourceMap: this.options.sourceMapInline,
|
||||
stripTypes: this.options.stripTypes
|
||||
stripTypes: this.options.stripTypes,
|
||||
sourceType: sourceType,
|
||||
};
|
||||
return transform(source, options);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user