@@ -22,7 +22,7 @@ public class JsxTransformer : IJsxTransformer
22
22
/// <summary>
23
23
/// Cache key for JSX to JavaScript compilation
24
24
/// </summary>
25
- protected const string JSX_CACHE_KEY = "JSX_v2_ {0}" ;
25
+ protected const string JSX_CACHE_KEY = "JSX_v3_ {0}" ;
26
26
/// <summary>
27
27
/// Suffix to append to compiled files
28
28
/// </summary>
@@ -78,15 +78,10 @@ public JsxTransformer(IReactEnvironment environment, ICache cache, IFileSystem f
78
78
/// Transforms a JSX file. Results of the JSX to JavaScript transformation are cached.
79
79
/// </summary>
80
80
/// <param name="filename">Name of the file to load</param>
81
- /// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
82
- /// <param name="stripTypes">
83
- /// Whether Flow types should be stripped out. Defaults to the value set in the site
84
- /// configuration.
85
- /// </param>
86
81
/// <returns>JavaScript</returns>
87
- public virtual string TransformJsxFile ( string filename , bool ? useHarmony = null , bool ? stripTypes = null )
82
+ public virtual string TransformJsxFile ( string filename )
88
83
{
89
- return TransformJsxFileWithSourceMap ( filename , false , useHarmony , stripTypes ) . Code ;
84
+ return TransformJsxFileWithSourceMap ( filename , false ) . Code ;
90
85
}
91
86
92
87
/// <summary>
@@ -98,17 +93,10 @@ public virtual string TransformJsxFile(string filename, bool? useHarmony = null,
98
93
/// <param name="forceGenerateSourceMap">
99
94
/// <c>true</c> to re-transform the file if a cached version with no source map is available
100
95
/// </param>
101
- /// <param name="useHarmony"><c>true</c> if support for ES6 syntax should be enabled</param>
102
- /// <param name="stripTypes">
103
- /// Whether Flow types should be stripped out. Defaults to the value set in the site
104
- /// configuration.
105
- /// </param>
106
96
/// <returns>JavaScript and source map</returns>
107
97
public virtual JavaScriptWithSourceMap TransformJsxFileWithSourceMap (
108
98
string filename ,
109
- bool forceGenerateSourceMap = false ,
110
- bool ? useHarmony = null ,
111
- bool ? stripTypes = null
99
+ bool forceGenerateSourceMap = false
112
100
)
113
101
{
114
102
var cacheKey = string . Format ( JSX_CACHE_KEY , filename ) ;
@@ -131,7 +119,7 @@ public virtual JavaScriptWithSourceMap TransformJsxFileWithSourceMap(
131
119
// 3. Not cached, perform the transformation
132
120
try
133
121
{
134
- output = TransformJsxWithHeader ( filename , contents , hash , useHarmony , stripTypes ) ;
122
+ output = TransformJsxWithHeader ( filename , contents , hash ) ;
135
123
}
136
124
catch ( JsxException ex )
137
125
{
@@ -223,26 +211,19 @@ protected virtual JavaScriptWithSourceMap LoadJsxFromFileCache(string filename,
223
211
/// <param name="filename">Name of the file being transformed</param>
224
212
/// <param name="contents">Contents of the input file</param>
225
213
/// <param name="hash">Hash of the input. If null, it will be calculated</param>
226
- /// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
227
- /// <param name="stripTypes">
228
- /// Whether Flow types should be stripped out. Defaults to the value set in the site
229
- /// configuration.
230
- /// </param>
231
214
/// <returns>JavaScript</returns>
232
215
protected virtual JavaScriptWithSourceMap TransformJsxWithHeader (
233
216
string filename ,
234
217
string contents ,
235
- string hash = null ,
236
- bool ? useHarmony = null ,
237
- bool ? stripTypes = null
218
+ string hash = null
238
219
)
239
220
{
240
221
if ( string . IsNullOrEmpty ( hash ) )
241
222
{
242
223
hash = _fileCacheHash . CalculateHash ( contents ) ;
243
224
}
244
225
var header = GetFileHeader ( hash ) ;
245
- var result = TransformJsxWithSourceMap ( header + contents , useHarmony , stripTypes ) ;
226
+ var result = TransformJsxWithSourceMap ( header + contents ) ;
246
227
result . Hash = hash ;
247
228
if ( result . SourceMap != null )
248
229
{
@@ -262,21 +243,14 @@ protected virtual JavaScriptWithSourceMap TransformJsxWithHeader(
262
243
/// <see cref="TransformJsxFile"/> if loading from a file since this will cache the result.
263
244
/// </summary>
264
245
/// <param name="input">JSX</param>
265
- /// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
266
- /// <param name="stripTypes">
267
- /// Whether Flow types should be stripped out. Defaults to the value set in the site
268
- /// configuration.
269
- /// </param>
270
246
/// <returns>JavaScript</returns>
271
- public virtual string TransformJsx ( string input , bool ? useHarmony = null , bool ? stripTypes = null )
247
+ public virtual string TransformJsx ( string input )
272
248
{
273
249
try
274
250
{
275
251
var output = _environment . ExecuteWithLargerStackIfRequired < string > (
276
252
"ReactNET_transform" ,
277
- input ,
278
- useHarmony ?? _config . UseHarmony ,
279
- stripTypes ?? _config . StripTypes
253
+ input
280
254
) ;
281
255
return output ;
282
256
}
@@ -291,25 +265,16 @@ public virtual string TransformJsx(string input, bool? useHarmony = null, bool?
291
265
/// source to the original version. The result is not cached.
292
266
/// </summary>
293
267
/// <param name="input">JSX</param>
294
- /// <param name="useHarmony"><c>true</c> if support for ES6 syntax should be enabled</param>
295
- /// <param name="stripTypes">
296
- /// Whether Flow types should be stripped out. Defaults to the value set in the site
297
- /// configuration.
298
- /// </param>
299
268
/// <returns>JavaScript and source map</returns>
300
269
public virtual JavaScriptWithSourceMap TransformJsxWithSourceMap (
301
- string input ,
302
- bool ? useHarmony = null ,
303
- bool ? stripTypes = null
270
+ string input
304
271
)
305
272
{
306
273
try
307
274
{
308
275
return _environment . ExecuteWithLargerStackIfRequired < JavaScriptWithSourceMap > (
309
276
"ReactNET_transform_sourcemap" ,
310
- input ,
311
- useHarmony ?? _config . UseHarmony ,
312
- stripTypes ?? _config . StripTypes
277
+ input
313
278
) ;
314
279
}
315
280
catch ( Exception ex )
@@ -365,22 +330,15 @@ public virtual string GetSourceMapOutputPath(string path)
365
330
/// alongside the original file.
366
331
/// </summary>
367
332
/// <param name="filename">Name of the file to load</param>
368
- /// <param name="useHarmony"><c>true</c> if support for es6 syntax should be rewritten.</param>
369
- /// <param name="stripTypes">
370
- /// Whether Flow types should be stripped out. Defaults to the value set in the site
371
- /// configuration.
372
- /// </param>
373
333
/// <returns>File contents</returns>
374
334
public virtual string TransformAndSaveJsxFile (
375
- string filename ,
376
- bool ? useHarmony = null ,
377
- bool ? stripTypes = null
335
+ string filename
378
336
)
379
337
{
380
338
var outputPath = GetJsxOutputPath ( filename ) ;
381
339
var sourceMapPath = GetSourceMapOutputPath ( filename ) ;
382
340
var contents = _fileSystem . ReadAsString ( filename ) ;
383
- var result = TransformJsxWithHeader ( filename , contents , null , useHarmony , stripTypes ) ;
341
+ var result = TransformJsxWithHeader ( filename , contents , null ) ;
384
342
_fileSystem . WriteAsString ( outputPath , result . Code ) ;
385
343
_fileSystem . WriteAsString ( sourceMapPath , result . SourceMap == null ? string . Empty : result . SourceMap . ToJson ( ) ) ;
386
344
return outputPath ;
0 commit comments