@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.
- package/package.json +9 -9
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.d.ts +3 -7
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.js +17 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-bundles.di.d.ts +2 -2
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-bundles.di.js +14 -9
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-bundles.transform.js +28 -23
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.d.ts +1 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-packagr.js +6 -3
- package/src/executors/package/ng-packagr-adjustments/ng-packagr.d.ts +1 -1
- package/src/executors/package/ng-packagr-adjustments/ng-packagr.js +2 -2
- package/src/executors/utilities/ng-packagr/ng-packagr-version.d.ts +2 -0
- package/src/executors/utilities/ng-packagr/ng-packagr-version.js +11 -0
- package/src/executors/utilities/ng-packagr/package-imports.d.ts +1 -0
- package/src/executors/utilities/ng-packagr/package-imports.js +10 -0
- package/src/executors/utilities/ng-packagr/pre-v19/stylesheet-processor.js +3 -3
- package/src/executors/utilities/ng-packagr/stylesheet-processor.di.d.ts +1 -1
- package/src/executors/utilities/ng-packagr/stylesheet-processor.di.js +23 -20
- package/src/executors/utilities/ng-packagr/v19+/stylesheet-processor.d.ts +4 -13
- 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.
|
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.
|
71
|
-
"@nx/js": "21.0.0-canary.
|
72
|
-
"@nx/eslint": "21.0.0-canary.
|
73
|
-
"@nx/webpack": "21.0.0-canary.
|
74
|
-
"@nx/rspack": "21.0.0-canary.
|
75
|
-
"@nx/module-federation": "21.0.0-canary.
|
76
|
-
"@nx/web": "21.0.0-canary.
|
77
|
-
"@nx/workspace": "21.0.0-canary.
|
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": {
|
package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.d.ts
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
import
|
2
|
-
|
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;
|
package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/entry-point.js
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
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.
|
4
|
-
const
|
5
|
-
const
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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) =>
|
20
|
-
const
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
33
|
-
|
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
|
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 {
|
7
|
-
const {
|
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([
|
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 {
|
6
|
+
const { getStylesheetProcessorFactoryProvider } = await import('../../utilities/ng-packagr/stylesheet-processor.di.js');
|
7
7
|
const packagr = (0, ng_packagr_1.ngPackagr)();
|
8
|
-
packagr.withProviders([
|
8
|
+
packagr.withProviders([getStylesheetProcessorFactoryProvider()]);
|
9
9
|
return packagr;
|
10
10
|
}
|
@@ -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
|
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,
|
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,
|
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
|
2
|
+
export declare function getStylesheetProcessorFactoryProvider(): FactoryProvider;
|
@@ -1,22 +1,25 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
4
|
-
const
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
14
|
-
|
15
|
-
|
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.
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|