Skip to content

Commit

Permalink
🩹 fix: parallelism (#2386)
Browse files Browse the repository at this point in the history
- Nightly revealed that I am doing way too much with the `parallelism` static. 
- Indicate compiler label in logger

## Type of change

**PATCH: backwards compatible change**
  • Loading branch information
kellymears committed Jul 20, 2023
1 parent dfe7116 commit 96cb653
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
8 changes: 4 additions & 4 deletions sources/@roots/bud-build/src/config/infrastructureLogging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ export const infrastructureLogging: Factory<
console: bud.hooks.filter(`build.infrastructureLogging.console`, {
...console,
error: (...args: any[]) => {
logger.scope(`webpack`).error(...args)
logger.scope(bud.label, `webpack`).error(...args)
},
info: (...args: any[]) => {
logger.scope(`webpack`).info(...args)
logger.scope(bud.label, `webpack`).info(...args)
},
log: (...args: any[]) => {
logger.scope(`webpack`).log(...args)
logger.scope(bud.label, `webpack`).log(...args)
},
warn: (...args: any[]) => {
logger.scope(`webpack`).info(...args)
logger.scope(bud.label, `webpack`).info(...args)
},
}),
level: bud.hooks.filter(`build.infrastructureLogging.level`, `log`),
Expand Down
1 change: 1 addition & 0 deletions sources/@roots/bud-build/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export class Build extends Service implements BudBuild {
)

this.logger.success(`configuration successfully built`)
this.logger.info(this.config)
await this.app.hooks.fire(`build.after`, this.app)

return this.config
Expand Down
11 changes: 2 additions & 9 deletions sources/@roots/bud-compiler/src/service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,7 @@ export class Compiler extends Service implements BudCompiler {
),
)

const cores = Math.max(cpus().length, 1)
const compilations = Math.max(
Object.keys(bud.children ?? []).length,
1,
)
const parallelism = Math.max(Math.floor(cores / compilations), 1)

this.config.parallelism = parallelism
this.config.parallelism = Math.max(cpus().length - 1, 1)
this.logger.info(`parallel compilations: ${this.config.parallelism}`)

await bud.hooks.fire(`compiler.before`, bud).catch(error => {
Expand All @@ -96,7 +89,6 @@ export class Compiler extends Service implements BudCompiler {

this.instance.hooks.done.tap(bud.label, (stats: any) => {
this.onStats(stats)

bud.hooks.fire(`compiler.done`, bud, this.stats).catch(error => {
throw error
})
Expand All @@ -111,6 +103,7 @@ export class Compiler extends Service implements BudCompiler {
@bind
public onError(error: BudErrorClass | webpack.WebpackError) {
process.exitCode = 1
if (!error) return

this.app.server?.appliedMiddleware?.hot?.publish({error})

Expand Down

0 comments on commit 96cb653

Please sign in to comment.