Skip to content

refactor(@angular/build): remove sass worker and fallback to pure-JS sass - #33942

Merged
alan-agius4 merged 2 commits into
angular:mainfrom
alan-agius4:refactor/sass-compiler-pure-js
Aug 28, 2026
Merged

refactor(@angular/build): remove sass worker and fallback to pure-JS sass#33942
alan-agius4 merged 2 commits into
angular:mainfrom
alan-agius4:refactor/sass-compiler-pure-js

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

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 (process.versions.webcontainer), the native embedded Sass compiler is disabled and the pure-JS Sass compiler is used instead.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/angular/build/src/tools/sass/rebasing-importer.ts Outdated
Comment thread packages/angular/build/src/tools/sass/rebasing-importer.ts Outdated
@alan-agius4
alan-agius4 force-pushed the refactor/sass-compiler-pure-js branch 2 times, most recently from 78ca8af to b8e9db4 Compare August 27, 2026 07:56
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Aug 27, 2026
@alan-agius4
alan-agius4 requested a review from clydin August 27, 2026 08:03
@angular-robot angular-robot Bot added the area: build & ci Related the build and CI infrastructure of the project label Aug 27, 2026
@alan-agius4
alan-agius4 force-pushed the refactor/sass-compiler-pure-js branch 3 times, most recently from 413c192 to 1b8c60d Compare August 27, 2026 08:31
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 28, 2026
@ngbot

ngbot Bot commented Aug 28, 2026

Copy link
Copy Markdown

I see that you just added the action: merge label, but the following checks are still failing:
    failure conflicts with base branch "main"
If you want your PR to be merged, it has to pass all the CI checks.
If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

…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`.
@alan-agius4
alan-agius4 force-pushed the refactor/sass-compiler-pure-js branch from 1b8c60d to e1b09d6 Compare August 28, 2026 06:54
@alan-agius4
alan-agius4 merged commit 4d3b5b7 into angular:main Aug 28, 2026
39 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

@alan-agius4
alan-agius4 deleted the refactor/sass-compiler-pure-js branch August 28, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build area: build & ci Related the build and CI infrastructure of the project target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants