Add --es6module and --non-strict-es6module flags to jsx bin

This commit is contained in:
jeffmo
2015-02-13 17:51:35 -05:00
parent 286ca6403e
commit 35ebae8412
+20 -2
View File
@@ -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);
});