Skip to content

Commit 64879c1

Browse files
authored
Re-add typescript check when adding react-docgen-typescript plugin (#509)
1 parent e348165 commit 64879c1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/builder-vite/vite-config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,16 @@ export async function pluginConfig(options: ExtendedOptions, _type: PluginConfig
218218
{} as TypescriptConfig
219219
);
220220

221-
if (reactDocgenOption === 'react-docgen-typescript') {
221+
let typescriptPresent;
222+
223+
try {
224+
require.resolve('typescript');
225+
typescriptPresent = true;
226+
} catch (e) {
227+
typescriptPresent = false;
228+
}
229+
230+
if (reactDocgenOption === 'react-docgen-typescript' && typescriptPresent) {
222231
plugins.push(
223232
require('@joshwooding/vite-plugin-react-docgen-typescript')({
224233
...reactDocgenTypescriptOptions,

0 commit comments

Comments
 (0)