Uh oh!
There was an error while loading. Please reload this page.
forked from ModernTechnologyPlayers01/react
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
Latest commit
95 lines (84 loc) · 2.65 KB
/
Copy pathmain.js
File metadata and controls
95 lines (84 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
/*eslint-disable no-undef*/
varvisitors=require('./vendor/fbtransform/visitors');
vartransform=require('jstransform').transform;
vartypesSyntax=require('jstransform/visitors/type-syntax');
varinlineSourceMap=require('./vendor/inline-source-map');
module.exports={
transform: function(input,options){
options=processOptions(options);
varoutput=innerTransform(input,options);
varresult=output.code;
if(options.sourceMap){
varmap=inlineSourceMap(
output.sourceMap,
input,
options.filename
);
result+='\n'+map;
}
returnresult;
},
transformWithDetails: function(input,options){
options=processOptions(options);
varoutput=innerTransform(input,options);
varresult={};
result.code=output.code;
if(options.sourceMap){
result.sourceMap=output.sourceMap.toJSON();
}
if(options.filename){
result.sourceMap.sources=[options.filename];
}
returnresult;
}
};
/**
* Only copy the values that we need. We'll do some preprocessing to account for
* converting command line flags to options that jstransform can actually use.
*/
functionprocessOptions(opts){
opts=opts||{};
varoptions={};
options.harmony=opts.harmony;
options.stripTypes=opts.stripTypes;
options.sourceMap=opts.sourceMap;
options.filename=opts.sourceFilename;
if(opts.es6module){
options.sourceType='module';
}
if(opts.nonStrictEs6module){
options.sourceType='nonStrictModule';
}
// Instead of doing any fancy validation, only look for 'es3'. If we have
// that, then use it. Otherwise use 'es5'.
options.es3=opts.target==='es3';
options.es5=!options.es3;
returnoptions;
}
functioninnerTransform(input,options){
varvisitorSets=['react'];
if(options.harmony){
visitorSets.push('harmony');
}
if(options.es3){
visitorSets.push('es3');
}
if(options.stripTypes){
// Stripping types needs to happen before the other transforms
// unfortunately, due to bad interactions. For example,
// es6-rest-param-visitors conflict with stripping rest param type
// annotation
input=transform(typesSyntax.visitorList,input,options).code;
}
varvisitorList=visitors.getVisitorsBySet(visitorSets);
returntransform(visitorList,input,options);
}