Skip to content

Commit

Permalink
Add --es6module and --non-strict-es6module flags to jsx bin
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmo committed Feb 13, 2015
1 parent 34bb8e8 commit 332a782
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions bin/jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
// -*- mode: js -*-
"use strict";
'use strict';

var transform = require('../main').transform;

Expand All @@ -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);
});

0 comments on commit 332a782

Please sign in to comment.