Skip to content

Commit 0bcc5af

Browse files
balzssclaude
andcommitted
perf(scripts,ui-themes): optimize bootstrap with parallel builds
Performance improvements: - Run SWC compilation and TypeScript declarations in parallel - Move token generation after parallel build phase (requires SWC output) - Add "type": "module" to ui-themes to eliminate Node.js reparse overhead Results: - Bootstrap time reduced from ~50s to ~35s (30% faster) - SWC (24s) + TypeScript (31s) now run concurrently (31s total) - Token generation optimized to 0.8s 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 86f527e commit 0bcc5af

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

packages/ui-themes/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "11.0.1",
44
"description": "A library of instructure themes",
55
"author": "Instructure, Inc. Engineering and Product Design",
6+
"type": "module",
67
"module": "./es/index.js",
78
"main": "./es/index.js",
89
"types": "./types/index.d.ts",

scripts/bootstrap.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,15 @@ async function buildProject() {
125125
execSync('pnpm --filter @instructure/ui-icons prepare-build', opts)
126126
})
127127

128-
await trackPhase('SWC compilation', () => {
129-
console.info('Building packages with SWC...')
130-
execSync('pnpm run build', opts)
131-
})
132-
133-
console.info('Running token generation and TypeScript compilation in parallel...')
128+
console.info('Running SWC compilation and TypeScript declarations in parallel...')
134129

135-
const parallelPhases = [
136-
{ trackName: 'Token generation', name: 'Generating tokens', command: 'build:tokens' },
130+
const parallelBuildPhases = [
131+
{ trackName: 'SWC compilation', name: 'Building packages with SWC', command: 'build' },
137132
{ trackName: 'TypeScript declarations', name: 'Building TypeScript declarations', command: 'build:types' }
138133
]
139134

140135
await Promise.all(
141-
parallelPhases.map(({ trackName, name, command }) => {
136+
parallelBuildPhases.map(({ trackName, name, command }) => {
142137
return trackPhase(trackName, () => {
143138
return new Promise((resolve, reject) => {
144139
console.info(`${name}...`)
@@ -158,6 +153,25 @@ async function buildProject() {
158153
})
159154
})
160155
)
156+
157+
console.info('Generating tokens...')
158+
159+
await trackPhase('Token generation', () => {
160+
return new Promise((resolve, reject) => {
161+
const child = spawn('pnpm', ['run', 'build:tokens'], {
162+
stdio: 'inherit',
163+
shell: true
164+
})
165+
child.on('close', (code) => {
166+
if (code !== 0) {
167+
reject(new Error(`'build:tokens' failed with exit code ${code}`))
168+
} else {
169+
resolve()
170+
}
171+
})
172+
child.on('error', reject)
173+
})
174+
})
161175
}
162176
async function bootstrap() {
163177
const bootstrapStart = Date.now()

0 commit comments

Comments
 (0)