Skip to content

Commit 5e9476a

Browse files
committed
Blacklist "strict" Babel transformer so "this" isn't transformed incorrectly. Closes #176
1 parent 767398a commit 5e9476a

File tree

7 files changed

+17
-7
lines changed

7 files changed

+17
-7
lines changed

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ of patent rights can be found in the PATENTS file in the same directory.
1111
<PropertyGroup>
1212
<Major>2</Major>
1313
<Minor>0</Minor>
14-
<Build>0</Build>
14+
<Build>1</Build>
1515
<Revision>0</Revision>
1616
<DevNuGetServer>http://reactjs.net/packages/</DevNuGetServer>
1717
<MSBuildCommunityTasksPath>$(MSBuildProjectDirectory)\tools\MSBuildTasks</MSBuildCommunityTasksPath>

src/React.AspNet/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0-*",
2+
"version": "2.0.1-*",
33
"configurations": {
44
"Debug": {
55
"compilationOptions": {

src/React.Core/BabelConfig.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public class BabelConfig
1616
/// </summary>
1717
public bool AllLoose { get; set; }
1818

19+
/// <summary>
20+
/// Gets or sets the transformers to blacklist
21+
/// </summary>
22+
public IEnumerable<string> Blacklist { get; set; }
23+
1924
/// <summary>
2025
/// Gets or sets whether Babel should use a reference to babelHelpers instead of placing
2126
/// helpers at the top of your code. Meant to be used in conjunction with external
@@ -46,6 +51,10 @@ public class BabelConfig
4651
/// </summary>
4752
public BabelConfig()
4853
{
54+
// By default, we blacklist the "strict" transform, as it messes with the top-level "this".
55+
// This is required since we're not actually using JavaScript modules directly in ReactJS.NET yet.
56+
// See https://babeljs.io/docs/faq/#why-is-this-being-remapped-to-undefined-
57+
Blacklist = new[] {"strict"};
4958
Stage = 2;
5059
}
5160

@@ -57,6 +66,7 @@ public string Serialize()
5766
{
5867
var config = new Dictionary<string, object>
5968
{
69+
{"blacklist", Blacklist},
6070
{"externalHelpers", ExternalHelpers},
6171
{"optional", Optional},
6272
{"stage", Stage},

src/React.Sample.Mvc6/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"webroot": "wwwroot",
3-
"version": "2.0.0-*",
3+
"version": "2.0.1-*",
44
"dependencies": {
55
"Microsoft.AspNet.Mvc": "6.0.0-beta8",
66
"Microsoft.AspNet.Diagnostics": "1.0.0-beta8",

src/React.Tests/Core/BabelConfigTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void SerializesAllLoose()
2222
AllLoose = true,
2323
};
2424
var result = config.Serialize();
25-
Assert.AreEqual(@"{""externalHelpers"":false,""optional"":null,""stage"":2,""loose"":""all""}", result);
25+
Assert.AreEqual(@"{""blacklist"":[""strict""],""externalHelpers"":false,""optional"":null,""stage"":2,""loose"":""all""}", result);
2626
}
2727

2828
[Test]
@@ -33,7 +33,7 @@ public void SerializesSomeLoose()
3333
Loose = new[] { "foo" },
3434
};
3535
var result = config.Serialize();
36-
Assert.AreEqual(@"{""externalHelpers"":false,""optional"":null,""stage"":2,""loose"":[""foo""]}", result);
36+
Assert.AreEqual(@"{""blacklist"":[""strict""],""externalHelpers"":false,""optional"":null,""stage"":2,""loose"":[""foo""]}", result);
3737
}
3838
}
3939
}

src/wrap/React.Core/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0-*",
2+
"version": "2.0.1-*",
33
"frameworks": {
44
"net40": {
55
"wrappedProject": "../../React.Core/React.Core.csproj",

src/wrap/VroomJs/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0-*",
2+
"version": "2.0.1-*",
33
"frameworks": {
44
"net40": {
55
"bin": {

0 commit comments

Comments
 (0)