Repository navigation
refactor(@angular/build): remove sass worker and fallback to pure-JS sass - #33942
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Sass compilation logic by consolidating the separate worker-based and async-compiler implementations into a single, unified SassCompiler class. It also introduces the useSassEmbedded environment option to toggle between the native embedded compiler and the pure-JS fallback, simplifying the codebase and removing several files. The review feedback highlights a couple of redundant method bindings in the rebasing importer subclasses, where load and canonicalize are unnecessarily bound again despite already being bound in their parent constructors.
78ca8af to
b8e9db4
Compare
413c192 to
1b8c60d
Compare
…sass Removes the legacy Piscina-based Sass worker thread pool implementation (`sass-worker-implementation.ts` and `worker.ts`). When the native `sass-embedded` compiler cannot be used (such as inside WebContainers or when disabled), the build system now directly falls back to the in-process pure-JS Dart Sass asynchronous compiler (`sass.initAsyncCompiler()`). Consolidates the Sass compilation logic in `packages/angular/build/src/tools/sass` into a simplified `SassCompiler` class in `sass-service.ts` supporting both rebasing (esbuild) and non-rebasing (Webpack) usage. Environment Variable: - Replaces `NG_BUILD_SASS_WORKER` with `NG_BUILD_SASS_EMBEDDED`. - When `NG_BUILD_SASS_EMBEDDED` is set to `0` or `false`, or when running within a WebContainer environment, the native embedded Sass compiler is disabled and the pure-JS Sass compiler is used instead.
This `sass` version is only used for types, as the `sass` implementation is in `@angular/build`.
1b8c60d to
e1b09d6
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |

Removes the legacy Piscina-based Sass worker thread pool implementation (
sass-worker-implementation.tsandworker.ts). When the nativesass-embeddedcompiler cannot be used (such as inside WebContainers or when disabled), the build system now directly falls back to the in-process pure-JS Dart Sass asynchronous compiler (sass.initAsyncCompiler()).Consolidates the Sass compilation logic in
packages/angular/build/src/tools/sassinto a simplifiedSassCompilerclass insass-service.tssupporting both rebasing (esbuild) and non-rebasing (Webpack) usage.Environment Variable
NG_BUILD_SASS_WORKERwithNG_BUILD_SASS_EMBEDDED.NG_BUILD_SASS_EMBEDDEDis set to0orfalse, or when running within a WebContainer environment (process.versions.webcontainer), the native embedded Sass compiler is disabled and the pure-JS Sass compiler is used instead.