Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): target correct versions of ng-packagr to create stylesheet worker synchronously #22485

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { FactoryProvider } from 'injection-js';
import { STYLESHEET_PROCESSOR_TOKEN } from 'ng-packagr/lib/styles/stylesheet-processor.di';
import { gte, lt } from 'semver';
import { getInstalledPackageVersionInfo } from '../angular-version-utils';
import {
AsyncStylesheetProcessor,
Expand All @@ -13,7 +12,7 @@ export const STYLESHEET_PROCESSOR: FactoryProvider = {
const { version: ngPackagrVersion } =
getInstalledPackageVersionInfo('ng-packagr');

return lt(ngPackagrVersion, '17.2.0') || gte(ngPackagrVersion, '17.3.0')
return ngPackagrVersion !== '17.2.0'
? StylesheetProcessor
: AsyncStylesheetProcessor;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ export class StylesheetProcessor {
}

/**
* This class is used when ng-packagr version is greater than or equal to 17.2.0 and less than 17.3.0.
* The async `loadPostcssConfiguration` function introduced in ng-packagr 17.2.x causes a memory leak
* due to multiple workers being created. We must keep this class to support any workspace that might
* be using ng-packagr 17.2.x where that function need to be awaited.
* This class is used when ng-packagr version is 17.2.0. The async `loadPostcssConfiguration` function
* introduced in ng-packagr 17.2.0 causes a memory leak due to multiple workers being created. We must
* keep this class to support any workspace that might be using ng-packagr 17.2.0 where that function
* need to be awaited.
*/
export class AsyncStylesheetProcessor {
private renderWorker: typeof Piscina | undefined;
Expand Down Expand Up @@ -199,7 +199,7 @@ export class AsyncStylesheetProcessor {
const { version: ngPackagrVersion } =
getInstalledPackageVersionInfo('ng-packagr');
let postcssConfiguration: PostcssConfiguration | undefined;
if (gte(ngPackagrVersion, '17.2.0')) {
if (ngPackagrVersion === '17.2.0') {
const { loadPostcssConfiguration } = await import(
'ng-packagr/lib/styles/postcss-configuration'
);
Expand Down