Skip to content

Commit 0c2891d

Browse files
authored
fix: rename exports and fix exports of importers (#690)
BREAKING_CHANGE: `handlers`, `resolver`, and `importers` was renamed to `builtinHandlers`, `builtinResolvers`, and `builtinImporters`.
1 parent 2c5e88a commit 0c2891d

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed

packages/react-docgen/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"repository": "reactjs/react-docgen",
66
"type": "module",
77
"browser": {
8-
"./dist/importer/fsImporter.js": "./dist/importer/ignoreImports.js",
9-
"./src/importer/fsImporter.ts": "./src/importer/ignoreImports.ts"
8+
"./dist/importer/fsImporter.js": "./dist/importer/ignoreImporter.js",
9+
"./src/importer/fsImporter.ts": "./src/importer/ignoreImporter.ts"
1010
},
1111
"files": [
1212
"dist"

packages/react-docgen/src/__tests__/main-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { handlers, parse } from '../main.js';
1+
import { builtinHandlers, parse } from '../main.js';
22
import { ERROR_MISSING_DEFINITION } from '../parse.js';
33
import { describe, expect, test } from 'vitest';
44

@@ -13,7 +13,7 @@ describe('main', () => {
1313

1414
test('parses with custom handlers', () => {
1515
const docs = parse(source, {
16-
handlers: [handlers.componentDocblockHandler],
16+
handlers: [builtinHandlers.componentDocblockHandler],
1717
});
1818

1919
expect(docs).toMatchSnapshot();

packages/react-docgen/src/importer/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
ImportDeclaration,
66
} from '@babel/types';
77
import type FileState from '../FileState.js';
8-
import ignoreImports from './ignoreImports.js';
8+
import ignoreImporter from './ignoreImporter.js';
99
import fsImporter from './fsImporter.js';
1010
import makeFsImporter from './makeFsImporter.js';
1111

@@ -19,4 +19,4 @@ export type Importer = (
1919
file: FileState,
2020
) => NodePath | null;
2121

22-
export { fsImporter, ignoreImports, makeFsImporter };
22+
export { fsImporter, ignoreImporter, makeFsImporter };

packages/react-docgen/src/main.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import * as allHandlers from './handlers/index.js';
1+
import * as builtinHandlers from './handlers/index.js';
22
import parse from './parse.js';
3-
import * as allResolvers from './resolver/index.js';
4-
import * as allImporters from './importer/index.js';
3+
import * as builtinResolvers from './resolver/index.js';
4+
import {
5+
fsImporter,
6+
ignoreImporter,
7+
makeFsImporter,
8+
} from './importer/index.js';
59
import * as utils from './utils/index.js';
610
import type { DocumentationObject as Documentation } from './Documentation.js';
711
import type { Resolver } from './resolver/index.js';
@@ -11,6 +15,11 @@ import type FileState from './FileState.js';
1115
import type { Config } from './config.js';
1216
import { createConfig, defaultHandlers } from './config.js';
1317

18+
const builtinImporters = {
19+
fsImporter,
20+
ignoreImporter,
21+
};
22+
1423
declare module '@babel/traverse' {
1524
export interface HubInterface {
1625
file: FileState;
@@ -47,11 +56,12 @@ function defaultParse(
4756
}
4857

4958
export {
50-
defaultParse as parse,
59+
builtinHandlers,
60+
builtinResolvers,
61+
builtinImporters,
5162
defaultHandlers,
52-
allHandlers as handlers,
53-
allResolvers as resolver,
54-
allImporters as importers,
63+
makeFsImporter,
64+
defaultParse as parse,
5565
utils,
5666
};
5767

packages/react-docgen/tests/integration/integration-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs';
22
import { dirname, join } from 'path';
33
import { describe, expect, test } from 'vitest';
4-
import { parse, importers } from '../../src/main';
4+
import { parse, makeFsImporter } from '../../src/main';
55
import { fileURLToPath } from 'url';
66

77
describe('integration', () => {
@@ -26,7 +26,7 @@ describe('integration', () => {
2626

2727
expect(() => {
2828
result = parse(fileContent, {
29-
importer: importers.makeFsImporter(),
29+
importer: makeFsImporter(),
3030
babelOptions: {
3131
filename: filePath,
3232
babelrc: false,

0 commit comments

Comments
 (0)