Skip to content

chore(build): replace node:fs repeated import #13467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ nr build core --formats cjs

import fs from 'node:fs'
import { parseArgs } from 'node:util'
import { existsSync, readFileSync } from 'node:fs'
import path from 'node:path'
import { brotliCompressSync, gzipSync } from 'node:zlib'
import pico from 'picocolors'
Expand Down Expand Up @@ -163,15 +162,15 @@ async function build(target) {
? `packages-private`
: `packages`
const pkgDir = path.resolve(`${pkgBase}/${target}`)
const pkg = JSON.parse(readFileSync(`${pkgDir}/package.json`, 'utf-8'))
const pkg = JSON.parse(fs.readFileSync(`${pkgDir}/package.json`, 'utf-8'))

// if this is a full build (no specific targets), ignore private packages
if ((isRelease || !targets.length) && pkg.private) {
return
}

// if building a specific format, do not remove dist.
if (!formats && existsSync(`${pkgDir}/dist`)) {
if (!formats && fs.existsSync(`${pkgDir}/dist`)) {
fs.rmSync(`${pkgDir}/dist`, { recursive: true })
}

Expand Down Expand Up @@ -234,7 +233,7 @@ async function checkSize(target) {
* @returns {Promise<void>}
*/
async function checkFileSize(filePath) {
if (!existsSync(filePath)) {
if (!fs.existsSync(filePath)) {
return
}
const file = fs.readFileSync(filePath)
Expand Down