Skip to content

Commit ab0434f

Browse files
committed
build: use TSGo (TS 7.0 dev) to speed up building types
Also simplify and put timers into the bootstrap script
1 parent ab0536f commit ab0434f

6 files changed

Lines changed: 164 additions & 82 deletions

File tree

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"packages/*"
1515
],
1616
"scripts": {
17-
"build:themes": "ui-scripts build-themes",
1817
"prestart": "pnpm run bootstrap",
1918
"start": "pnpm --filter docs-app start",
2019
"start:watch": "pnpm --filter docs-app start:watch",
@@ -30,8 +29,9 @@
3029
"build": "pnpm -r --stream build",
3130
"build:watch": "pnpm -r --stream build:watch",
3231
"build:docs": "pnpm --filter docs-app bundle",
32+
"build:themes": "ui-scripts build-themes",
3333
"build:tokens": "ui-scripts generate-all-tokens",
34-
"build:types": "tsc -b tsconfig.references.json",
34+
"build:types": "tsgo -b tsconfig.references.json",
3535
"build:ts": "pnpm --filter @instructure/ui-icons prepare-build && pnpm run build:types",
3636
"clean": "node scripts/clean.js",
3737
"clean-node": "node scripts/clean.js --nuke_node",
@@ -76,6 +76,7 @@
7676
"@types/node": "^22",
7777
"@types/react": "18.3.26",
7878
"@types/react-dom": "18.3.1",
79+
"@typescript/native-preview": "7.0.0-dev.20260526.1",
7980
"@vitejs/plugin-react": "^4.5.1",
8081
"@vitest/eslint-plugin": "^1.6.14",
8182
"babel-plugin-add-import-extension": "^1.6.0",

packages/__docs__/globals.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ import ReactDOM from 'react-dom'
3434

3535
import { LoremIpsum } from 'lorem-ipsum'
3636
import moment from 'moment'
37-
// @ts-expect-error no type declarations for moment locales side-effect import
3837
import 'moment/min/locales'
39-
4038
import { mirrorHorizontalPlacement } from '@instructure/ui-position'
41-
4239
import { getComponentsForVersion } from './versioned-components'
4340
import { dark, light } from '@instructure/ui-themes'
4441
import { debounce } from '@instructure/debounce'

packages/ui-table/src/Table/__tests__/Table.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,11 @@ describe('<Table />', async () => {
209209
<Table.Body>
210210
test
211211
<span>test</span>
212-
{/* @ts-ignore error is normal here */}
212+
{/* @ts-expect-error error is normal here */}
213213
<Table.Row>
214214
test
215215
<span>test</span>
216+
{/* @ts-expect-error error is normal here */}
216217
<Table.Cell>Foo</Table.Cell>
217218
test
218219
<span>test</span>

pnpm-lock.yaml

Lines changed: 92 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/bootstrap.js

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,71 +23,75 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424
* SOFTWARE.
2525
*/
26-
const { execSync, fork } = require('child_process')
26+
const { execSync } = require('child_process')
2727
const path = require('path')
2828

2929
const opts = { stdio: 'inherit' }
30-
function buildProject() {
31-
console.info('Fetching design tokens...')
32-
try {
33-
execSync(
34-
'pnpm --filter @instructure/ui-scripts update @instructure/instructure-design-tokens',
35-
opts
36-
)
37-
} catch (error) {
38-
console.error(
39-
"'pnpm --filter @instructure/ui-scripts update @instructure/instructure-design-tokens' failed",
40-
error
41-
)
42-
process.exit(1)
43-
}
4430

45-
console.info('Building themes...')
46-
try {
47-
execSync('pnpm run build:themes', opts)
48-
} catch (error) {
49-
console.error("'pnpm run build:themes' failed", error)
50-
process.exit(1)
51-
}
31+
function format(ms) {
32+
return `${(ms / 1000).toFixed(1)}s`
33+
}
5234

53-
execSync('pnpm --filter @instructure/ui-icons prepare-build', opts)
54-
55-
// Executes a ui-codemods script to generate a versioned components list
56-
// from the ui metapackage's latest re-export file. This is required for
57-
// the updateInstUIImportVersions codemod's diagnose mode.
58-
execSync(
59-
'pnpm --filter @instructure/ui-codemods generate:versioned-exports',
60-
opts
61-
)
62-
63-
console.info('Building packages with Babel...')
64-
try {
65-
execSync('pnpm run build', opts)
66-
} catch (error) {
67-
console.error("'pnpm run build' failed", error)
68-
process.exit(1)
35+
function mark(name) {
36+
console.log(`\n================================================`)
37+
console.log(`${name}...`)
38+
if (steps.length) {
39+
steps[steps.length - 1].duration =
40+
Date.now() - steps[steps.length - 1].start
6941
}
42+
steps.push({ name, start: Date.now(), duration: 0 })
43+
}
7044

71-
console.info('Generating tokens...')
72-
try {
73-
execSync('pnpm run build:tokens', opts)
74-
} catch (error) {
75-
console.error("'pnpm run build:tokens' failed", error)
76-
process.exit(1)
77-
}
45+
const steps = []
46+
const bootstrapStart = Date.now()
7847

79-
console.info('Building TypeScript declarations...')
80-
try {
81-
execSync('pnpm run build:types', opts)
82-
} catch (error) {
83-
console.error("'pnpm run build:types' failed", error)
84-
process.exit(1)
85-
}
86-
}
48+
mark('Deleting build artifacts')
49+
execSync(path.resolve('scripts/clean.js'), opts)
8750

88-
function bootstrap() {
89-
execSync(path.resolve('scripts/clean.js'), opts)
90-
buildProject()
91-
}
51+
mark('Fetching design tokens')
52+
execSync(
53+
'pnpm --filter @instructure/ui-scripts update @instructure/instructure-design-tokens',
54+
opts
55+
)
56+
57+
mark('Building themes')
58+
execSync('pnpm run build:themes', opts)
9259

93-
bootstrap()
60+
mark('Preparing icons')
61+
execSync('pnpm --filter @instructure/ui-icons prepare-build', opts)
62+
63+
mark('Generating package list for codemods')
64+
execSync(
65+
'pnpm --filter @instructure/ui-codemods generate:versioned-exports',
66+
opts
67+
)
68+
69+
mark('Building packages with Babel')
70+
execSync('pnpm run build', opts)
71+
72+
mark('Generating design tokens')
73+
execSync('pnpm run build:tokens', opts)
74+
75+
mark('Building TypeScript declarations')
76+
execSync('pnpm run build:types', opts)
77+
78+
// Log build time summary. Assumes that the build is not parallel
79+
steps[steps.length - 1].duration = Date.now() - steps[steps.length - 1].start
80+
81+
const total = Date.now() - bootstrapStart
82+
const nameW = Math.max(...steps.map((s) => s.name.length))
83+
const durW = Math.max(
84+
...steps.map((s) => format(s.duration).length),
85+
format(total).length
86+
)
87+
const tableWidth = nameW + durW + 7
88+
89+
console.log('\n' + '='.repeat(tableWidth))
90+
console.log(' Bootstrap Summary')
91+
console.log('='.repeat(tableWidth))
92+
for (const s of steps) {
93+
console.log(` ${s.name.padEnd(nameW)} ${format(s.duration).padStart(durW)}`)
94+
}
95+
console.log('-'.repeat(tableWidth))
96+
console.log(` ${'Total'.padEnd(nameW)} ${format(total).padStart(durW)}`)
97+
console.log('='.repeat(tableWidth))

0 commit comments

Comments
 (0)