Skip to content

Commit

Permalink
Test .js and .ts files for components as well
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Apr 2, 2022
1 parent 85037af commit d8f00f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/builder-vite/plugins/react-docgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function reactDocgen(): Plugin {
name: 'react-docgen',
enforce: 'pre',
async transform(src: string, id: string) {
if (/\.(mjs|tsx|jsx)$/.test(id)) {
// JSX syntax is only allowed in .tsx and .jsx, but components can technically be created without JSX
if (/\.(mjs|tsx?|jsx?)$/.test(id)) {
try {
// Since we're using `findAllExportedComponentDefinitions`, this will always be an array.
const docgenResults = parse(src, defaultResolver, handlers, { importer: defaultImporter, filename: id }) as
Expand Down

0 comments on commit d8f00f8

Please sign in to comment.