Skip to content

Commit 9453a23

Browse files
committed
fix(@angular-devkit/build-angular): remove CJS usage warnings for inactionable packages
This commit add `critters` and `express` to the CJS allowed deps. (cherry picked from commit 196e9d9)
1 parent 7f9f044 commit 9453a23

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

packages/angular_devkit/build_angular/src/tools/esbuild/commonjs-checker.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ export function checkCommonJSModules(
4545
// using `provideHttpClient(withFetch())`.
4646
allowedRequests.add('xhr2');
4747

48+
// Packages used by @angular/ssr.
49+
// While critters is ESM it has a number of direct and transtive CJS deps.
50+
allowedRequests.add('express');
51+
allowedRequests.add('critters');
52+
4853
// Find all entry points that contain code (JS/TS)
4954
const files: string[] = [];
5055
for (const { entryPoint } of Object.values(metafile.outputs)) {
@@ -72,8 +77,14 @@ export function checkCommonJSModules(
7277
if (!imported.original || seenFiles.has(imported.path)) {
7378
continue;
7479
}
80+
7581
seenFiles.add(imported.path);
7682

83+
// If the dependency is allowed ignore all other checks
84+
if (allowedRequests.has(imported.original)) {
85+
continue;
86+
}
87+
7788
// Only check actual code files
7889
if (!isPathCode(imported.path)) {
7990
continue;
@@ -137,11 +148,7 @@ function isPathCode(name: string): boolean {
137148
* @returns True, if specifier is potentially relative; false, otherwise.
138149
*/
139150
function isPotentialRelative(specifier: string): boolean {
140-
if (specifier[0] === '.') {
141-
return true;
142-
}
143-
144-
return false;
151+
return specifier[0] === '.';
145152
}
146153

147154
/**

0 commit comments

Comments
 (0)