ng-packagr 17.2.0 → 17.3.0-rc.0
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export interface PostcssConfiguration {
|
|
2
2
|
plugins: [name: string, options?: object | string][];
|
|
3
3
|
}
|
|
4
|
-
export declare function loadPostcssConfiguration(projectRoot: string):
|
|
4
|
+
export declare function loadPostcssConfiguration(projectRoot: string): PostcssConfiguration | undefined;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadPostcssConfiguration = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const postcssConfigurationFiles = ['postcss.config.json', '.postcssrc.json'];
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
root,
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
function generateSearchDirectories(roots) {
|
|
8
|
+
return roots.map(root => {
|
|
9
|
+
const entries = (0, node_fs_1.readdirSync)(root, { withFileTypes: true });
|
|
10
|
+
return {
|
|
11
|
+
root,
|
|
12
|
+
files: new Set(entries.filter(entry => entry.isFile()).map(entry => entry.name)),
|
|
13
|
+
};
|
|
14
|
+
});
|
|
12
15
|
}
|
|
13
16
|
function findFile(searchDirectories, potentialFiles) {
|
|
14
17
|
for (const { root, files } of searchDirectories) {
|
|
@@ -20,19 +23,19 @@ function findFile(searchDirectories, potentialFiles) {
|
|
|
20
23
|
}
|
|
21
24
|
return undefined;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
const data =
|
|
26
|
+
function readPostcssConfiguration(configurationFile) {
|
|
27
|
+
const data = (0, node_fs_1.readFileSync)(configurationFile, 'utf-8');
|
|
25
28
|
const config = JSON.parse(data);
|
|
26
29
|
return config;
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
function loadPostcssConfiguration(projectRoot) {
|
|
29
32
|
// A configuration file can exist in the project or workspace root
|
|
30
|
-
const searchDirectories =
|
|
33
|
+
const searchDirectories = generateSearchDirectories([projectRoot]);
|
|
31
34
|
const configPath = findFile(searchDirectories, postcssConfigurationFiles);
|
|
32
35
|
if (!configPath) {
|
|
33
36
|
return undefined;
|
|
34
37
|
}
|
|
35
|
-
const raw =
|
|
38
|
+
const raw = readPostcssConfiguration(configPath);
|
|
36
39
|
// If no plugins are defined, consider it equivalent to no configuration
|
|
37
40
|
if (!raw.plugins || typeof raw.plugins !== 'object') {
|
|
38
41
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postcss-configuration.js","sourceRoot":"","sources":["../../../src/lib/styles/postcss-configuration.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"postcss-configuration.js","sourceRoot":"","sources":["../../../src/lib/styles/postcss-configuration.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AACpD,yCAAiC;AAUjC,MAAM,yBAAyB,GAAa,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC;AAOvF,SAAS,yBAAyB,CAAC,KAAe;IAChD,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACtB,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAE3D,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACjF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,QAAQ,CAAC,iBAAoC,EAAE,cAAwB;IAC9E,KAAK,MAAM,EAAE,IAA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AAM,OAAO,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAClC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBAChC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YACjC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,mCAAmC;IACnC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAyB,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,CAAC,EAAE,CAAC;YAC7E,SAAS;QACX,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAlDD,4DAkDC","sourcesContent":["import { readFileSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport interface PostcssConfiguration {\n plugins: [name: string, options?: object | string][];\n}\n\ninterface RawPostcssConfiguration {\n plugins?: Record<string, object | string | boolean> | (string | [string, object])[];\n}\n\nconst postcssConfigurationFiles: string[] = ['postcss.config.json', '.postcssrc.json'];\n\ninterface SearchDirectory {\n root: string;\n files: Set<string>;\n}\n\nfunction generateSearchDirectories(roots: string[]): SearchDirectory[] {\n return roots.map(root => {\n const entries = readdirSync(root, { withFileTypes: true });\n\n return {\n root,\n files: new Set(entries.filter(entry => entry.isFile()).map(entry => entry.name)),\n };\n });\n}\n\nfunction findFile(searchDirectories: SearchDirectory[], potentialFiles: string[]): string | undefined {\n for (const { root, files } of searchDirectories) {\n for (const potential of potentialFiles) {\n if (files.has(potential)) {\n return join(root, potential);\n }\n }\n }\n\n return undefined;\n}\n\nfunction readPostcssConfiguration(configurationFile: string): RawPostcssConfiguration {\n const data = readFileSync(configurationFile, 'utf-8');\n const config = JSON.parse(data) as RawPostcssConfiguration;\n\n return config;\n}\n\nexport function loadPostcssConfiguration(projectRoot: string): PostcssConfiguration | undefined {\n // A configuration file can exist in the project or workspace root\n const searchDirectories = generateSearchDirectories([projectRoot]);\n\n const configPath = findFile(searchDirectories, postcssConfigurationFiles);\n if (!configPath) {\n return undefined;\n }\n\n const raw = readPostcssConfiguration(configPath);\n\n // If no plugins are defined, consider it equivalent to no configuration\n if (!raw.plugins || typeof raw.plugins !== 'object') {\n return undefined;\n }\n\n // Normalize plugin array form\n if (Array.isArray(raw.plugins)) {\n if (raw.plugins.length < 1) {\n return undefined;\n }\n\n const config: PostcssConfiguration = { plugins: [] };\n for (const element of raw.plugins) {\n if (typeof element === 'string') {\n config.plugins.push([element]);\n } else {\n config.plugins.push(element);\n }\n }\n\n return config;\n }\n\n // Normalize plugin object map form\n const entries = Object.entries(raw.plugins);\n if (entries.length < 1) {\n return undefined;\n }\n\n const config: PostcssConfiguration = { plugins: [] };\n for (const [name, options] of entries) {\n if (!options || (typeof options !== 'object' && typeof options !== 'string')) {\n continue;\n }\n\n config.plugins.push([name, options]);\n }\n\n return config;\n}\n"]}
|
|
@@ -38,7 +38,7 @@ class StylesheetProcessor {
|
|
|
38
38
|
];
|
|
39
39
|
}
|
|
40
40
|
async process({ filePath, content }) {
|
|
41
|
-
|
|
41
|
+
this.createRenderWorker();
|
|
42
42
|
return this.renderWorker.run({ content, filePath });
|
|
43
43
|
}
|
|
44
44
|
/** Destory workers in pool. */
|
|
@@ -46,7 +46,8 @@ class StylesheetProcessor {
|
|
|
46
46
|
var _a;
|
|
47
47
|
void ((_a = this.renderWorker) === null || _a === void 0 ? void 0 : _a.destroy());
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
createRenderWorker() {
|
|
50
|
+
// Do not use async FS calls in here as otherwise a race will be created which causes multiple FS calls to be done.
|
|
50
51
|
if (this.renderWorker) {
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
@@ -65,12 +66,13 @@ class StylesheetProcessor {
|
|
|
65
66
|
this.renderWorker = new piscina_1.default({
|
|
66
67
|
filename: require.resolve('./stylesheet-processor-worker'),
|
|
67
68
|
maxThreads,
|
|
69
|
+
recordTiming: false,
|
|
68
70
|
env: {
|
|
69
71
|
...process.env,
|
|
70
72
|
FORCE_COLOR: '' + color_1.colors.enabled,
|
|
71
73
|
},
|
|
72
74
|
workerData: {
|
|
73
|
-
postcssConfiguration:
|
|
75
|
+
postcssConfiguration: (0, postcss_configuration_1.loadPostcssConfiguration)(this.projectBasePath),
|
|
74
76
|
tailwindConfigPath: getTailwindConfigPath(this.projectBasePath),
|
|
75
77
|
projectBasePath: this.projectBasePath,
|
|
76
78
|
browserslistData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAwC;AACxC,2BAAgC;AAChC,+BAAqC;AACrC,sDAA8B;AAC9B,0CAAwC;AACxC,mEAAmE;AAEnE,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAC/D,MAAM,UAAU,GAAG,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjH,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAED,MAAa,mBAAmB;IAG9B,YACmB,eAAuB,EACvB,QAAgB,EAChB,MAAe,EACf,YAAuB,EACvB,cAA+B;QAJ/B,oBAAe,GAAf,eAAe,CAAQ;QACvB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAS;QACf,iBAAY,GAAZ,YAAY,CAAW;QACvB,mBAAc,GAAd,cAAc,CAAiB;QAEhD,sDAAsD;QACtD,gHAAgH;QAChH,gEAAgE;QAChE,2CAA2C;QAC1C,sBAAY,CAAC,QAAqB,GAAG;YACpC,wBAAwB;YACxB,wBAAwB;YACxB,4BAA4B;YAC5B,8BAA8B;YAC9B,2BAA2B;YAC3B,aAAa;SACd,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAyC;QACxE,
|
|
1
|
+
{"version":3,"file":"stylesheet-processor.js","sourceRoot":"","sources":["../../../src/lib/styles/stylesheet-processor.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAwC;AACxC,2BAAgC;AAChC,+BAAqC;AACrC,sDAA8B;AAC9B,0CAAwC;AACxC,mEAAmE;AAEnE,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;AAC/D,MAAM,UAAU,GAAG,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjH,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAED,MAAa,mBAAmB;IAG9B,YACmB,eAAuB,EACvB,QAAgB,EAChB,MAAe,EACf,YAAuB,EACvB,cAA+B;QAJ/B,oBAAe,GAAf,eAAe,CAAQ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,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,wBAAwB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9C,IAAI,WAAW,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACjD,2FAA2F;gBAC3F,0FAA0F;gBAC1F,OAAO,GAAG,KAAK,CAAC;YAClB,CAAC;YAED,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,+KAA+K;AAC/K,MAAM,mBAAmB,GAAG;IAC1B,sBAAsB;IACtB,uBAAuB;IACvB,uBAAuB;IACvB,sBAAsB;CACvB,CAAC;AAEF,SAAS,qBAAqB,CAAC,WAAmB;IAChD,kEAAkE;IAClE,KAAK,MAAM,UAAU,IAAI,mBAAmB,EAAE,CAAC;QAC7C,sFAAsF;QACtF,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAC/C,IAAI,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YACzB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import browserslist from 'browserslist';\nimport { existsSync } from 'fs';\nimport { dirname, join } from 'path';\nimport Piscina from 'piscina';\nimport { colors } from '../utils/color';\nimport { loadPostcssConfiguration } from './postcss-configuration';\n\nconst maxWorkersVariable = process.env['NG_BUILD_MAX_WORKERS'];\nconst maxThreads = typeof maxWorkersVariable === 'string' && maxWorkersVariable !== '' ? +maxWorkersVariable : 4;\n\nexport enum CssUrl {\n inline = 'inline',\n none = 'none',\n}\n\nexport class StylesheetProcessor {\n private renderWorker: Piscina | undefined;\n\n constructor(\n private readonly projectBasePath: string,\n private readonly basePath: string,\n private readonly cssUrl?: CssUrl,\n private readonly includePaths?: string[],\n private readonly cacheDirectory?: string | false,\n ) {\n // By default, browserslist defaults are too inclusive\n // https://github.com/browserslist/browserslist/blob/83764ea81ffaa39111c204b02c371afa44a4ff07/index.js#L516-L522\n // We change the default query to browsers that Angular support.\n // https://angular.io/guide/browser-support\n (browserslist.defaults as string[]) = [\n 'last 2 Chrome versions',\n 'last 1 Firefox version',\n 'last 2 Edge major versions',\n 'last 2 Safari major versions',\n 'last 2 iOS major versions',\n 'Firefox ESR',\n ];\n }\n\n async process({ filePath, content }: { filePath: string; content: string }): Promise<string> {\n this.createRenderWorker();\n\n return this.renderWorker.run({ content, filePath });\n }\n\n /** Destory workers in pool. */\n destroy(): void {\n void this.renderWorker?.destroy();\n }\n\n private createRenderWorker(): void {\n // Do not use async FS calls in here as otherwise a race will be created which causes multiple FS calls to be done.\n if (this.renderWorker) {\n return;\n }\n\n const styleIncludePaths = [...this.includePaths];\n let prevDir = null;\n let currentDir = this.basePath;\n\n while (currentDir !== prevDir) {\n const p = join(currentDir, 'node_modules');\n if (existsSync(p)) {\n styleIncludePaths.push(p);\n }\n\n prevDir = currentDir;\n currentDir = dirname(prevDir);\n }\n\n const browserslistData = browserslist(undefined, { path: this.basePath });\n\n this.renderWorker = new Piscina({\n filename: require.resolve('./stylesheet-processor-worker'),\n maxThreads,\n recordTiming: false,\n env: {\n ...process.env,\n FORCE_COLOR: '' + colors.enabled,\n },\n workerData: {\n postcssConfiguration: loadPostcssConfiguration(this.projectBasePath),\n tailwindConfigPath: getTailwindConfigPath(this.projectBasePath),\n projectBasePath: this.projectBasePath,\n browserslistData,\n targets: transformSupportedBrowsersToTargets(browserslistData),\n cacheDirectory: this.cacheDirectory,\n cssUrl: this.cssUrl,\n styleIncludePaths,\n },\n });\n }\n}\n\nfunction transformSupportedBrowsersToTargets(supportedBrowsers: string[]): string[] {\n const transformed: string[] = [];\n\n // https://esbuild.github.io/api/#target\n const esBuildSupportedBrowsers = new Set(['safari', 'firefox', 'edge', 'chrome', 'ios']);\n\n for (const browser of supportedBrowsers) {\n let [browserName, version] = browser.split(' ');\n\n // browserslist uses the name `ios_saf` for iOS Safari whereas esbuild uses `ios`\n if (browserName === 'ios_saf') {\n browserName = 'ios';\n }\n\n // browserslist uses ranges `15.2-15.3` versions but only the lowest is required\n // to perform minimum supported feature checks. esbuild also expects a single version.\n [version] = version.split('-');\n\n if (esBuildSupportedBrowsers.has(browserName)) {\n if (browserName === 'safari' && version === 'tp') {\n // esbuild only supports numeric versions so `TP` is converted to a high number (999) since\n // a Technology Preview (TP) of Safari is assumed to support all currently known features.\n version = '999';\n }\n\n transformed.push(browserName + version);\n }\n }\n\n return transformed.length ? transformed : undefined;\n}\n\n/** The list of valid config files can be found https://github.com/tailwindlabs/tailwindcss/blob/ba5454543e74a6d702ce11b410d27672c2ee4b3f/src/util/resolveConfigPath.js#L4-L9*/\nconst tailwindConfigFiles = [\n './tailwind.config.js',\n './tailwind.config.cjs',\n './tailwind.config.mjs',\n './tailwind.config.ts',\n];\n\nfunction getTailwindConfigPath(projectRoot: string): string | undefined {\n // A configuration file can exist in the project or workspace root\n for (const configFile of tailwindConfigFiles) {\n // Irrespective of the name project level configuration should always take precedence.\n const fullPath = join(projectRoot, configFile);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return undefined;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ng-packagr",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.3.0-rc.0",
|
|
4
4
|
"description": "Compile and package Angular libraries in Angular Package Format (APF)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apf",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"jsonc-parser": "^3.2.0",
|
|
51
51
|
"less": "^4.2.0",
|
|
52
52
|
"ora": "^5.1.0",
|
|
53
|
-
"piscina": "^4.
|
|
53
|
+
"piscina": "^4.4.0",
|
|
54
54
|
"postcss": "^8.4.31",
|
|
55
55
|
"rxjs": "^7.8.1",
|
|
56
56
|
"sass": "^1.69.5"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@angular/compiler-cli": "^17.0.0 || ^17.2.0-next.0 || ^17.3.0-next.0",
|
|
64
64
|
"tailwindcss": "^2.0.0 || ^3.0.0",
|
|
65
65
|
"tslib": "^2.3.0",
|
|
66
|
-
"typescript": ">=5.2 <5.
|
|
66
|
+
"typescript": ">=5.2 <5.5"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"tailwindcss": {
|