Skip to content

Commit 03e4f07

Browse files
committed
fix: Include builtModules fix for webpack 5
This improves rebuild performance as it's not going to process already built modules anymore.
1 parent 09fe9dc commit 03e4f07

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/plugin.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,30 @@ export default class DocgenPlugin implements webpack.WebpackPluginInstance {
198198

199199
const nameForCondition = module.nameForCondition() || "";
200200

201+
// Ignore already built modules for webpack 5
202+
if (!compilation.builtModules.has(module)) {
203+
debugExclude(`Ignoring un-built module: ${nameForCondition}`);
204+
return;
205+
}
206+
207+
// Ignore external modules
208+
// eslint-disable-next-line
209+
// @ts-ignore: Webpack 4 type
210+
if (module.external) {
211+
debugExclude(`Ignoring external module: ${nameForCondition}`);
212+
return;
213+
}
214+
215+
// Ignore raw requests
216+
// eslint-disable-next-line
217+
// @ts-ignore: Webpack 4 type
218+
if (!module.rawRequest) {
219+
debugExclude(
220+
`Ignoring module without "rawRequest": ${nameForCondition}`
221+
);
222+
return;
223+
}
224+
201225
if (isExcluded(nameForCondition)) {
202226
debugExclude(
203227
`Module not matched in "exclude": ${nameForCondition}`

0 commit comments

Comments
 (0)