Skip to content

Commit 5ad2c4a

Browse files
committed
fix(@angular-devkit/build-angular): improve detection of CommonJS dependencies
With this change we include `CommonJsSelfReferenceDependency` and `CommonJsExportsDependency` in the CJS checks. Closes angular#23505
1 parent c07a45d commit 5ad2c4a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/angular_devkit/build_angular/src/webpack/plugins/common-js-usage-warn-plugin.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { addWarning } from '../../utils/webpack-diagnostics';
1212

1313
// Webpack doesn't export these so the deep imports can potentially break.
1414
const AMDDefineDependency = require('webpack/lib/dependencies/AMDDefineDependency');
15+
const CommonJsExportsDependency = require('webpack/lib/dependencies/CommonJsExportsDependency');
1516
const CommonJsRequireDependency = require('webpack/lib/dependencies/CommonJsRequireDependency');
17+
const CommonJsSelfReferenceDependency = require('webpack/lib/dependencies/CommonJsSelfReferenceDependency');
1618

1719
export interface CommonJsUsageWarnPluginOptions {
1820
/** A list of CommonJS packages that are allowed to be used without a warning. */
@@ -105,7 +107,12 @@ export class CommonJsUsageWarnPlugin {
105107
checkParentModules = false,
106108
): boolean {
107109
for (const dep of dependencies) {
108-
if (dep instanceof CommonJsRequireDependency || dep instanceof AMDDefineDependency) {
110+
if (
111+
dep instanceof CommonJsRequireDependency ||
112+
dep instanceof CommonJsExportsDependency ||
113+
dep instanceof CommonJsSelfReferenceDependency ||
114+
dep instanceof AMDDefineDependency
115+
) {
109116
return true;
110117
}
111118

0 commit comments

Comments
 (0)