@nx/angular 21.0.0-canary.20250430-07b881d → 21.0.0-canary.20250501-8f50358

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.
Files changed (19) hide show
  1. package/package.json +9 -9
  2. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.d.ts +3 -7
  3. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.js +17 -12
  4. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-bundles.di.d.ts +2 -2
  5. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-bundles.di.js +14 -9
  6. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-bundles.transform.js +28 -23
  7. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.d.ts +1 -1
  8. package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.js +6 -3
  9. package/src/executors/package/ng-packagr-adjustments/ng-packagr.d.ts +1 -1
  10. package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +2 -2
  11. package/src/executors/utilities/ng-packagr/ng-packagr-version.d.ts +2 -0
  12. package/src/executors/utilities/ng-packagr/ng-packagr-version.js +11 -0
  13. package/src/executors/utilities/ng-packagr/package-imports.d.ts +1 -0
  14. package/src/executors/utilities/ng-packagr/package-imports.js +10 -0
  15. package/src/executors/utilities/ng-packagr/pre-v19/stylesheet-processor.js +3 -3
  16. package/src/executors/utilities/ng-packagr/stylesheet-processor.di.d.ts +1 -1
  17. package/src/executors/utilities/ng-packagr/stylesheet-processor.di.js +23 -20
  18. package/src/executors/utilities/ng-packagr/v19+/stylesheet-processor.d.ts +4 -13
  19. package/src/executors/utilities/ng-packagr/v19+/stylesheet-processor.js +52 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "21.0.0-canary.20250430-07b881d",
3
+ "version": "21.0.0-canary.20250501-8f50358",
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, Playwright 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": {
@@ -67,14 +67,14 @@
67
67
  "semver": "^7.5.3",
68
68
  "tslib": "^2.3.0",
69
69
  "webpack-merge": "^5.8.0",
70
- "@nx/devkit": "21.0.0-canary.20250430-07b881d",
71
- "@nx/js": "21.0.0-canary.20250430-07b881d",
72
- "@nx/eslint": "21.0.0-canary.20250430-07b881d",
73
- "@nx/webpack": "21.0.0-canary.20250430-07b881d",
74
- "@nx/rspack": "21.0.0-canary.20250430-07b881d",
75
- "@nx/module-federation": "21.0.0-canary.20250430-07b881d",
76
- "@nx/web": "21.0.0-canary.20250430-07b881d",
77
- "@nx/workspace": "21.0.0-canary.20250430-07b881d",
70
+ "@nx/devkit": "21.0.0-canary.20250501-8f50358",
71
+ "@nx/js": "21.0.0-canary.20250501-8f50358",
72
+ "@nx/eslint": "21.0.0-canary.20250501-8f50358",
73
+ "@nx/webpack": "21.0.0-canary.20250501-8f50358",
74
+ "@nx/rspack": "21.0.0-canary.20250501-8f50358",
75
+ "@nx/module-federation": "21.0.0-canary.20250501-8f50358",
76
+ "@nx/web": "21.0.0-canary.20250501-8f50358",
77
+ "@nx/workspace": "21.0.0-canary.20250501-8f50358",
78
78
  "piscina": "^4.4.0"
79
79
  },
80
80
  "peerDependencies": {
@@ -1,7 +1,3 @@
1
- import { type DestinationFiles, NgEntryPoint as NgEntryPointBase } from 'ng-packagr/lib/ng-package/entry-point/entry-point';
2
- export declare class NgEntryPoint extends NgEntryPointBase {
3
- /**
4
- * Point the FESM2022 files to the ESM2022 files.
5
- */
6
- get destinationFiles(): DestinationFiles;
7
- }
1
+ import type { NgEntryPoint as NgEntryPointBase } from 'ng-packagr/lib/ng-package/entry-point/entry-point';
2
+ import type { NgPackageConfig } from 'ng-packagr/ng-package.schema';
3
+ export declare function createNgEntryPoint(packageJson: Record<string, any>, ngPackageJson: NgPackageConfig, basePath: string, secondaryData?: Record<string, any>): NgEntryPointBase;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NgEntryPoint = void 0;
4
- const entry_point_1 = require("ng-packagr/lib/ng-package/entry-point/entry-point");
3
+ exports.createNgEntryPoint = createNgEntryPoint;
5
4
  const node_path_1 = require("node:path");
6
- class NgEntryPoint extends entry_point_1.NgEntryPoint {
7
- /**
8
- * Point the FESM2022 files to the ESM2022 files.
9
- */
10
- get destinationFiles() {
11
- const result = super.destinationFiles;
12
- result.fesm2022 = result.esm2022;
13
- result.fesm2022Dir = (0, node_path_1.dirname)(result.esm2022);
14
- return result;
5
+ const ng_packagr_version_1 = require("../../../../utilities/ng-packagr/ng-packagr-version");
6
+ const package_imports_1 = require("../../../../utilities/ng-packagr/package-imports");
7
+ function createNgEntryPoint(packageJson, ngPackageJson, basePath, secondaryData) {
8
+ const { major: ngPackagrMajorVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
9
+ const { NgEntryPoint: NgEntryPointBase } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/ng-package/entry-point/entry-point', ngPackagrMajorVersion);
10
+ class NgEntryPoint extends NgEntryPointBase {
11
+ /**
12
+ * Point the FESM2022 files to the ESM2022 files.
13
+ */
14
+ get destinationFiles() {
15
+ const result = super.destinationFiles;
16
+ result.fesm2022 = result.esm2022;
17
+ result.fesm2022Dir = (0, node_path_1.dirname)(result.esm2022);
18
+ return result;
19
+ }
15
20
  }
21
+ return new NgEntryPoint(packageJson, ngPackageJson, basePath, secondaryData);
16
22
  }
17
- exports.NgEntryPoint = NgEntryPoint;
@@ -1,2 +1,2 @@
1
- import { TransformProvider } from 'ng-packagr/lib/graph/transform.di';
2
- export declare const WRITE_BUNDLES_TRANSFORM: TransformProvider;
1
+ import type { TransformProvider } from 'ng-packagr/lib/graph/transform.di';
2
+ export declare function getWriteBundlesTransformProvider(): TransformProvider;
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WRITE_BUNDLES_TRANSFORM = void 0;
4
- const transform_di_1 = require("ng-packagr/lib/graph/transform.di");
5
- const write_bundles_di_1 = require("ng-packagr/lib/ng-package/entry-point/write-bundles.di");
6
- const options_di_1 = require("ng-packagr/lib/ng-package/options.di");
3
+ exports.getWriteBundlesTransformProvider = getWriteBundlesTransformProvider;
4
+ const ng_packagr_version_1 = require("../../../../utilities/ng-packagr/ng-packagr-version");
5
+ const package_imports_1 = require("../../../../utilities/ng-packagr/package-imports");
7
6
  const write_bundles_transform_1 = require("./write-bundles.transform");
8
- exports.WRITE_BUNDLES_TRANSFORM = (0, transform_di_1.provideTransform)({
9
- provide: write_bundles_di_1.WRITE_BUNDLES_TRANSFORM_TOKEN,
10
- useFactory: write_bundles_transform_1.writeBundlesTransform,
11
- deps: [options_di_1.OPTIONS_TOKEN],
12
- });
7
+ function getWriteBundlesTransformProvider() {
8
+ const { major: ngPackagrMajorVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
9
+ const { provideTransform } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/graph/transform.di', ngPackagrMajorVersion);
10
+ const { WRITE_BUNDLES_TRANSFORM_TOKEN } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/ng-package/entry-point/write-bundles.di', ngPackagrMajorVersion);
11
+ const { OPTIONS_TOKEN } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/ng-package/options.di', ngPackagrMajorVersion);
12
+ return provideTransform({
13
+ provide: WRITE_BUNDLES_TRANSFORM_TOKEN,
14
+ useFactory: write_bundles_transform_1.writeBundlesTransform,
15
+ deps: [OPTIONS_TOKEN],
16
+ });
17
+ }
@@ -9,36 +9,41 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.writeBundlesTransform = void 0;
12
- const build_graph_1 = require("ng-packagr/lib/graph/build-graph");
13
- const transform_1 = require("ng-packagr/lib/graph/transform");
14
- const nodes_1 = require("ng-packagr/lib/ng-package/nodes");
15
- const package_1 = require("ng-packagr/lib/ng-package/package");
16
12
  const promises_1 = require("node:fs/promises");
17
13
  const node_path_1 = require("node:path");
14
+ const ng_packagr_version_1 = require("../../../../utilities/ng-packagr/ng-packagr-version");
15
+ const package_imports_1 = require("../../../../utilities/ng-packagr/package-imports");
18
16
  const entry_point_1 = require("./entry-point");
19
- const writeBundlesTransform = (_options) => (0, transform_1.transformFromPromise)(async (graph) => {
20
- const updatedGraph = new build_graph_1.BuildGraph();
21
- for (const entry of graph.entries()) {
22
- if ((0, nodes_1.isEntryPoint)(entry)) {
23
- const entryPoint = toCustomNgEntryPoint(entry.data.entryPoint);
24
- entry.data.entryPoint = entryPoint;
25
- entry.data.destinationFiles = entryPoint.destinationFiles;
26
- for (const [path, outputCache] of entry.cache.outputCache.entries()) {
27
- // write the outputs to the file system
28
- await (0, promises_1.mkdir)((0, node_path_1.dirname)(path), { recursive: true });
29
- await (0, promises_1.writeFile)(path, outputCache.content);
17
+ const writeBundlesTransform = (_options) => {
18
+ const { major: ngPackagrMajorVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
19
+ const { BuildGraph } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/graph/build-graph', ngPackagrMajorVersion);
20
+ const { transformFromPromise } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/graph/transform', ngPackagrMajorVersion);
21
+ const { isEntryPoint, isPackage } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/ng-package/nodes', ngPackagrMajorVersion);
22
+ const { NgPackage } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/ng-package/package', ngPackagrMajorVersion);
23
+ return transformFromPromise(async (graph) => {
24
+ const updatedGraph = new BuildGraph();
25
+ for (const entry of graph.entries()) {
26
+ if (isEntryPoint(entry)) {
27
+ const entryPoint = toCustomNgEntryPoint(entry.data.entryPoint);
28
+ entry.data.entryPoint = entryPoint;
29
+ entry.data.destinationFiles = entryPoint.destinationFiles;
30
+ for (const [path, outputCache] of entry.cache.outputCache.entries()) {
31
+ // write the outputs to the file system
32
+ await (0, promises_1.mkdir)((0, node_path_1.dirname)(path), { recursive: true });
33
+ await (0, promises_1.writeFile)(path, outputCache.content);
34
+ }
30
35
  }
36
+ else if (isPackage(entry)) {
37
+ entry.data = new NgPackage(entry.data.src, toCustomNgEntryPoint(entry.data.primary), entry.data.secondaries.map((secondary) => toCustomNgEntryPoint(secondary)));
38
+ }
39
+ updatedGraph.put(entry);
31
40
  }
32
- else if ((0, nodes_1.isPackage)(entry)) {
33
- entry.data = new package_1.NgPackage(entry.data.src, toCustomNgEntryPoint(entry.data.primary), entry.data.secondaries.map((secondary) => toCustomNgEntryPoint(secondary)));
34
- }
35
- updatedGraph.put(entry);
36
- }
37
- return updatedGraph;
38
- });
41
+ return updatedGraph;
42
+ });
43
+ };
39
44
  exports.writeBundlesTransform = writeBundlesTransform;
40
45
  function toCustomNgEntryPoint(entryPoint) {
41
- return new entry_point_1.NgEntryPoint(entryPoint.packageJson, entryPoint.ngPackageJson, entryPoint.basePath,
46
+ return (0, entry_point_1.createNgEntryPoint)(entryPoint.packageJson, entryPoint.ngPackageJson, entryPoint.basePath,
42
47
  // @ts-expect-error this is a TS private property, but it can be accessed at runtime
43
48
  entryPoint.secondaryData);
44
49
  }
@@ -1,2 +1,2 @@
1
- import { NgPackagr } from 'ng-packagr';
1
+ import { type NgPackagr } from 'ng-packagr';
2
2
  export declare function getNgPackagrInstance(): Promise<NgPackagr>;
@@ -3,9 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNgPackagrInstance = getNgPackagrInstance;
4
4
  const ng_packagr_1 = require("ng-packagr");
5
5
  async function getNgPackagrInstance() {
6
- const { WRITE_BUNDLES_TRANSFORM } = await import('./ng-package/entry-point/write-bundles.di.js');
7
- const { STYLESHEET_PROCESSOR } = await import('../../utilities/ng-packagr/stylesheet-processor.di.js');
6
+ const { getWriteBundlesTransformProvider } = await import('./ng-package/entry-point/write-bundles.di.js');
7
+ const { getStylesheetProcessorFactoryProvider } = await import('../../utilities/ng-packagr/stylesheet-processor.di.js');
8
8
  const packagr = (0, ng_packagr_1.ngPackagr)();
9
- packagr.withProviders([WRITE_BUNDLES_TRANSFORM, STYLESHEET_PROCESSOR]);
9
+ packagr.withProviders([
10
+ getWriteBundlesTransformProvider(),
11
+ getStylesheetProcessorFactoryProvider(),
12
+ ]);
10
13
  return packagr;
11
14
  }
@@ -1,2 +1,2 @@
1
- import { NgPackagr } from 'ng-packagr';
1
+ import { type NgPackagr } from 'ng-packagr';
2
2
  export declare function getNgPackagrInstance(): Promise<NgPackagr>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNgPackagrInstance = getNgPackagrInstance;
4
4
  const ng_packagr_1 = require("ng-packagr");
5
5
  async function getNgPackagrInstance() {
6
- const { STYLESHEET_PROCESSOR } = await import('../../utilities/ng-packagr/stylesheet-processor.di.js');
6
+ const { getStylesheetProcessorFactoryProvider } = await import('../../utilities/ng-packagr/stylesheet-processor.di.js');
7
7
  const packagr = (0, ng_packagr_1.ngPackagr)();
8
- packagr.withProviders([STYLESHEET_PROCESSOR]);
8
+ packagr.withProviders([getStylesheetProcessorFactoryProvider()]);
9
9
  return packagr;
10
10
  }
@@ -0,0 +1,2 @@
1
+ import { type VersionInfo } from '../angular-version-utils';
2
+ export declare function getNgPackagrVersionInfo(): VersionInfo;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNgPackagrVersionInfo = getNgPackagrVersionInfo;
4
+ const angular_version_utils_1 = require("../angular-version-utils");
5
+ let ngPackagrVersionInfo;
6
+ function getNgPackagrVersionInfo() {
7
+ if (!ngPackagrVersionInfo) {
8
+ ngPackagrVersionInfo = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
9
+ }
10
+ return ngPackagrVersionInfo;
11
+ }
@@ -0,0 +1 @@
1
+ export declare function importNgPackagrPath<T>(path: string, ngPackagrMajorVersion: number): T;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importNgPackagrPath = importNgPackagrPath;
4
+ function importNgPackagrPath(path, ngPackagrMajorVersion) {
5
+ let finalPath = path;
6
+ if (ngPackagrMajorVersion >= 20 && !path.startsWith('ng-packagr/src/')) {
7
+ finalPath = path.replace(/^ng-packagr\//, 'ng-packagr/src/');
8
+ }
9
+ return require(finalPath);
10
+ }
@@ -18,7 +18,7 @@ const color_1 = require("ng-packagr/lib/utils/color");
18
18
  const tailwindcss_1 = require("../tailwindcss");
19
19
  const devkit_1 = require("@nx/devkit");
20
20
  const semver_1 = require("semver");
21
- const angular_version_utils_1 = require("../../angular-version-utils");
21
+ const ng_packagr_version_1 = require("../ng-packagr-version");
22
22
  const maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];
23
23
  const maxThreads = typeof maxWorkersVariable === 'string' && maxWorkersVariable !== ''
24
24
  ? +maxWorkersVariable
@@ -72,7 +72,7 @@ class StylesheetProcessor {
72
72
  currentDir = (0, path_1.dirname)(prevDir);
73
73
  }
74
74
  const browserslistData = (0, browserslist_1.default)(undefined, { path: this.basePath });
75
- const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
75
+ const { version: ngPackagrVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
76
76
  let tailwindConfigPath;
77
77
  let postcssConfiguration;
78
78
  if ((0, semver_1.gte)(ngPackagrVersion, '18.0.0')) {
@@ -163,7 +163,7 @@ class AsyncStylesheetProcessor {
163
163
  currentDir = (0, path_1.dirname)(prevDir);
164
164
  }
165
165
  const browserslistData = (0, browserslist_1.default)(undefined, { path: this.basePath });
166
- const { version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
166
+ const { version: ngPackagrVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
167
167
  let postcssConfiguration;
168
168
  if (ngPackagrVersion === '17.2.0') {
169
169
  const { loadPostcssConfiguration, } = require('ng-packagr/lib/styles/postcss-configuration');
@@ -1,2 +1,2 @@
1
1
  import type { FactoryProvider } from 'injection-js';
2
- export declare const STYLESHEET_PROCESSOR: FactoryProvider;
2
+ export declare function getStylesheetProcessorFactoryProvider(): FactoryProvider;
@@ -1,22 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STYLESHEET_PROCESSOR = void 0;
4
- const stylesheet_processor_di_1 = require("ng-packagr/lib/styles/stylesheet-processor.di");
5
- const angular_version_utils_1 = require("../angular-version-utils");
6
- exports.STYLESHEET_PROCESSOR = {
7
- provide: stylesheet_processor_di_1.STYLESHEET_PROCESSOR_TOKEN,
8
- useFactory: () => {
9
- const { major: ngPackagrMajorVersion, version: ngPackagrVersion } = (0, angular_version_utils_1.getInstalledPackageVersionInfo)('ng-packagr');
10
- if (ngPackagrMajorVersion >= 19) {
11
- const { StylesheetProcessor } = require('./v19+/stylesheet-processor');
12
- return StylesheetProcessor;
13
- }
14
- if (ngPackagrVersion !== '17.2.0') {
15
- const { StylesheetProcessor } = require('./pre-v19/stylesheet-processor');
16
- return StylesheetProcessor;
17
- }
18
- const { AsyncStylesheetProcessor, } = require('./pre-v19/stylesheet-processor');
19
- return AsyncStylesheetProcessor;
20
- },
21
- deps: [],
22
- };
3
+ exports.getStylesheetProcessorFactoryProvider = getStylesheetProcessorFactoryProvider;
4
+ const ng_packagr_version_1 = require("./ng-packagr-version");
5
+ const package_imports_1 = require("./package-imports");
6
+ function getStylesheetProcessorFactoryProvider() {
7
+ const { major: ngPackagrMajorVersion, version: ngPackagrVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
8
+ const { STYLESHEET_PROCESSOR_TOKEN } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/styles/stylesheet-processor.di', ngPackagrMajorVersion);
9
+ return {
10
+ provide: STYLESHEET_PROCESSOR_TOKEN,
11
+ useFactory: () => {
12
+ if (ngPackagrMajorVersion >= 19) {
13
+ const { getStylesheetProcessor, } = require('./v19+/stylesheet-processor');
14
+ return getStylesheetProcessor();
15
+ }
16
+ if (ngPackagrVersion !== '17.2.0') {
17
+ const { StylesheetProcessor, } = require('./pre-v19/stylesheet-processor');
18
+ return StylesheetProcessor;
19
+ }
20
+ const { AsyncStylesheetProcessor, } = require('./pre-v19/stylesheet-processor');
21
+ return AsyncStylesheetProcessor;
22
+ },
23
+ deps: [],
24
+ };
25
+ }
@@ -4,20 +4,11 @@
4
4
  * Changes made:
5
5
  * - Add the project root to the search directories.
6
6
  */
7
- import { NgPackageEntryConfig } from 'ng-packagr/ng-entrypoint.schema';
8
- import { ComponentStylesheetBundler } from 'ng-packagr/lib/styles/component-stylesheets';
7
+ import type { NgPackageEntryConfig } from 'ng-packagr/ng-entrypoint.schema';
9
8
  export declare enum CssUrl {
10
9
  inline = "inline",
11
10
  none = "none"
12
11
  }
13
- export declare class StylesheetProcessor extends ComponentStylesheetBundler {
14
- protected readonly projectBasePath: string;
15
- protected readonly basePath: string;
16
- protected readonly cssUrl?: CssUrl;
17
- protected readonly includePaths?: string[];
18
- protected readonly sass?: NgPackageEntryConfig['lib']['sass'];
19
- protected readonly cacheDirectory?: string | false;
20
- protected readonly watch?: boolean;
21
- constructor(projectBasePath: string, basePath: string, cssUrl?: CssUrl, includePaths?: string[], sass?: NgPackageEntryConfig['lib']['sass'], cacheDirectory?: string | false, watch?: boolean);
22
- destroy(): void;
23
- }
12
+ export declare function getStylesheetProcessor(): new (projectBasePath: string, basePath: string, cssUrl?: CssUrl, includePaths?: string[], sass?: NgPackageEntryConfig['lib']['sass'], cacheDirectory?: string | false, watch?: boolean) => {
13
+ [key: string]: any;
14
+ };
@@ -6,61 +6,67 @@
6
6
  * - Add the project root to the search directories.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.StylesheetProcessor = exports.CssUrl = void 0;
9
+ exports.CssUrl = void 0;
10
+ exports.getStylesheetProcessor = getStylesheetProcessor;
10
11
  const tslib_1 = require("tslib");
11
- const browserslist_1 = tslib_1.__importDefault(require("browserslist"));
12
- const component_stylesheets_1 = require("ng-packagr/lib/styles/component-stylesheets");
13
- const postcss_configuration_1 = require("ng-packagr/lib/styles/postcss-configuration");
14
12
  const devkit_1 = require("@nx/devkit");
13
+ const browserslist_1 = tslib_1.__importDefault(require("browserslist"));
14
+ const ng_packagr_version_1 = require("../ng-packagr-version");
15
+ const package_imports_1 = require("../package-imports");
15
16
  var CssUrl;
16
17
  (function (CssUrl) {
17
18
  CssUrl["inline"] = "inline";
18
19
  CssUrl["none"] = "none";
19
20
  })(CssUrl || (exports.CssUrl = CssUrl = {}));
20
- class StylesheetProcessor extends component_stylesheets_1.ComponentStylesheetBundler {
21
- constructor(projectBasePath, basePath, cssUrl, includePaths, sass, cacheDirectory, watch) {
22
- // By default, browserslist defaults are too inclusive
23
- // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522
24
- // We change the default query to browsers that Angular support.
25
- // https://angular.io/guide/browser-support
26
- browserslist_1.default.defaults = [
27
- 'last 2 Chrome versions',
28
- 'last 1 Firefox version',
29
- 'last 2 Edge major versions',
30
- 'last 2 Safari major versions',
31
- 'last 2 iOS major versions',
32
- 'Firefox ESR',
33
- ];
34
- const browserslistData = (0, browserslist_1.default)(undefined, { path: basePath });
35
- let searchDirs = (0, postcss_configuration_1.generateSearchDirectories)([projectBasePath]);
36
- const postcssConfiguration = (0, postcss_configuration_1.loadPostcssConfiguration)(searchDirs);
37
- // (nx-specific): we support loading the TailwindCSS config from the root of the workspace
38
- searchDirs = (0, postcss_configuration_1.generateSearchDirectories)([projectBasePath, devkit_1.workspaceRoot]);
39
- super({
40
- cacheDirectory: cacheDirectory,
41
- postcssConfiguration: postcssConfiguration,
42
- tailwindConfiguration: postcssConfiguration
43
- ? undefined
44
- : (0, postcss_configuration_1.getTailwindConfig)(searchDirs, projectBasePath),
45
- sass: sass,
46
- workspaceRoot: projectBasePath,
47
- cssUrl: cssUrl,
48
- target: transformSupportedBrowsersToTargets(browserslistData),
49
- includePaths: includePaths,
50
- }, 'css', watch);
51
- this.projectBasePath = projectBasePath;
52
- this.basePath = basePath;
53
- this.cssUrl = cssUrl;
54
- this.includePaths = includePaths;
55
- this.sass = sass;
56
- this.cacheDirectory = cacheDirectory;
57
- this.watch = watch;
58
- }
59
- destroy() {
60
- void super.dispose();
21
+ function getStylesheetProcessor() {
22
+ const { major: ngPackagrMajorVersion } = (0, ng_packagr_version_1.getNgPackagrVersionInfo)();
23
+ const { ComponentStylesheetBundler } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/styles/component-stylesheets', ngPackagrMajorVersion);
24
+ const { generateSearchDirectories, getTailwindConfig, loadPostcssConfiguration, } = (0, package_imports_1.importNgPackagrPath)('ng-packagr/lib/styles/postcss-configuration', ngPackagrMajorVersion);
25
+ class StylesheetProcessor extends ComponentStylesheetBundler {
26
+ constructor(projectBasePath, basePath, cssUrl, includePaths, sass, cacheDirectory, watch) {
27
+ // By default, browserslist defaults are too inclusive
28
+ // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522
29
+ // We change the default query to browsers that Angular support.
30
+ // https://angular.io/guide/browser-support
31
+ browserslist_1.default.defaults = [
32
+ 'last 2 Chrome versions',
33
+ 'last 1 Firefox version',
34
+ 'last 2 Edge major versions',
35
+ 'last 2 Safari major versions',
36
+ 'last 2 iOS major versions',
37
+ 'Firefox ESR',
38
+ ];
39
+ const browserslistData = (0, browserslist_1.default)(undefined, { path: basePath });
40
+ let searchDirs = generateSearchDirectories([projectBasePath]);
41
+ const postcssConfiguration = loadPostcssConfiguration(searchDirs);
42
+ // (nx-specific): we support loading the TailwindCSS config from the root of the workspace
43
+ searchDirs = generateSearchDirectories([projectBasePath, devkit_1.workspaceRoot]);
44
+ super({
45
+ cacheDirectory: cacheDirectory,
46
+ postcssConfiguration: postcssConfiguration,
47
+ tailwindConfiguration: postcssConfiguration
48
+ ? undefined
49
+ : getTailwindConfig(searchDirs, projectBasePath),
50
+ sass: sass,
51
+ workspaceRoot: projectBasePath,
52
+ cssUrl: cssUrl,
53
+ target: transformSupportedBrowsersToTargets(browserslistData),
54
+ includePaths: includePaths,
55
+ }, 'css', watch);
56
+ this.projectBasePath = projectBasePath;
57
+ this.basePath = basePath;
58
+ this.cssUrl = cssUrl;
59
+ this.includePaths = includePaths;
60
+ this.sass = sass;
61
+ this.cacheDirectory = cacheDirectory;
62
+ this.watch = watch;
63
+ }
64
+ destroy() {
65
+ void super.dispose();
66
+ }
61
67
  }
68
+ return StylesheetProcessor;
62
69
  }
63
- exports.StylesheetProcessor = StylesheetProcessor;
64
70
  function transformSupportedBrowsersToTargets(supportedBrowsers) {
65
71
  const transformed = [];
66
72
  // https://esbuild.github.io/api/#target