@@ -210,26 +210,29 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
210
210
? [ 'solid-js' , 'solid-js/web' , 'solid-js/store' , 'solid-js/html' , 'solid-js/h' ]
211
211
: [ ] ;
212
212
213
- const test = ( userConfig as any ) . test || { } ;
214
-
213
+ const userTest = ( userConfig as any ) ?? { } ;
214
+ const test = { } as any ;
215
215
if ( userConfig . mode === 'test' ) {
216
216
// to simplify the processing of the config, we normalize the setupFiles to an array
217
217
const userSetupFiles : string [ ] =
218
- typeof test . setupFiles === 'string' ? [ test . setupFiles ] : test . setupFiles || [ ] ;
218
+ typeof userTest . setupFiles === 'string'
219
+ ? [ userTest . setupFiles ]
220
+ : userTest . setupFiles || [ ] ;
219
221
220
- if ( ! test . environment && ! options . ssr ) {
222
+ if ( ! userTest . environment && ! options . ssr ) {
221
223
test . environment = 'jsdom' ;
222
224
}
223
225
224
- test . server = test . server || { } ;
225
- test . server . deps = test . server . deps || { } ;
226
- if ( ! test . server . deps . external ?. find ( ( item : string | RegExp ) => / s o l i d - j s / . test ( item . toString ( ) ) ) ) {
227
- test . server . deps . external = [ ...( test . server . deps . external || [ ] ) , / s o l i d - j s / ] ;
226
+ if (
227
+ ! userTest . server ?. deps ?. external ?. find ( ( item : string | RegExp ) =>
228
+ / s o l i d - j s / . test ( item . toString ( ) ) ,
229
+ )
230
+ ) {
231
+ test . server = { deps : { external : [ / s o l i d - j s / ] } } ;
228
232
}
229
-
230
233
const jestDomImport = getJestDomExport ( userSetupFiles ) ;
231
234
if ( jestDomImport ) {
232
- test . setupFiles = [ ... userSetupFiles , jestDomImport ] ;
235
+ test . setupFiles = [ jestDomImport ] ;
233
236
}
234
237
}
235
238
@@ -303,7 +306,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
303
306
) ;
304
307
305
308
if ( ! filter ( id ) ) {
306
- return null
309
+ return null ;
307
310
}
308
311
309
312
id = id . replace ( / \? .* $ / , '' ) ;
@@ -327,17 +330,21 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
327
330
}
328
331
329
332
// We need to know if the current file extension has a typescript options tied to it
330
- const shouldBeProcessedWithTypescript = / \. [ m c ] ? t s x $ / i. test ( id ) || extensionsToWatch . some ( ( extension ) => {
331
- if ( typeof extension === 'string' ) {
332
- return extension . includes ( 'tsx' ) ;
333
- }
333
+ const shouldBeProcessedWithTypescript =
334
+ / \. [ m c ] ? t s x $ / i. test ( id ) ||
335
+ extensionsToWatch . some ( ( extension ) => {
336
+ if ( typeof extension === 'string' ) {
337
+ return extension . includes ( 'tsx' ) ;
338
+ }
334
339
335
- const [ extensionName , extensionOptions ] = extension ;
336
- if ( extensionName !== currentFileExtension ) return false ;
340
+ const [ extensionName , extensionOptions ] = extension ;
341
+ if ( extensionName !== currentFileExtension ) return false ;
337
342
338
- return extensionOptions . typescript ;
339
- } ) ;
340
- const plugins : NonNullable < NonNullable < babel . TransformOptions [ 'parserOpts' ] > [ 'plugins' ] > = [ 'jsx' ]
343
+ return extensionOptions . typescript ;
344
+ } ) ;
345
+ const plugins : NonNullable < NonNullable < babel . TransformOptions [ 'parserOpts' ] > [ 'plugins' ] > = [
346
+ 'jsx' ,
347
+ ] ;
341
348
342
349
if ( shouldBeProcessedWithTypescript ) {
343
350
plugins . push ( 'typescript' ) ;
0 commit comments