File tree Expand file tree Collapse file tree
angular_devkit/build_angular/src/tools/webpack/configs
tools/esbuild/stylesheets Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ import {
1515 RebuildState ,
1616} from '../../tools/esbuild/bundler-execution-result' ;
1717import { BuildOutputFile , BuildOutputFileType } from '../../tools/esbuild/bundler-files' ;
18- import { shutdownSassWorkerPool } from '../../tools/esbuild/stylesheets/sass-language' ;
18+ import {
19+ resetSassWorkerPoolCaches ,
20+ shutdownSassWorkerPool ,
21+ } from '../../tools/esbuild/stylesheets/sass-language' ;
1922import { logMessages , withNoProgress , withSpinner } from '../../tools/esbuild/utils' ;
2023import { ChangedFiles } from '../../tools/esbuild/watcher' ;
2124import { shouldWatchRoot } from '../../utils/environment-options' ;
@@ -210,6 +213,8 @@ export async function* runEsBuildBuildAction(
210213 // Clear removed files from current watch files
211214 changes . removed . forEach ( ( removedPath ) => currentWatchFiles . delete ( removedPath ) ) ;
212215
216+ resetSassWorkerPoolCaches ( ) ;
217+
213218 const rebuildState = result . createRebuildState ( changes ) ;
214219 result = await withProgress ( 'Changes detected. Rebuilding...' , ( ) => action ( rebuildState ) ) ;
215220
Original file line number Diff line number Diff line change @@ -23,9 +23,18 @@ function isSassException(error: unknown): error is Exception {
2323 return ! ! error && typeof error === 'object' && 'sassMessage' in error ;
2424}
2525
26+ export function resetSassWorkerPoolCaches ( ) : void {
27+ resolutionCache ?. clear ( ) ;
28+ packageRootCache ?. clear ( ) ;
29+ if ( sassService ) {
30+ sassService . clearCache ( ) ;
31+ } else if ( sassServicePromise ) {
32+ void sassServicePromise . then ( ( service ) => service . clearCache ( ) ) ;
33+ }
34+ }
35+
2636export function shutdownSassWorkerPool ( ) : void {
27- resolutionCache = undefined ;
28- packageRootCache = undefined ;
37+ resetSassWorkerPoolCaches ( ) ;
2938 if ( sassService ) {
3039 void sassService . close ( ) ;
3140 sassService = undefined ;
Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ export async function getStylesConfig(wco: WebpackConfigOptions): Promise<Config
7070
7171 extraPlugins . push ( {
7272 apply ( compiler ) {
73+ compiler . hooks . thisCompilation . tap ( 'sass-service' , ( ) => {
74+ sassImplementation . clearCache ( ) ;
75+ } ) ;
7376 compiler . hooks . shutdown . tap ( 'sass-service' , ( ) => {
7477 void sassImplementation . close ( ) ;
7578 } ) ;
You can’t perform that action at this time.
0 commit comments