diff --git a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts index 27f2d1055d41..6d96d3e071ab 100644 --- a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts +++ b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts @@ -12,7 +12,7 @@ import { readFile } from 'node:fs/promises'; import { dirname, extname, join, relative } from 'node:path'; import { fileURLToPath, pathToFileURL } from 'node:url'; import type { CompileResult, Exception, Syntax } from 'sass'; -import { +import type { FileImporterWithRequestContextOptions, SassWorkerImplementation, } from '../../sass/sass-service'; @@ -93,7 +93,10 @@ async function compileString( resolveUrl: (url: string, previousResolvedModules?: Set) => Promise, ): Promise { // Lazily load Sass when a Sass file is found - sassWorkerPool ??= new SassWorkerImplementation(true); + if (sassWorkerPool === undefined) { + const sassService = await import('../../sass/sass-service'); + sassWorkerPool = new sassService.SassWorkerImplementation(true); + } const warnings: PartialMessage[] = []; try {