Skip to content

Commit 1397585

Browse files
committed
fix(@angular/build): remove deprecated javascriptEnabled option for Less
The `javascriptEnabled` option for the Less CSS preprocessor has been deprecated since v18 and its usage was behind a warning. This functionality is now fully removed. This change simplifies the Less stylesheet processing by removing the retry logic that attempted to compile with inline JavaScript enabled after an initial failure. BREAKING CHANGE: The `javascriptEnabled` option for Less is no longer supported. Projects relying on inline JavaScript within Less files will need to refactor their stylesheets to remove this dependency.
1 parent 705af22 commit 1397585

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

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

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ export const LessStylesheetLanguage = Object.freeze<StylesheetLanguage>({
3232
componentFilter: /^less;/,
3333
fileFilter: /\.less$/,
3434
process(data, file, _, options, build) {
35-
return compileString(
36-
data,
37-
file,
38-
options,
39-
build.resolve.bind(build),
40-
/* unsafeInlineJavaScript */ false,
41-
);
35+
return compileString(data, file, options, build.resolve.bind(build));
4236
},
4337
});
4438

@@ -47,7 +41,6 @@ async function compileString(
4741
filename: string,
4842
options: StylesheetPluginOptions,
4943
resolver: PluginBuild['resolve'],
50-
unsafeInlineJavaScript: boolean,
5144
): Promise<OnLoadResult> {
5245
try {
5346
lessPreprocessor ??= (await import('less')).default;
@@ -118,7 +111,6 @@ async function compileString(
118111
paths: options.includePaths,
119112
plugins: [resolverPlugin],
120113
rewriteUrls: 'all',
121-
javascriptEnabled: unsafeInlineJavaScript,
122114
sourceMap: options.sourcemap
123115
? {
124116
sourceMapFileInline: true,
@@ -136,35 +128,6 @@ async function compileString(
136128
if (isLessException(error)) {
137129
const location = convertExceptionLocation(error);
138130

139-
// Retry with a warning for less files requiring the deprecated inline JavaScript option
140-
if (error.message.includes('Inline JavaScript is not enabled.')) {
141-
const withJsResult = await compileString(
142-
data,
143-
filename,
144-
options,
145-
resolver,
146-
/* unsafeInlineJavaScript */ true,
147-
);
148-
withJsResult.warnings = [
149-
{
150-
text: 'Deprecated inline execution of JavaScript has been enabled ("javascriptEnabled")',
151-
location,
152-
notes: [
153-
{
154-
location: null,
155-
text: 'JavaScript found within less stylesheets may be executed at build time. [https://lesscss.org/usage/#less-options]',
156-
},
157-
{
158-
location: null,
159-
text: 'Support for "javascriptEnabled" may be removed from the Angular CLI starting with Angular v19.',
160-
},
161-
],
162-
},
163-
];
164-
165-
return withJsResult;
166-
}
167-
168131
return {
169132
errors: [
170133
{

0 commit comments

Comments
 (0)