Skip to content

Commit 5211732

Browse files
committed
Speed up matching
1 parent 14935a1 commit 5211732

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/plugin.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as webpack from "webpack";
44
import ts from "typescript";
55
import * as docGen from "react-docgen-typescript";
66
import generateDocgenCodeBlock from "react-docgen-typescript-loader/dist/generateDocgenCodeBlock";
7-
import match from "micromatch";
7+
import { matcher } from "micromatch";
88

99
const debugExclude = createDebug("docgen:exclude");
1010
const debugInclude = createDebug("docgen:include");
@@ -130,8 +130,11 @@ function getTSConfigFile(tsconfigPath: string): ts.ParsedCommandLine {
130130
}
131131

132132
/** Create a glob matching function. */
133-
const matchGlob = (globs: string[]) => (filename: string) =>
134-
Boolean(filename && globs.find((g) => match([filename], g).length));
133+
const matchGlob = (globs: string[]) => {
134+
const matchers = globs.map((g) => matcher(g));
135+
return (filename: string) =>
136+
Boolean(filename && matchers.find((matcher) => matcher(filename)));
137+
};
135138

136139
/** Inject typescript docgen information into modules at the end of a build */
137140
export default class DocgenPlugin {

0 commit comments

Comments
 (0)