1
1
import * as babel from '@babel/core' ;
2
+ // @ts -ignore
2
3
import solid from 'babel-preset-solid' ;
3
4
import { readFileSync } from 'fs' ;
4
5
import { mergeAndConcat } from 'merge-anything' ;
@@ -193,7 +194,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
193
194
async config ( userConfig , { command } ) {
194
195
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
195
196
replaceDev = options . dev === true || ( options . dev !== false && command === 'serve' ) ;
196
- projectRoot = userConfig . root ;
197
+ projectRoot = userConfig . root || projectRoot ;
197
198
198
199
if ( ! userConfig . resolve ) userConfig . resolve = { } ;
199
200
userConfig . resolve . alias = normalizeAliases ( userConfig . resolve && userConfig . resolve . alias ) ;
@@ -355,7 +356,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
355
356
356
357
if ( options . babel ) {
357
358
if ( typeof options . babel === 'function' ) {
358
- const babelOptions = options . babel ( source , id , isSsr ) ;
359
+ const babelOptions = options . babel ( source , id , ! ! isSsr ) ;
359
360
babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions ;
360
361
} else {
361
362
babelUserOptions = options . babel ;
@@ -364,9 +365,11 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
364
365
365
366
const babelOptions = mergeAndConcat ( babelUserOptions , opts ) as babel . TransformOptions ;
366
367
367
- const { code, map } = await babel . transformAsync ( source , babelOptions ) ;
368
-
369
- return { code, map } ;
368
+ const result = await babel . transformAsync ( source , babelOptions ) ;
369
+ if ( ! result ) {
370
+ return undefined ;
371
+ }
372
+ return { code : result . code || '' , map : result . map } ;
370
373
} ,
371
374
} ;
372
375
}
0 commit comments