Major Changes
-
96d6e9e: Rename
flowTypeHandler
tocodeTypeHandler
because it handles Flow and TypeScript -
96d6e9e: Simplify
resolveObjectValuesToArray
and remove type handling. None of the code that was handling types was actually used. -
caae6bf: The return values of
resolveObjectValuesToArray
are now in the order they are defined in the source code. -
96d6e9e: Migrate react-docgen to ES modules. Please read this
-
3b28f6e: The CLI was removed from
react-docgen
into its own package@react-docgen/cli
.Check out https://react-docgen.dev/docs/getting-started/cli for the documentation.
-
96d6e9e: The main
parse
API had some breaking changes.-
The arguments were changed from previously 5 to just 2. Checkout the diff to see how to migrate:
-parse(src, resolver, handlers, importer, options) +parse(src, { resolver, handlers, importer, filename, babelOptions: {} })
-
The return type is now always an array, independent of resolver and even if
only one component was found in the file.
-
-
96d6e9e: Renamed some of the main exports for clarity.
Renamed
handlers
tobuiltinHandlers
Renamedresolver
tobuiltinResolvers
Renamedimporters
tobuiltinImporters
-
96d6e9e: Migrated to babel toolchain
This is one of the big changes in this new version of react-docgen. It made the code a lot more robust
because there are now finally working TypeScript types for the ASTs.Another benefit from this change that react-docgen is now a lot faster. 🚀 In some
tests an improvement of nearly 50% was seen in comparison to version 5. -
d4c27d4: Improve performance of file system importer.
The file system importer now also caches resolving of files in addition to parsing files.
If the importer is used in an environment where files do change at runtime (like a watch
command) then the caches will need to be cleared on every file change. -
96d6e9e: Changed the minimum Node.js version to 14.17.0
Minor Changes
-
96d6e9e: Add support for
.cts
and.mts
extension when using typescript -
96d6e9e: Treat functions returning
React.Children.map
as components -
96d6e9e: Improve performance by creating all visitors only once
-
96d6e9e: Support all possible kinds of functions in the
displayNameHandler
-
96d6e9e: Support all literal types in typescript
-
96d6e9e: Support flow qualified type names
-
96d6e9e: Support class and function declarations without identifier
-
96d6e9e: Support resolving of destructurings in
resolveToValue
-
96d6e9e: Improve performance drastically by making changes to AST traversal
Visitors are now pre-exploded and are cached in the module scope instead of creating them on every call.
This change brought the benchmark from 170ops/s to 225ops/sec -
96d6e9e: Add codes to errors to be able to easily detect them
There is a new export
ERROR_CODES
that contains all possible error codes.
The two errors that have codes right now are:MISSING_DEFINITION
: No component found in fileMULTIPLE_DEFINITIONS
: Multiple components found in one files
-
96d6e9e: Support handling
useImperativeHandle
correctly
New Contributors
- @ggascoigne made their first contribution in #634