@@ -449,8 +449,8 @@ func TestJSXImportsCommonJS(t *testing.T) {
449
449
options : config.Options {
450
450
Mode : config .ModeBundle ,
451
451
JSX : config.JSXOptions {
452
- Factory : config.JSXExpr {Parts : []string {"elem" }},
453
- Fragment : config.JSXExpr {Parts : []string {"frag" }},
452
+ Factory : config.DefineExpr {Parts : []string {"elem" }},
453
+ Fragment : config.DefineExpr {Parts : []string {"frag" }},
454
454
},
455
455
AbsOutputFile : "/out.js" ,
456
456
},
@@ -473,8 +473,8 @@ func TestJSXImportsES6(t *testing.T) {
473
473
options : config.Options {
474
474
Mode : config .ModeBundle ,
475
475
JSX : config.JSXOptions {
476
- Factory : config.JSXExpr {Parts : []string {"elem" }},
477
- Fragment : config.JSXExpr {Parts : []string {"frag" }},
476
+ Factory : config.DefineExpr {Parts : []string {"elem" }},
477
+ Fragment : config.DefineExpr {Parts : []string {"frag" }},
478
478
},
479
479
AbsOutputFile : "/out.js" ,
480
480
},
@@ -529,7 +529,7 @@ func TestJSXConstantFragments(t *testing.T) {
529
529
Mode : config .ModeBundle ,
530
530
AbsOutputFile : "/out.js" ,
531
531
JSX : config.JSXOptions {
532
- Fragment : config.JSXExpr {
532
+ Fragment : config.DefineExpr {
533
533
Constant : & js_ast.EString {Value : helpers .StringToUTF16 ("]" )},
534
534
},
535
535
},
@@ -2090,7 +2090,7 @@ func TestImportReExportES6Issue149(t *testing.T) {
2090
2090
options : config.Options {
2091
2091
Mode : config .ModeBundle ,
2092
2092
JSX : config.JSXOptions {
2093
- Factory : config.JSXExpr {Parts : []string {"h" }},
2093
+ Factory : config.DefineExpr {Parts : []string {"h" }},
2094
2094
},
2095
2095
AbsOutputFile : "/out.js" ,
2096
2096
ExternalSettings : config.ExternalSettings {
@@ -3979,18 +3979,18 @@ func TestInjectDuplicate(t *testing.T) {
3979
3979
func TestInject (t * testing.T ) {
3980
3980
defines := config .ProcessDefines (map [string ]config.DefineData {
3981
3981
"chain.prop" : {
3982
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
3983
- return & js_ast. EIdentifier { Ref : args . FindSymbol ( args . Loc , "replace" )}
3982
+ DefineExpr : & config.DefineExpr {
3983
+ Parts : [] string { "replace" },
3984
3984
},
3985
3985
},
3986
3986
"obj.defined" : {
3987
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
3988
- return & js_ast.EString {Value : helpers .StringToUTF16 ("defined" )}
3987
+ DefineExpr : & config.DefineExpr {
3988
+ Constant : & js_ast.EString {Value : helpers .StringToUTF16 ("defined" )},
3989
3989
},
3990
3990
},
3991
3991
"injectedAndDefined" : {
3992
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
3993
- return & js_ast.EString {Value : helpers .StringToUTF16 ("should be used" )}
3992
+ DefineExpr : & config.DefineExpr {
3993
+ Constant : & js_ast.EString {Value : helpers .StringToUTF16 ("should be used" )},
3994
3994
},
3995
3995
},
3996
3996
})
@@ -4059,18 +4059,18 @@ func TestInject(t *testing.T) {
4059
4059
func TestInjectNoBundle (t * testing.T ) {
4060
4060
defines := config .ProcessDefines (map [string ]config.DefineData {
4061
4061
"chain.prop" : {
4062
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4063
- return & js_ast. EIdentifier { Ref : args . FindSymbol ( args . Loc , "replace" )}
4062
+ DefineExpr : & config.DefineExpr {
4063
+ Parts : [] string { "replace" },
4064
4064
},
4065
4065
},
4066
4066
"obj.defined" : {
4067
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4068
- return & js_ast.EString {Value : helpers .StringToUTF16 ("defined" )}
4067
+ DefineExpr : & config.DefineExpr {
4068
+ Constant : & js_ast.EString {Value : helpers .StringToUTF16 ("defined" )},
4069
4069
},
4070
4070
},
4071
4071
"injectedAndDefined" : {
4072
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4073
- return & js_ast.EString {Value : helpers .StringToUTF16 ("should be used" )}
4072
+ DefineExpr : & config.DefineExpr {
4073
+ Constant : & js_ast.EString {Value : helpers .StringToUTF16 ("should be used" )},
4074
4074
},
4075
4075
},
4076
4076
})
@@ -4134,8 +4134,8 @@ func TestInjectNoBundle(t *testing.T) {
4134
4134
func TestInjectJSX (t * testing.T ) {
4135
4135
defines := config .ProcessDefines (map [string ]config.DefineData {
4136
4136
"React.createElement" : {
4137
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4138
- return & js_ast. EIdentifier { Ref : args . FindSymbol ( args . Loc , "el" )}
4137
+ DefineExpr : & config.DefineExpr {
4138
+ Parts : [] string { "el" },
4139
4139
},
4140
4140
},
4141
4141
})
@@ -4310,18 +4310,18 @@ func TestAvoidTDZNoBundle(t *testing.T) {
4310
4310
func TestDefineImportMeta (t * testing.T ) {
4311
4311
defines := config .ProcessDefines (map [string ]config.DefineData {
4312
4312
"import.meta" : {
4313
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4314
- return & js_ast.ENumber {Value : 1 }
4313
+ DefineExpr : & config.DefineExpr {
4314
+ Constant : & js_ast.ENumber {Value : 1 },
4315
4315
},
4316
4316
},
4317
4317
"import.meta.foo" : {
4318
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4319
- return & js_ast.ENumber {Value : 2 }
4318
+ DefineExpr : & config.DefineExpr {
4319
+ Constant : & js_ast.ENumber {Value : 2 },
4320
4320
},
4321
4321
},
4322
4322
"import.meta.foo.bar" : {
4323
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4324
- return & js_ast.ENumber {Value : 3 }
4323
+ DefineExpr : & config.DefineExpr {
4324
+ Constant : & js_ast.ENumber {Value : 3 },
4325
4325
},
4326
4326
},
4327
4327
})
@@ -4354,8 +4354,8 @@ func TestDefineImportMeta(t *testing.T) {
4354
4354
func TestDefineImportMetaES5 (t * testing.T ) {
4355
4355
defines := config .ProcessDefines (map [string ]config.DefineData {
4356
4356
"import.meta.x" : {
4357
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4358
- return & js_ast.ENumber {Value : 1 }
4357
+ DefineExpr : & config.DefineExpr {
4358
+ Constant : & js_ast.ENumber {Value : 1 },
4359
4359
},
4360
4360
},
4361
4361
})
@@ -4391,18 +4391,18 @@ kept.js: WARNING: "import.meta" is not available in the configured target enviro
4391
4391
func TestDefineThis (t * testing.T ) {
4392
4392
defines := config .ProcessDefines (map [string ]config.DefineData {
4393
4393
"this" : {
4394
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4395
- return & js_ast.ENumber {Value : 1 }
4394
+ DefineExpr : & config.DefineExpr {
4395
+ Constant : & js_ast.ENumber {Value : 1 },
4396
4396
},
4397
4397
},
4398
4398
"this.foo" : {
4399
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4400
- return & js_ast.ENumber {Value : 2 }
4399
+ DefineExpr : & config.DefineExpr {
4400
+ Constant : & js_ast.ENumber {Value : 2 },
4401
4401
},
4402
4402
},
4403
4403
"this.foo.bar" : {
4404
- DefineFunc : func ( args config.DefineArgs ) js_ast. E {
4405
- return & js_ast.ENumber {Value : 3 }
4404
+ DefineExpr : & config.DefineExpr {
4405
+ Constant : & js_ast.ENumber {Value : 3 },
4406
4406
},
4407
4407
},
4408
4408
})
@@ -4791,8 +4791,8 @@ func TestJSXThisValueCommonJS(t *testing.T) {
4791
4791
options : config.Options {
4792
4792
Mode : config .ModeBundle ,
4793
4793
JSX : config.JSXOptions {
4794
- Factory : config.JSXExpr {Parts : []string {"this" }},
4795
- Fragment : config.JSXExpr {Parts : []string {"this" }},
4794
+ Factory : config.DefineExpr {Parts : []string {"this" }},
4795
+ Fragment : config.DefineExpr {Parts : []string {"this" }},
4796
4796
},
4797
4797
AbsOutputDir : "/out" ,
4798
4798
},
@@ -4833,8 +4833,8 @@ func TestJSXThisValueESM(t *testing.T) {
4833
4833
options : config.Options {
4834
4834
Mode : config .ModeBundle ,
4835
4835
JSX : config.JSXOptions {
4836
- Factory : config.JSXExpr {Parts : []string {"this" }},
4837
- Fragment : config.JSXExpr {Parts : []string {"this" }},
4836
+ Factory : config.DefineExpr {Parts : []string {"this" }},
4837
+ Fragment : config.DefineExpr {Parts : []string {"this" }},
4838
4838
},
4839
4839
AbsOutputDir : "/out" ,
4840
4840
},
@@ -4878,8 +4878,8 @@ func TestJSXThisPropertyCommonJS(t *testing.T) {
4878
4878
options : config.Options {
4879
4879
Mode : config .ModeBundle ,
4880
4880
JSX : config.JSXOptions {
4881
- Factory : config.JSXExpr {Parts : []string {"this" , "factory" }},
4882
- Fragment : config.JSXExpr {Parts : []string {"this" , "fragment" }},
4881
+ Factory : config.DefineExpr {Parts : []string {"this" , "factory" }},
4882
+ Fragment : config.DefineExpr {Parts : []string {"this" , "fragment" }},
4883
4883
},
4884
4884
AbsOutputDir : "/out" ,
4885
4885
},
@@ -4920,8 +4920,8 @@ func TestJSXThisPropertyESM(t *testing.T) {
4920
4920
options : config.Options {
4921
4921
Mode : config .ModeBundle ,
4922
4922
JSX : config.JSXOptions {
4923
- Factory : config.JSXExpr {Parts : []string {"this" , "factory" }},
4924
- Fragment : config.JSXExpr {Parts : []string {"this" , "fragment" }},
4923
+ Factory : config.DefineExpr {Parts : []string {"this" , "factory" }},
4924
+ Fragment : config.DefineExpr {Parts : []string {"this" , "fragment" }},
4925
4925
},
4926
4926
AbsOutputDir : "/out" ,
4927
4927
},
@@ -4968,8 +4968,8 @@ func TestJSXImportMetaValue(t *testing.T) {
4968
4968
Mode : config .ModeBundle ,
4969
4969
UnsupportedJSFeatures : compat .ImportMeta ,
4970
4970
JSX : config.JSXOptions {
4971
- Factory : config.JSXExpr {Parts : []string {"import" , "meta" }},
4972
- Fragment : config.JSXExpr {Parts : []string {"import" , "meta" }},
4971
+ Factory : config.DefineExpr {Parts : []string {"import" , "meta" }},
4972
+ Fragment : config.DefineExpr {Parts : []string {"import" , "meta" }},
4973
4973
},
4974
4974
AbsOutputDir : "/out" ,
4975
4975
},
@@ -5018,8 +5018,8 @@ func TestJSXImportMetaProperty(t *testing.T) {
5018
5018
Mode : config .ModeBundle ,
5019
5019
UnsupportedJSFeatures : compat .ImportMeta ,
5020
5020
JSX : config.JSXOptions {
5021
- Factory : config.JSXExpr {Parts : []string {"import" , "meta" , "factory" }},
5022
- Fragment : config.JSXExpr {Parts : []string {"import" , "meta" , "fragment" }},
5021
+ Factory : config.DefineExpr {Parts : []string {"import" , "meta" , "factory" }},
5022
+ Fragment : config.DefineExpr {Parts : []string {"import" , "meta" , "fragment" }},
5023
5023
},
5024
5024
AbsOutputDir : "/out" ,
5025
5025
},
@@ -5978,8 +5978,8 @@ func TestManglePropsJSXTransform(t *testing.T) {
5978
5978
AbsOutputFile : "/out.js" ,
5979
5979
MangleProps : regexp .MustCompile ("_$" ),
5980
5980
JSX : config.JSXOptions {
5981
- Factory : config.JSXExpr {Parts : []string {"Foo" , "createElement_" }},
5982
- Fragment : config.JSXExpr {Parts : []string {"Foo" , "Fragment_" }},
5981
+ Factory : config.DefineExpr {Parts : []string {"Foo" , "createElement_" }},
5982
+ Fragment : config.DefineExpr {Parts : []string {"Foo" , "Fragment_" }},
5983
5983
},
5984
5984
},
5985
5985
})
0 commit comments