Skip to content

Commit

Permalink
perf(@angular-devkit/build-angular): fully lazy load sass in esbuild …
Browse files Browse the repository at this point in the history
…builder

When using the esbuild-based browser application builder, the Sass worker pool
import is now lazy to prevent unnecessary module loading when Sass is not used
within an application.
  • Loading branch information
clydin authored and angular-robot[bot] committed Apr 4, 2023
1 parent 59b7d71 commit aae34fc
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -93,7 +93,10 @@ async function compileString(
resolveUrl: (url: string, previousResolvedModules?: Set<string>) => Promise<ResolveResult>,
): Promise<OnLoadResult> {
// 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 {
Expand Down

0 comments on commit aae34fc

Please sign in to comment.