Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): remove CJS usage warnings for ina…
Browse files Browse the repository at this point in the history
…ctionable packages

This commit add `critters` and `express` to the CJS allowed deps.

(cherry picked from commit 196e9d9)
  • Loading branch information
alan-agius4 committed Nov 3, 2023
1 parent 7f9f044 commit 9453a23
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export function checkCommonJSModules(
// using `provideHttpClient(withFetch())`.
allowedRequests.add('xhr2');

// Packages used by @angular/ssr.
// While critters is ESM it has a number of direct and transtive CJS deps.
allowedRequests.add('express');
allowedRequests.add('critters');

// Find all entry points that contain code (JS/TS)
const files: string[] = [];
for (const { entryPoint } of Object.values(metafile.outputs)) {
Expand Down Expand Up @@ -72,8 +77,14 @@ export function checkCommonJSModules(
if (!imported.original || seenFiles.has(imported.path)) {
continue;
}

seenFiles.add(imported.path);

// If the dependency is allowed ignore all other checks
if (allowedRequests.has(imported.original)) {
continue;
}

// Only check actual code files
if (!isPathCode(imported.path)) {
continue;
Expand Down Expand Up @@ -137,11 +148,7 @@ function isPathCode(name: string): boolean {
* @returns True, if specifier is potentially relative; false, otherwise.
*/
function isPotentialRelative(specifier: string): boolean {
if (specifier[0] === '.') {
return true;
}

return false;
return specifier[0] === '.';
}

/**
Expand Down

0 comments on commit 9453a23

Please sign in to comment.