Skip to content

Commit 96e5dcb

Browse files
committed
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. (cherry picked from commit 25ea098)
1 parent bf1b30c commit 96e5dcb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ async function compileString(
130130
} as Less.Options);
131131

132132
return {
133-
contents: options.sourcemap ? `${css}\n${sourceMapToUrlComment(map)}` : css,
133+
// There can be cases where `less` will return an undefined `map` even
134+
// though the types do not specify this as a possibility.
135+
contents: map ? `${css}\n${sourceMapToUrlComment(map)}` : css,
134136
loader: 'css',
135137
watchFiles: [filename, ...imports],
136138
};

0 commit comments

Comments
 (0)