Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Feb 6, 2024
1 parent c503f9d commit 53548e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as babel from '@babel/core';
// @ts-ignore
import solid from 'babel-preset-solid';
import { readFileSync } from 'fs';
import { mergeAndConcat } from 'merge-anything';
Expand Down Expand Up @@ -193,7 +194,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
async config(userConfig, { command }) {
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
replaceDev = options.dev === true || (options.dev !== false && command === 'serve');
projectRoot = userConfig.root;
projectRoot = userConfig.root || projectRoot;

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

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

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

const { code, map } = await babel.transformAsync(source, babelOptions);

return { code, map };
const result = await babel.transformAsync(source, babelOptions);
if (!result) {
return undefined;
}
return { code: result.code || '', map: result.map };
},
};
}
Expand Down
12 changes: 8 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"include": ["src"],
"exclude": ["**/*.spec.ts"],
"include": [
"src"
],
"exclude": [
"**/*.spec.ts"
],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"strict": false,
"strict": true,
"declaration": true,
"noUnusedLocals": true,
"skipLibCheck": true,
Expand All @@ -14,4 +18,4 @@
"declarationDir": "dist/types",
"baseUrl": "."
}
}
}

0 comments on commit 53548e7

Please sign in to comment.