|
|
@@ -16,7 +16,7 @@ nr build core --formats cjs
|
|
|
```
|
|
|
*/
|
|
|
|
|
|
-import fs from 'node:fs/promises'
|
|
|
+import fs from 'node:fs'
|
|
|
import { parseArgs } from 'node:util'
|
|
|
import { existsSync, readFileSync } from 'node:fs'
|
|
|
import path from 'node:path'
|
|
|
@@ -84,7 +84,7 @@ const sizeDir = path.resolve('temp/size')
|
|
|
run()
|
|
|
|
|
|
async function run() {
|
|
|
- if (writeSize) await fs.mkdir(sizeDir, { recursive: true })
|
|
|
+ if (writeSize) fs.mkdirSync(sizeDir, { recursive: true })
|
|
|
const removeCache = scanEnums()
|
|
|
try {
|
|
|
const resolvedTargets = targets.length
|
|
|
@@ -151,13 +151,18 @@ async function runParallel(maxConcurrency, source, iteratorFn) {
|
|
|
return Promise.all(ret)
|
|
|
}
|
|
|
|
|
|
+const privatePackages = fs.readdirSync('packages-private')
|
|
|
+
|
|
|
/**
|
|
|
* Builds the target.
|
|
|
* @param {string} target - The target to build.
|
|
|
* @returns {Promise<void>} - A promise representing the build process.
|
|
|
*/
|
|
|
async function build(target) {
|
|
|
- const pkgDir = path.resolve(`packages/${target}`)
|
|
|
+ const pkgBase = privatePackages.includes(target)
|
|
|
+ ? `packages-private`
|
|
|
+ : `packages`
|
|
|
+ const pkgDir = path.resolve(`${pkgBase}/${target}`)
|
|
|
const pkg = JSON.parse(readFileSync(`${pkgDir}/package.json`, 'utf-8'))
|
|
|
|
|
|
// if this is a full build (no specific targets), ignore private packages
|
|
|
@@ -167,7 +172,7 @@ async function build(target) {
|
|
|
|
|
|
// if building a specific format, do not remove dist.
|
|
|
if (!formats && existsSync(`${pkgDir}/dist`)) {
|
|
|
- await fs.rm(`${pkgDir}/dist`, { recursive: true })
|
|
|
+ fs.rmSync(`${pkgDir}/dist`, { recursive: true })
|
|
|
}
|
|
|
|
|
|
const env =
|
|
|
@@ -232,7 +237,7 @@ async function checkFileSize(filePath) {
|
|
|
if (!existsSync(filePath)) {
|
|
|
return
|
|
|
}
|
|
|
- const file = await fs.readFile(filePath)
|
|
|
+ const file = fs.readFileSync(filePath)
|
|
|
const fileName = path.basename(filePath)
|
|
|
|
|
|
const gzipped = gzipSync(file)
|
|
|
@@ -247,7 +252,7 @@ async function checkFileSize(filePath) {
|
|
|
)
|
|
|
|
|
|
if (writeSize)
|
|
|
- await fs.writeFile(
|
|
|
+ fs.writeFileSync(
|
|
|
path.resolve(sizeDir, `${fileName}.json`),
|
|
|
JSON.stringify({
|
|
|
file: fileName,
|