diff --git a/packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts b/packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts index 449e2b5c8d39..1b99100b90e9 100644 --- a/packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts +++ b/packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts @@ -130,7 +130,9 @@ async function compileString( } as Less.Options); return { - contents: options.sourcemap ? `${css}\n${sourceMapToUrlComment(map)}` : css, + // There can be cases where `less` will return an undefined `map` even + // though the types do not specify this as a possibility. + contents: map ? `${css}\n${sourceMapToUrlComment(map)}` : css, loader: 'css', watchFiles: [filename, ...imports], };