Skip to content

Commit 3ea6f8b

Browse files
committed
Add option to use production version of React. Closes #316
1 parent ce29248 commit 3ea6f8b

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/React.Core/IReactSiteConfiguration.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,16 @@ public interface IReactSiteConfiguration
148148
/// </summary>
149149
/// <returns>The configuration, for chaining</returns>
150150
IReactSiteConfiguration SetBabelConfig(BabelConfig value);
151+
152+
/// <summary>
153+
/// Gets or sets whether to use the debug version of React. This is slower, but gives
154+
/// useful debugging tips.
155+
/// </summary>
156+
bool UseDebugReact { get; set; }
157+
/// <summary>
158+
/// Sets whether to use the debug version of React. This is slower, but gives
159+
/// useful debugging tips.
160+
/// </summary>
161+
IReactSiteConfiguration SetUseDebugReact(bool value);
151162
}
152163
}

src/React.Core/JavaScriptEngineFactory.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ protected virtual void InitialiseEngine(IJsEngine engine)
121121
engine.ExecuteResource("React.Core.Resources.shims.js", thisAssembly);
122122
if (_config.LoadReact)
123123
{
124-
// TODO: Add option to choose whether to load dev vs prod version of React.
125-
engine.ExecuteResource("React.Core.Resources.react.generated.js", thisAssembly);
124+
engine.ExecuteResource(
125+
_config.UseDebugReact
126+
? "React.Core.Resources.react.generated.js"
127+
: "React.Core.Resources.react.generated.min.js",
128+
thisAssembly
129+
);
126130
}
127131

128132
LoadUserScripts(engine);

src/React.Core/ReactSiteConfiguration.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public ReactSiteConfiguration()
4242
{
4343
StringEscapeHandling = StringEscapeHandling.EscapeHtml
4444
};
45+
UseDebugReact = false;
4546
}
4647

4748
/// <summary>
@@ -253,5 +254,21 @@ public IReactSiteConfiguration SetBabelConfig(BabelConfig value)
253254
BabelConfig = value;
254255
return this;
255256
}
257+
258+
/// <summary>
259+
/// Gets or sets whether to use the debug version of React. This is slower, but gives
260+
/// useful debugging tips.
261+
/// </summary>
262+
public bool UseDebugReact { get; set; }
263+
264+
/// <summary>
265+
/// Sets whether to use the debug version of React. This is slower, but gives
266+
/// useful debugging tips.
267+
/// </summary>
268+
public IReactSiteConfiguration SetUseDebugReact(bool value)
269+
{
270+
UseDebugReact = value;
271+
return this;
272+
}
256273
}
257274
}

0 commit comments

Comments
 (0)