From 3cb93e95e5f1f8875362f9e7c4246884d0fe7ad7 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Thu, 9 Jan 2025 16:37:53 +0100 Subject: [PATCH] Add npm script to profile TypeScript builds (#68533) Co-authored-by: ciampo Co-authored-by: tyxla Co-authored-by: t-hamano --- .gitignore | 1 + package.json | 1 + react-scanner.config.js | 1 + 3 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 1d75f9f429d869..9e7e4333af8689 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ results /test/e2e/artifacts /perf-envs /composer.lock +/ts-traces # The /.cache folder is needed for phpcs to cache results between runs, while other .cache folders must be ignored # It is not possible to re-include a file if a parent directory of that file is excluded diff --git a/package.json b/package.json index ba2ef003b0dd1d..1d54299515ff64 100644 --- a/package.json +++ b/package.json @@ -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": "rimraf ./ts-traces && npm run clean:package-types && node ./bin/packages/validate-typescript-version.js && ( tsc --build --extendedDiagnostics --generateTrace ./ts-traces || ( echo 'tsc failed.'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js && npx --yes @typescript/analyze-trace ts-traces > ts-traces/analysis.txt && echo $'\n\nDone! Build traces saved to ts-traces/ directory.\nTrace analysis saved to ts-traces/analysis.txt.'", "prebuild:packages": "npm run clean:packages && npm run --if-present --workspaces build", "build:packages": "npm run --silent build:package-types && node ./bin/packages/build.js", "postbuild:packages": " npm run --if-present --workspaces build:wp", diff --git a/react-scanner.config.js b/react-scanner.config.js index 7501e7e8fc3ab0..853bbde69327c6 100644 --- a/react-scanner.config.js +++ b/react-scanner.config.js @@ -19,6 +19,7 @@ module.exports = { 'storybook', 'test', 'tools', + 'ts-traces', 'typings', 'vendor', ],