fix(@angular/build): handle undefined less stylesheet sourcemap values

There can be cases where the `less` stylesheet preprocessor will return
an undefined value for a sourcemap even though sourcemaps have been enabled.
A check is now performed to handle these cases to prevent potential crashes
when processing `less` styles.
This commit is contained in:
Charles Lyding 2025-02-27 10:41:39 -05:00 committed by Charles
parent 44b06f4486
commit 25ea0986b1

View File

@ -130,7 +130,9 @@ async function compileString(
} as Less.Options); } as Less.Options);
return { 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', loader: 'css',
watchFiles: [filename, ...imports], watchFiles: [filename, ...imports],
}; };