Add --es6module and --non-strict-es6module flags to jsx bin
jeffmo committed
Feb 13, 2015 at 17:51 UTC
332a782d28f7e640eb238605a05eb6c5b704aa53
1 file changed
+20
-2
bin/jsx
+20
-2
@@ -1,6 +1,6 @@
1
#!/usr/bin/env node
2
// -*- mode: js -*-
3
-"use strict";
3
+'use strict';
4
5
var transform = require('../main').transform;
6
@@ -14,15 +14,33 @@ require('commoner').version(
14
).option(
15
'--strip-types',
16
'Strips out type annotations.'
17
+).option(
18
+ '--es6module',
19
+ 'Parses the file as a valid ES6 module. ' +
20
+ '(Note that this means implicit strict mode)'
21
+).option(
22
+ '--non-strict-es6module',
23
+ 'Parses the file as an ES6 module, except disables implicit strict-mode. ' +
24
+ '(This is useful if you\'re porting non-ES6 modules to ES6, but haven\'t ' +
25
+ 'yet verified that they are strict-mode safe yet)'
26
).option(
27
'--source-map-inline',
28
'Embed inline sourcemap in transformed source'
29
).process(function(id, source) {
30
+ var sourceType;
31
+ if (this.options.es6module) {
32
+ sourceType = 'module';
33
+ }
34
+ if (this.options.nonStrictEs6module) {
35
+ sourceType = 'nonStrictModule';
36
+ }
37
+
38
// This is where JSX, ES6, etc. desugaring happens.
39
var options = {
40
harmony: this.options.harmony,
41
sourceMap: this.options.sourceMapInline,
25
- stripTypes: this.options.stripTypes
42
+ stripTypes: this.options.stripTypes,
43
+ sourceType: sourceType,
44
};
45
return transform(source, options);
46
});