diff --git a/package-lock.json b/package-lock.json index 2bce4905..44146aaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "reablocks", - "version": "7.5.5", + "version": "7.5.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "reablocks", - "version": "7.5.5", + "version": "7.5.6", "license": "Apache-2.0", "dependencies": { "@marko19907/string-to-color": "^1.0.0", @@ -68,7 +68,6 @@ "prettier": "^3.2.5", "react": "^18.0.0", "react-docgen": "^7.0.3", - "react-docgen-typescript": "^2.2.2", "react-dom": "^18.0.0", "react-hook-form": "^7.51.1", "rollup-plugin-peer-deps-external": "2.2.4", diff --git a/package.json b/package.json index 70ce1b4b..e1668f01 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,6 @@ "prettier": "^3.2.5", "react": "^18.0.0", "react-docgen": "^7.0.3", - "react-docgen-typescript": "^2.2.2", "react-dom": "^18.0.0", "react-hook-form": "^7.51.1", "rollup-plugin-peer-deps-external": "2.2.4", diff --git a/scripts/docs.js b/scripts/docs.js index 73a772f0..35a67d59 100644 --- a/scripts/docs.js +++ b/scripts/docs.js @@ -1,8 +1,40 @@ import { readFileSync, writeFileSync } from 'fs'; import fg from 'fast-glob'; import { resolve } from 'path'; -// import { parse } from 'react-docgen-typescript'; -import { parse } from 'react-docgen'; +import { parse, builtinResolvers } from 'react-docgen'; + +const { + ChainResolver, + FindAllDefinitionsResolver, + FindAnnotatedDefinitionsResolver, +} = builtinResolvers; + +const resolver = new ChainResolver( + [new FindAnnotatedDefinitionsResolver(), new FindAllDefinitionsResolver()], + { chainingLogic: ChainResolver.Logic.ALL }, +); + +const defaultPlugins = [ + 'jsx', + 'asyncDoExpressions', + 'decimal', + 'decorators', + 'decoratorAutoAccessors', + 'destructuringPrivate', + 'doExpressions', + 'explicitResourceManagement', + 'exportDefaultFrom', + 'functionBind', + 'functionSent', + 'importAssertions', + 'importReflection', + 'moduleBlocks', + 'partialApplication', + ['pipelineOperator', { proposal: 'minimal' }], + 'recordAndTuple', + 'regexpUnicodeSets', + 'throwExpressions', +]; /** * Builds the doc types. @@ -19,7 +51,20 @@ function buildDocs() { try { const code = readFileSync(file, { encoding: 'utf-8' }); - const documentation = parse(code, { reactDocgen: 'react-docgen' }); + const documentation = parse(code, { + // Stolen from website + // https://github.com/reactjs/react-docgen/blob/main/packages/website/src/components/playground/Playground.tsx#L85 + resolver, + babelOptions: { + babelrc: false, + babelrcRoots: false, + configFile: false, + filename: 'playground.js', + parserOpts: { + plugins: [...defaultPlugins, 'typescript'], + }, + } + }); if (documentation) { result.push(...documentation); count++;