@nx/angular 18.1.1 → 18.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "18.1.1",
3
+ "version": "18.1.3",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -78,14 +78,14 @@
78
78
  "tslib": "^2.3.0",
79
79
  "webpack": "^5.80.0",
80
80
  "webpack-merge": "^5.8.0",
81
- "@nx/devkit": "18.1.1",
82
- "@nx/js": "18.1.1",
83
- "@nx/eslint": "18.1.1",
84
- "@nx/webpack": "18.1.1",
85
- "@nx/web": "18.1.1",
86
- "@nx/workspace": "18.1.1",
81
+ "@nx/devkit": "18.1.3",
82
+ "@nx/js": "18.1.3",
83
+ "@nx/eslint": "18.1.3",
84
+ "@nx/webpack": "18.1.3",
85
+ "@nx/web": "18.1.3",
86
+ "@nx/workspace": "18.1.3",
87
87
  "piscina": "^4.2.1",
88
- "@nrwl/angular": "18.1.1"
88
+ "@nrwl/angular": "18.1.3"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
@@ -25,3 +25,25 @@ export declare class StylesheetProcessor {
25
25
  destroy(): void;
26
26
  private createRenderWorker;
27
27
  }
28
+ /**
29
+ * This class is used when ng-packagr version is 17.2.0. The async `loadPostcssConfiguration` function
30
+ * introduced in ng-packagr 17.2.0 causes a memory leak due to multiple workers being created. We must
31
+ * keep this class to support any workspace that might be using ng-packagr 17.2.0 where that function
32
+ * need to be awaited.
33
+ */
34
+ export declare class AsyncStylesheetProcessor {
35
+ private readonly projectBasePath;
36
+ private readonly basePath;
37
+ private readonly cssUrl?;
38
+ private readonly includePaths?;
39
+ private readonly cacheDirectory?;
40
+ private renderWorker;
41
+ constructor(projectBasePath: string, basePath: string, cssUrl?: CssUrl, includePaths?: string[], cacheDirectory?: string | false);
42
+ process({ filePath, content, }: {
43
+ filePath: string;
44
+ content: string;
45
+ }): Promise<string>;
46
+ /** Destory workers in pool. */
47
+ destroy(): void;
48
+ private createRenderWorker;
49
+ }
@@ -1,2 +1,2 @@
1
- import { FactoryProvider } from 'injection-js';
1
+ import type { FactoryProvider } from 'injection-js';
2
2
  export declare const STYLESHEET_PROCESSOR: FactoryProvider;
@@ -2,9 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.STYLESHEET_PROCESSOR = void 0;
4
4
  const stylesheet_processor_di_1 = require("ng-packagr/lib/styles/stylesheet-processor.di");
5
+ const angular_version_utils_1 = require("../angular-version-utils");
5
6
  const stylesheet_processor_1 = require("./stylesheet-processor");
6
7
  exports.STYLESHEET_PROCESSOR = {
7
8
  provide: stylesheet_processor_di_1.STYLESHEET_PROCESSOR_TOKEN,
8
- useFactory: () => stylesheet_processor_1.StylesheetProcessor,
9
+ useFactory: () => {
10
+ const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
11
+ return ngPackagrVersion !== '17.2.0'
12
+ ? stylesheet_processor_1.StylesheetProcessor
13
+ : stylesheet_processor_1.AsyncStylesheetProcessor;
14
+ },
9
15
  deps: [],
10
16
  };
@@ -7,7 +7,7 @@
7
7
  * config at the root of the workspace.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.StylesheetProcessor = exports.CssUrl = void 0;
10
+ exports.AsyncStylesheetProcessor = exports.StylesheetProcessor = exports.CssUrl = void 0;
11
11
  const browserslist = require("browserslist");
12
12
  const fs_1 = require("fs");
13
13
  const path_1 = require("path");
@@ -28,6 +28,83 @@ var CssUrl;
28
28
  CssUrl["none"] = "none";
29
29
  })(CssUrl || (exports.CssUrl = CssUrl = {}));
30
30
  class StylesheetProcessor {
31
+ constructor(projectBasePath, basePath, cssUrl, includePaths, cacheDirectory) {
32
+ this.projectBasePath = projectBasePath;
33
+ this.basePath = basePath;
34
+ this.cssUrl = cssUrl;
35
+ this.includePaths = includePaths;
36
+ this.cacheDirectory = cacheDirectory;
37
+ // By default, browserslist defaults are too inclusive
38
+ // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522
39
+ // We change the default query to browsers that Angular support.
40
+ // https://angular.io/guide/browser-support
41
+ browserslist.defaults = [
42
+ 'last 2 Chrome versions',
43
+ 'last 1 Firefox version',
44
+ 'last 2 Edge major versions',
45
+ 'last 2 Safari major versions',
46
+ 'last 2 iOS major versions',
47
+ 'Firefox ESR',
48
+ ];
49
+ }
50
+ async process({ filePath, content, }) {
51
+ this.createRenderWorker();
52
+ return this.renderWorker.run({ content, filePath });
53
+ }
54
+ /** Destory workers in pool. */
55
+ destroy() {
56
+ void this.renderWorker?.destroy();
57
+ }
58
+ createRenderWorker() {
59
+ if (this.renderWorker) {
60
+ return;
61
+ }
62
+ const styleIncludePaths = [...this.includePaths];
63
+ let prevDir = null;
64
+ let currentDir = this.basePath;
65
+ while (currentDir !== prevDir) {
66
+ const p = (0, path_1.join)(currentDir, 'node_modules');
67
+ if ((0, fs_1.existsSync)(p)) {
68
+ styleIncludePaths.push(p);
69
+ }
70
+ prevDir = currentDir;
71
+ currentDir = (0, path_1.dirname)(prevDir);
72
+ }
73
+ const browserslistData = browserslist(undefined, { path: this.basePath });
74
+ const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
75
+ let postcssConfiguration;
76
+ if ((0, semver_1.gte)(ngPackagrVersion, '17.3.0')) {
77
+ const { loadPostcssConfiguration, } = require('ng-packagr/lib/styles/postcss-configuration');
78
+ postcssConfiguration = loadPostcssConfiguration(this.projectBasePath);
79
+ }
80
+ this.renderWorker = new Piscina({
81
+ filename: require.resolve('ng-packagr/lib/styles/stylesheet-processor-worker'),
82
+ maxThreads,
83
+ env: {
84
+ ...process.env,
85
+ FORCE_COLOR: '' + color_1.colors.enabled,
86
+ },
87
+ workerData: {
88
+ postcssConfiguration,
89
+ tailwindConfigPath: (0, tailwindcss_1.getTailwindConfigPath)(this.projectBasePath, devkit_1.workspaceRoot),
90
+ projectBasePath: this.projectBasePath,
91
+ browserslistData,
92
+ targets: transformSupportedBrowsersToTargets(browserslistData),
93
+ cacheDirectory: this.cacheDirectory,
94
+ cssUrl: this.cssUrl,
95
+ styleIncludePaths,
96
+ },
97
+ });
98
+ }
99
+ }
100
+ exports.StylesheetProcessor = StylesheetProcessor;
101
+ /**
102
+ * This class is used when ng-packagr version is 17.2.0. The async `loadPostcssConfiguration` function
103
+ * introduced in ng-packagr 17.2.0 causes a memory leak due to multiple workers being created. We must
104
+ * keep this class to support any workspace that might be using ng-packagr 17.2.0 where that function
105
+ * need to be awaited.
106
+ */
107
+ class AsyncStylesheetProcessor {
31
108
  constructor(projectBasePath, basePath, cssUrl, includePaths, cacheDirectory) {
32
109
  this.projectBasePath = projectBasePath;
33
110
  this.basePath = basePath;
@@ -73,7 +150,7 @@ class StylesheetProcessor {
73
150
  const browserslistData = browserslist(undefined, { path: this.basePath });
74
151
  const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
75
152
  let postcssConfiguration;
76
- if ((0, semver_1.gte)(ngPackagrVersion, '17.2.0')) {
153
+ if (ngPackagrVersion === '17.2.0') {
77
154
  const { loadPostcssConfiguration } = await Promise.resolve().then(() => require('ng-packagr/lib/styles/postcss-configuration'));
78
155
  postcssConfiguration = await loadPostcssConfiguration(this.projectBasePath);
79
156
  }
@@ -97,7 +174,7 @@ class StylesheetProcessor {
97
174
  });
98
175
  }
99
176
  }
100
- exports.StylesheetProcessor = StylesheetProcessor;
177
+ exports.AsyncStylesheetProcessor = AsyncStylesheetProcessor;
101
178
  function transformSupportedBrowsersToTargets(supportedBrowsers) {
102
179
  const transformed = [];
103
180
  // https://esbuild.github.io/api/#target