Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): improve detection of CommonJS dep…
Browse files Browse the repository at this point in the history
…endencies

With this change we include `CommonJsSelfReferenceDependency` and `CommonJsExportsDependency` in the CJS checks.

Closes #23505

(cherry picked from commit d2bbcd7)
  • Loading branch information
alan-agius4 committed Jul 6, 2022
1 parent 98a6aad commit f649035
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import { addWarning } from '../../utils/webpack-diagnostics';

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

export interface CommonJsUsageWarnPluginOptions {
/** A list of CommonJS packages that are allowed to be used without a warning. */
Expand Down Expand Up @@ -105,7 +107,12 @@ export class CommonJsUsageWarnPlugin {
checkParentModules = false,
): boolean {
for (const dep of dependencies) {
if (dep instanceof CommonJsRequireDependency || dep instanceof AMDDefineDependency) {
if (
dep instanceof CommonJsRequireDependency ||
dep instanceof CommonJsExportsDependency ||
dep instanceof CommonJsSelfReferenceDependency ||
dep instanceof AMDDefineDependency
) {
return true;
}

Expand Down

0 comments on commit f649035

Please sign in to comment.