From b3715595f76c43358ef7dea17530f09f2046bb3c Mon Sep 17 00:00:00 2001 From: Steven Guh Date: Thu, 1 Dec 2016 10:58:16 -0800 Subject: [PATCH] Add parameter in MSBuild task to force to not use MSIE engine. --- src/React.MSBuild/TransformBabel.cs | 112 ++++++++++++---------- src/React.Sample.Mvc4/TransformBabel.proj | 12 +-- 2 files changed, 65 insertions(+), 59 deletions(-) diff --git a/src/React.MSBuild/TransformBabel.cs b/src/React.MSBuild/TransformBabel.cs index 76e081491..72ab20de0 100644 --- a/src/React.MSBuild/TransformBabel.cs +++ b/src/React.MSBuild/TransformBabel.cs @@ -3,7 +3,7 @@ * 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 + * 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. */ @@ -14,62 +14,68 @@ namespace React.MSBuild { - /// - /// MSBuild task that handles transforming JavaScript via Babel - /// - public class TransformBabel : Task - { - /// - /// The ReactJS.NET environment - /// - private IReactEnvironment _environment; + /// + /// MSBuild task that handles transforming JavaScript via Babel + /// + public class TransformBabel : Task + { + /// + /// The ReactJS.NET environment + /// + private IReactEnvironment _environment; - /// - /// Directory to process JavaScript files in. All subdirectories will be searched. - /// - [Required] - public string SourceDir { get; set; } + /// + /// Directory to process JavaScript files in. All subdirectories will be searched. + /// + [Required] + public string SourceDir { get; set; } - /// - /// The file extension pattern of the JavaScript files to transpile. Optional, defaults to *.jsx - /// - public string FileExtensionPattern { get; set; } = "*.jsx"; + /// + /// The file extension pattern of the JavaScript files to transpile. Optional, defaults to *.jsx + /// + public string FileExtensionPattern { get; set; } = "*.jsx"; - /// - /// Executes the task. - /// - /// true on success - public override bool Execute() - { - MSBuildHost.EnsureInitialized(); - var config = React.AssemblyRegistration.Container.Resolve(); - config - .SetReuseJavaScriptEngines(false); + /// + /// Sets if Msie Engine is allowed. + /// + public bool AllowMsieEngine { get; set; } = true; - _environment = ReactEnvironment.Current; + /// + /// Executes the task. + /// + /// true on success + public override bool Execute() + { + MSBuildHost.EnsureInitialized(); + var config = React.AssemblyRegistration.Container.Resolve(); + config + .SetReuseJavaScriptEngines(false) + .SetAllowMsieEngine(this.AllowMsieEngine); - Log.LogMessage("Starting Babel transform"); - var stopwatch = Stopwatch.StartNew(); - var result = ExecuteInternal(); - Log.LogMessage("Babel transform completed in {0}", stopwatch.Elapsed); - return result; - } + _environment = ReactEnvironment.Current; - /// - /// The core of the task. Locates all JSX files and transforms them to JavaScript. - /// - /// true on success - private bool ExecuteInternal() - { - var files = Directory.EnumerateFiles(SourceDir, FileExtensionPattern, SearchOption.AllDirectories); - foreach (var path in files) - { - var relativePath = path.Substring(SourceDir.Length + 1); - Log.LogMessage(" -> Processing {0}", relativePath); - _environment.Babel.TransformAndSaveFile(path); - } + Log.LogMessage("Starting Babel transform"); + var stopwatch = Stopwatch.StartNew(); + var result = ExecuteInternal(); + Log.LogMessage("Babel transform completed in {0}", stopwatch.Elapsed); + return result; + } - return true; - } - } -} + /// + /// The core of the task. Locates all JSX files and transforms them to JavaScript. + /// + /// true on success + private bool ExecuteInternal() + { + var files = Directory.EnumerateFiles(SourceDir, FileExtensionPattern, SearchOption.AllDirectories); + foreach (var path in files) + { + var relativePath = path.Substring(SourceDir.Length + 1); + Log.LogMessage(" -> Processing {0}", relativePath); + _environment.Babel.TransformAndSaveFile(path); + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/React.Sample.Mvc4/TransformBabel.proj b/src/React.Sample.Mvc4/TransformBabel.proj index b700addaa..93863721a 100644 --- a/src/React.Sample.Mvc4/TransformBabel.proj +++ b/src/React.Sample.Mvc4/TransformBabel.proj @@ -1,7 +1,7 @@  - - - - - - + + + + + + \ No newline at end of file