From 25a7611741a244f6cb4fa8bf8910e4203021fc49 Mon Sep 17 00:00:00 2001 From: Alan Agius <17563226+alan-agius4@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:26:29 +0000 Subject: [PATCH] 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. --- .../esbuild/stylesheets/less-language.ts | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) 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 1f6d8f2b7c26..68cacd576b10 100644 --- a/packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts +++ b/packages/angular/build/src/tools/esbuild/stylesheets/less-language.ts @@ -32,13 +32,7 @@ export const LessStylesheetLanguage = Object.freeze({ componentFilter: /^less;/, fileFilter: /\.less$/, process(data, file, _, options, build) { - return compileString( - data, - file, - options, - build.resolve.bind(build), - /* unsafeInlineJavaScript */ false, - ); + return compileString(data, file, options, build.resolve.bind(build)); }, }); @@ -47,7 +41,6 @@ async function compileString( filename: string, options: StylesheetPluginOptions, resolver: PluginBuild['resolve'], - unsafeInlineJavaScript: boolean, ): Promise { try { lessPreprocessor ??= (await import('less')).default; @@ -118,7 +111,6 @@ async function compileString( paths: options.includePaths, plugins: [resolverPlugin], rewriteUrls: 'all', - javascriptEnabled: unsafeInlineJavaScript, sourceMap: options.sourcemap ? { sourceMapFileInline: true, @@ -136,35 +128,6 @@ async function compileString( if (isLessException(error)) { const location = convertExceptionLocation(error); - // Retry with a warning for less files requiring the deprecated inline JavaScript option - if (error.message.includes('Inline JavaScript is not enabled.')) { - const withJsResult = await compileString( - data, - filename, - options, - resolver, - /* unsafeInlineJavaScript */ true, - ); - withJsResult.warnings = [ - { - text: 'Deprecated inline execution of JavaScript has been enabled ("javascriptEnabled")', - location, - notes: [ - { - location: null, - text: 'JavaScript found within less stylesheets may be executed at build time. [https://lesscss.org/usage/#less-options]', - }, - { - location: null, - text: 'Support for "javascriptEnabled" may be removed from the Angular CLI starting with Angular v19.', - }, - ], - }, - ]; - - return withJsResult; - } - return { errors: [ {