4.0.0
In this version we focused on allowing our internals to be more flexible when it comes to allowing different configurations for @babel/parser
. This will make it easier to introduce support for different javascript flavors (like TypeScript 🎉) in the future.
Thanks to @jquense for working on this changes.
BREAKING CHANGES
- Removed cli arguments
--legacy-decorators
and--decorators-before-export
. (#327)
As a replacement react-docgen will read your babel config and pickup the correct configuration from there. - Removed API options
legacyDecorators
anddecoratorsBeforeExport
. (#327)
This probably will only affect libraries or tools that integrate react-docgen and use the programmatic API. In most cases the automatic pickup of babel configuration files will already be enough to not make this a breaking change. With the newparserOptions
option you could still set this configuration, for example:
react-docgen.parse(code, null, null, {
- decoratorsBeforeExport: true
+ parserOptions: {
+ plugins: [
+ ["decorators", { decoratorsBeforeExport: true }],
+ ],
+ },
});
New Features
- Use local babel config if it exists (#320)
We now automatically check if a babel configuration already exists in your project and use it as configuration for the@babel/parser
we use. This was a necessary step as a lot of recent proposals in babel have configuration options, so we cannot simply activate everything. This change is not breaking unless your babel configuration is broken and does not enable all necessary features (which should throw already in your project).
If you are using react-docgen in the browser, ensure thatfs
,net
andmodule
are correctly mocked, as babel uses them. (see our website configuration) - New configuration option
fileName
(#320)
This is a new option which gets forwarded to babel in order to pick the correct configuration file. Library and tool authors are strongly recommended to set this option whenever possible. Not setting it might result in no or the wrong babel configuration being picked up. - New configuration option
cwd
(#320)
This is a new option which gets forwarded to babel in order to pick the correct configuration file. This option is usually autodetected by babel itself usingprocess.cwd()
. - Support forwardRef for all resolvers (#324)
- Support custom parser options in programmatic API (#327)
This allows you to supply your own@babel/parser
options through thereact-docgen
API with the newly added optionparserOptions
. See our README for more information.