Skip to content

Commit 53548e7

Browse files
committed
Fix types
1 parent c503f9d commit 53548e7

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as babel from '@babel/core';
2+
// @ts-ignore
23
import solid from 'babel-preset-solid';
34
import { readFileSync } from 'fs';
45
import { mergeAndConcat } from 'merge-anything';
@@ -193,7 +194,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
193194
async config(userConfig, { command }) {
194195
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
195196
replaceDev = options.dev === true || (options.dev !== false && command === 'serve');
196-
projectRoot = userConfig.root;
197+
projectRoot = userConfig.root || projectRoot;
197198

198199
if (!userConfig.resolve) userConfig.resolve = {};
199200
userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);
@@ -355,7 +356,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
355356

356357
if (options.babel) {
357358
if (typeof options.babel === 'function') {
358-
const babelOptions = options.babel(source, id, isSsr);
359+
const babelOptions = options.babel(source, id, !!isSsr);
359360
babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
360361
} else {
361362
babelUserOptions = options.babel;
@@ -364,9 +365,11 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
364365

365366
const babelOptions = mergeAndConcat(babelUserOptions, opts) as babel.TransformOptions;
366367

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 };
370373
},
371374
};
372375
}

tsconfig.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"include": ["src"],
3-
"exclude": ["**/*.spec.ts"],
2+
"include": [
3+
"src"
4+
],
5+
"exclude": [
6+
"**/*.spec.ts"
7+
],
48
"compilerOptions": {
59
"target": "ESNext",
610
"module": "ESNext",
711
"moduleResolution": "node",
8-
"strict": false,
12+
"strict": true,
913
"declaration": true,
1014
"noUnusedLocals": true,
1115
"skipLibCheck": true,
@@ -14,4 +18,4 @@
1418
"declarationDir": "dist/types",
1519
"baseUrl": "."
1620
}
17-
}
21+
}

0 commit comments

Comments
 (0)