ng-packagr
Advanced tools
Comparing version 17.2.0 to 17.2.1
export interface PostcssConfiguration { | ||
plugins: [name: string, options?: object | string][]; | ||
} | ||
export declare function loadPostcssConfiguration(projectRoot: string): Promise<PostcssConfiguration | undefined>; | ||
export declare function loadPostcssConfiguration(projectRoot: string): PostcssConfiguration | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadPostcssConfiguration = void 0; | ||
const promises_1 = require("node:fs/promises"); | ||
const node_fs_1 = require("node:fs"); | ||
const node_path_1 = require("node:path"); | ||
const postcssConfigurationFiles = ['postcss.config.json', '.postcssrc.json']; | ||
async function generateSearchDirectories(roots) { | ||
return await Promise.all(roots.map(root => (0, promises_1.readdir)(root, { withFileTypes: true }).then(entries => ({ | ||
root, | ||
files: new Set(entries.filter(entry => entry.isFile()).map(entry => entry.name)), | ||
})))); | ||
function generateSearchDirectories(roots) { | ||
return roots.map(root => { | ||
const entries = (0, node_fs_1.readdirSync)(root, { withFileTypes: true }); | ||
return { | ||
root, | ||
files: new Set(entries.filter(entry => entry.isFile()).map(entry => entry.name)), | ||
}; | ||
}); | ||
} | ||
@@ -23,10 +26,10 @@ function findFile(searchDirectories, potentialFiles) { | ||
} | ||
async function readPostcssConfiguration(configurationFile) { | ||
const data = await (0, promises_1.readFile)(configurationFile, 'utf-8'); | ||
function readPostcssConfiguration(configurationFile) { | ||
const data = (0, node_fs_1.readFileSync)(configurationFile, 'utf-8'); | ||
const config = JSON.parse(data); | ||
return config; | ||
} | ||
async function loadPostcssConfiguration(projectRoot) { | ||
function loadPostcssConfiguration(projectRoot) { | ||
// A configuration file can exist in the project or workspace root | ||
const searchDirectories = await generateSearchDirectories([projectRoot]); | ||
const searchDirectories = generateSearchDirectories([projectRoot]); | ||
const configPath = findFile(searchDirectories, postcssConfigurationFiles); | ||
@@ -36,3 +39,3 @@ if (!configPath) { | ||
} | ||
const raw = await readPostcssConfiguration(configPath); | ||
const raw = readPostcssConfiguration(configPath); | ||
// If no plugins are defined, consider it equivalent to no configuration | ||
@@ -39,0 +42,0 @@ if (!raw.plugins || typeof raw.plugins !== 'object') { |
@@ -41,3 +41,3 @@ "use strict"; | ||
async process({ filePath, content }) { | ||
await this.createRenderWorker(); | ||
this.createRenderWorker(); | ||
return this.renderWorker.run({ content, filePath }); | ||
@@ -50,3 +50,4 @@ } | ||
} | ||
async createRenderWorker() { | ||
createRenderWorker() { | ||
// Do not use async FS calls in here as otherwise a race will be created which causes multiple FS calls to be done. | ||
if (this.renderWorker) { | ||
@@ -70,2 +71,3 @@ return; | ||
maxThreads, | ||
recordTiming: false, | ||
env: { | ||
@@ -76,3 +78,3 @@ ...process.env, | ||
workerData: { | ||
postcssConfiguration: await (0, postcss_configuration_1.loadPostcssConfiguration)(this.projectBasePath), | ||
postcssConfiguration: (0, postcss_configuration_1.loadPostcssConfiguration)(this.projectBasePath), | ||
tailwindConfigPath: getTailwindConfigPath(this.projectBasePath), | ||
@@ -79,0 +81,0 @@ projectBasePath: this.projectBasePath, |
{ | ||
"name": "ng-packagr", | ||
"version": "17.2.0", | ||
"version": "17.2.1", | ||
"description": "Compile and package Angular libraries in Angular Package Format (APF)", | ||
@@ -53,3 +53,3 @@ "keywords": [ | ||
"ora": "^5.1.0", | ||
"piscina": "^4.2.0", | ||
"piscina": "^4.4.0", | ||
"postcss": "^8.4.31", | ||
@@ -56,0 +56,0 @@ "rxjs": "^7.8.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
472788
4988
Updatedpiscina@^4.4.0