Skip to content

Commit

Permalink
Add new experimental features config for upcoming features
Browse files Browse the repository at this point in the history
This way we do not have to do major releases that often and could also iterate more on some options.
  • Loading branch information
danez committed Apr 24, 2024
1 parent bf68a56 commit 86d0d07
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/react-docgen/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import {
FindExportedDefinitionsResolver,
} from './resolver/index.js';

interface Features {
resolveEnums?: boolean;
}

export interface Config {
handlers?: Handler[];
importer?: Importer;
Expand All @@ -33,6 +37,7 @@ export interface Config {
*/
filename?: string;
babelOptions?: TransformOptions;
experimentalFeatures?: Features;
}
export type InternalConfig = Omit<Required<Config>, 'filename'>;

Expand Down Expand Up @@ -61,14 +66,26 @@ export const defaultHandlers: Handler[] = [
componentMethodsJsDocHandler,
];

const defaultFeatures: Required<Features> = {
resolveEnums: false,
};

export function createConfig(inputConfig: Config): InternalConfig {
const { babelOptions, filename, handlers, importer, resolver } = inputConfig;
const {
babelOptions,
filename,
experimentalFeatures,
handlers,
importer,
resolver,
} = inputConfig;

const config = {
babelOptions: { ...babelOptions },
handlers: handlers ?? defaultHandlers,
importer: importer ?? defaultImporter,
resolver: resolver ?? defaultResolver,
experimentalFeatures: { ...defaultFeatures, ...experimentalFeatures },
};

if (filename) {
Expand Down

0 comments on commit 86d0d07

Please sign in to comment.