Skip to content

Commit

Permalink
fix(@angular/build): handle undefined less stylesheet sourcemap values
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clydin committed Feb 28, 2025
1 parent 44b06f4 commit 25ea098
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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],
};
Expand Down

0 comments on commit 25ea098

Please sign in to comment.