-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add npm script to profile TypeScript builds #68533
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: 0 B Total Size: 1.84 MB ℹ️ View Unchanged
|
package.json
Outdated
@@ -181,6 +181,7 @@ | |||
"build": "npm run build:packages && wp-scripts build", | |||
"build:analyze-bundles": "npm run build -- --webpack-bundle-analyzer", | |||
"build:package-types": "node ./bin/packages/validate-typescript-version.js && ( tsc --build || ( echo 'tsc failed. Try cleaning up first: `npm run clean:package-types`'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js", | |||
"build:profile-types": "npm run clean:package-types && node ./bin/packages/validate-typescript-version.js && ( tsc --build --extendedDiagnostics --generateTrace ./ts-traces || ( echo 'tsc failed. Try cleaning up first: `npm run clean:package-types`'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js && npx @typescript/analyze-trace ts-traces > ts-traces/analysis.txt", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, if you really want to profile the TS build for slow compilation reasons, the analysis-txt
file is the most useful one. Should we render a message in the console linking to it? And/or should we spit its contents out to the console as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of speed, I tweaked the command so that it prints a success message pointing to the folder and the analysis.txt
file, plus a command that open that file automatically.
We can always refine as needed in the future?
Flaky tests detected in fc9ccad. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12656234083
|
Co-authored-by: Aki Hamano <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script doesn't work on Windows host OS because it somehow throws a type error (However, it works fine on WSL2). The script itself should be correct, so it may be a problem with my environment 🤔
In any case, this script is just for analysis, so I think it's okay to ship it for the benefit of many contributors. If necessary, it can be improved in follow-ups.
Nit: The ts-traces
directory does not contain any JS files, but do we need to add ts-traces
here?
gutenberg/react-scanner.config.js
Lines 7 to 24 in 54f59fe
globs: [ '**/!(test|stories)/!(*native).@(js|ts)?(x)' ], | |
// Exclude any vendor or docs directories | |
exclude: [ | |
'bin', | |
'build', | |
'build-module', | |
'docs', | |
'node_modules', | |
'patches', | |
'platform-docs', | |
'results', | |
'schemas', | |
'storybook', | |
'test', | |
'tools', | |
'typings', | |
'vendor', | |
], |
What?
After debugging a few instances where TypeScript build times would suddenly inflate and require more memory (example), @tyxla and I decided to add a dedicate npm script to speed up the debugging process
How?
Tweaking the existing command to add trace generation, and using the
@typescript/analyze-trace
package (without installing it) to generate a human-readable report in thets-trace/
folder (git-ignored)Testing Instructions
npm run build:profile-types
ts-traces/
ts-traces/analysis.txt