@@ -38,6 +38,7 @@ func TestToBuildOptions(t *testing.T) {
38
38
Bundle : true ,
39
39
Target : api .ESNext ,
40
40
Format : api .FormatIIFE ,
41
+ Platform : api .PlatformBrowser ,
41
42
SourcesContent : 1 ,
42
43
Stdin : & api.StdinOptions {
43
44
Loader : api .LoaderJS ,
@@ -62,6 +63,7 @@ func TestToBuildOptions(t *testing.T) {
62
63
Bundle : true ,
63
64
Target : api .ES2018 ,
64
65
Format : api .FormatCommonJS ,
66
+ Platform : api .PlatformBrowser ,
65
67
SourcesContent : 1 ,
66
68
MinifyIdentifiers : true ,
67
69
MinifySyntax : true ,
@@ -87,6 +89,7 @@ func TestToBuildOptions(t *testing.T) {
87
89
Bundle : true ,
88
90
Target : api .ES2018 ,
89
91
Format : api .FormatCommonJS ,
92
+ Platform : api .PlatformBrowser ,
90
93
MinifyIdentifiers : true ,
91
94
MinifySyntax : true ,
92
95
MinifyWhitespace : true ,
@@ -113,6 +116,7 @@ func TestToBuildOptions(t *testing.T) {
113
116
Bundle : true ,
114
117
Target : api .ES2018 ,
115
118
Format : api .FormatCommonJS ,
119
+ Platform : api .PlatformBrowser ,
116
120
MinifyIdentifiers : true ,
117
121
MinifySyntax : true ,
118
122
MinifyWhitespace : true ,
@@ -139,6 +143,7 @@ func TestToBuildOptions(t *testing.T) {
139
143
Bundle : true ,
140
144
Target : api .ES2018 ,
141
145
Format : api .FormatCommonJS ,
146
+ Platform : api .PlatformBrowser ,
142
147
MinifyIdentifiers : true ,
143
148
MinifySyntax : true ,
144
149
MinifyWhitespace : true ,
@@ -164,6 +169,7 @@ func TestToBuildOptions(t *testing.T) {
164
169
Bundle : true ,
165
170
Target : api .ESNext ,
166
171
Format : api .FormatIIFE ,
172
+ Platform : api .PlatformBrowser ,
167
173
SourcesContent : 1 ,
168
174
Stdin : & api.StdinOptions {
169
175
Loader : api .LoaderJS ,
@@ -210,10 +216,25 @@ func TestToBuildOptionsTarget(t *testing.T) {
210
216
211
217
func TestDecodeExternalOptions (t * testing.T ) {
212
218
c := qt .New (t )
213
- m := map [string ]any {}
214
- opts , err := DecodeExternalOptions (m )
219
+ m := map [string ]any {
220
+ "platform" : "node" ,
221
+ }
222
+ ext , err := DecodeExternalOptions (m )
215
223
c .Assert (err , qt .IsNil )
216
- c .Assert (opts , qt .DeepEquals , ExternalOptions {
224
+ c .Assert (ext , qt .DeepEquals , ExternalOptions {
217
225
SourcesContent : true ,
226
+ Platform : "node" ,
227
+ })
228
+
229
+ opts := Options {
230
+ ExternalOptions : ext ,
231
+ }
232
+ c .Assert (opts .compile (), qt .IsNil )
233
+ c .Assert (opts .compiled , qt .DeepEquals , api.BuildOptions {
234
+ Bundle : true ,
235
+ Target : api .ESNext ,
236
+ Format : api .FormatIIFE ,
237
+ Platform : api .PlatformNode ,
238
+ SourcesContent : api .SourcesContentInclude ,
218
239
})
219
240
}
0 commit comments