Skip to content

Commit

Permalink
chore: refactor rollup building
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon committed Jan 6, 2025
1 parent 2120e87 commit 8609c63
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
*
* DEFAULT VALUE: "warning"
*/
"logLevel": "warning",
"logLevel": "none", /* FIXME: Change to "warning" */

/**
* When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md),
Expand Down
8 changes: 7 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,13 @@ function createConfig(format, _output, plugins = []) {
],
output,
onwarn: (msg, warn) => {
if (!/Circular/.test(msg)) {
if (
!(
msg.code == 'CIRCULAR_DEPENDENCY' ||
msg.code == 'EMPTY_BUNDLE' ||
msg.code == 'UNRESOLVED_IMPORT'
)
) {
warn(msg)
}
},
Expand Down
22 changes: 21 additions & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ async function main() {
if (size) {
await checkAllSizes(resolvedTargets)
}

if (buildTypes) {
await buildTypingsAll(resolvedTargets)
}
}

async function buildAll(targets: string[]) {
Expand All @@ -117,6 +121,12 @@ async function main() {
console.log(`\nbuilt in ${(performance.now() - start).toFixed(2)}ms.`)
}

async function buildTypingsAll(targets: string[]) {
const start = performance.now()
await runParallel(os.cpus().length, targets, buildTypings)
console.log(`\nbundle dts in ${(performance.now() - start).toFixed(2)}ms.`)
}

async function runParallel(
maxConcurrency: number,
source: string[],
Expand Down Expand Up @@ -176,8 +186,18 @@ async function main() {
],
{ stdio: 'inherit' }
)
}

async function buildTypings(target: string) {
const pkgDir = path.resolve(__dirname, `../packages/${target}`)
const pkg = await readJson(`${pkgDir}/package.json`)

// only build published packages for release
if (isRelease && pkg.private) {
return
}

if (buildTypes && pkg.types) {
if (pkg.types) {
console.log()
console.log(
pc.bold(pc.yellow(`Rolling up type definitions for ${target}...`))
Expand Down

0 comments on commit 8609c63

Please sign in to comment.