diff --git a/packages/angular/build/src/builders/dev-server/vite-server.ts b/packages/angular/build/src/builders/dev-server/vite-server.ts index 1b97ea661c70..c39395dfa4a9 100644 --- a/packages/angular/build/src/builders/dev-server/vite-server.ts +++ b/packages/angular/build/src/builders/dev-server/vite-server.ts @@ -675,6 +675,7 @@ function getDepOptimizationConfig({ supported: getFeatureSupport(target, zoneless), plugins, loader, + resolveExtensions: ['.mjs', '.js', '.cjs'], }, }; } diff --git a/packages/angular/build/src/tools/esbuild/application-code-bundle.ts b/packages/angular/build/src/tools/esbuild/application-code-bundle.ts index 696784fd3702..27cc5cccbaf0 100644 --- a/packages/angular/build/src/tools/esbuild/application-code-bundle.ts +++ b/packages/angular/build/src/tools/esbuild/application-code-bundle.ts @@ -360,7 +360,7 @@ function getEsBuildCommonOptions(options: NormalizedApplicationBuildOptions): Bu format: 'esm', assetNames: outputNames.media, conditions: ['es2020', 'es2015', 'module'], - resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'], + resolveExtensions: ['.ts', '.tsx', '.mjs', '.js', '.cjs'], metafile: true, legalComments: options.extractLicenses ? 'none' : 'eof', logLevel: options.verbose && !jsonLogs ? 'debug' : 'silent', diff --git a/packages/angular/build/src/tools/esbuild/global-scripts.ts b/packages/angular/build/src/tools/esbuild/global-scripts.ts index 7fa5c4d9fb80..2c178c29953a 100644 --- a/packages/angular/build/src/tools/esbuild/global-scripts.ts +++ b/packages/angular/build/src/tools/esbuild/global-scripts.ts @@ -63,7 +63,7 @@ export function createGlobalScriptsBundleOptions( assetNames: outputNames.media, mainFields: ['script', 'browser', 'main'], conditions: ['script'], - resolveExtensions: ['.mjs', '.js'], + resolveExtensions: ['.mjs', '.js', '.cjs'], logLevel: options.verbose && !jsonLogs ? 'debug' : 'silent', metafile: true, minify: optimizationOptions.scripts,