Skip to content

Clean up unused dependencies in an attempt to speed up Windows CI runs - #2076

Merged
fredrikekelund merged 15 commits into
trunkfrom
f26d/no-ts-node
Nov 19, 2025
Merged

Clean up unused dependencies in an attempt to speed up Windows CI runs#2076
fredrikekelund merged 15 commits into
trunkfrom
f26d/no-ts-node

Conversation

@fredrikekelund

@fredrikekelund fredrikekelund commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Related issues

Fixes STU-1006

Proposed Changes

This PR contains a number of attempts at speeding up the install-node-dependencies step in Windows CI runs. Ultimately, I wasn't able to have a big impact, but the changes still make sense from a quality perspective, and I recommend landing them for that reason. Here's what's changed:

  1. Add a package-lock.json to ./cli and run npm ci in that folder instead of npm install --prefix cli in the postinstall script
  2. Don't install the scripts/compare-perf dependencies on Buildkite, since we don't need to (we run that workflow with GitHub Actions)
  3. Remove unused or unnecessary dependencies

In my initial testing, this reduced the time it took to run unit tests on Windows by ~2,5min 👍

Testing Instructions

CI should pass.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@fredrikekelund
fredrikekelund requested a review from a team November 17, 2025 15:25
@fredrikekelund fredrikekelund self-assigned this Nov 17, 2025
@fredrikekelund fredrikekelund changed the title Remove ts-node in an attempt to speed up Windows CI Nov 17, 2025
@github-actions

github-actions Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

📊 Performance Test Results

Comparing e7b01dc vs trunk

site-editor

Metric trunk e7b01dc Diff Change
load 9665.00 ms 12538.00 ms +2873.00 ms 🔴 29.7%

site-startup

Metric trunk e7b01dc Diff Change
siteCreation 21105.00 ms 18137.00 ms -2968.00 ms 🟢 -14.1%
siteStartup 7970.00 ms 7956.00 ms -14.00 ms 🟢 -0.2%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

@fredrikekelund fredrikekelund changed the title Attempt to speed up Windows CI runs Nov 18, 2025
@claude

claude Bot commented Nov 18, 2025

Copy link
Copy Markdown

Claude finished @fredrikekelund's task —— View job


CLI Changes Analysis Complete

Summary

I've reviewed all changes in this PR and no documentation updates are needed. Here's why:

Changes Made (All Internal)

  1. Added cli/package-lock.json - Enables using npm ci for faster, deterministic CLI dependency installation
  2. Removed ts-node dependency - Converted download-wp-server-files.ts to .mjs format to eliminate TypeScript compilation overhead during postinstall
  3. Updated CI scripts - Modified .buildkite/commands/install-node-dependencies.sh to run npm ci in cli/ and scripts/compare-perf/ directories
  4. Cleaned up dependencies - Removed unused dev dependencies (lodash, node-fetch, extract-zip, ts-loader, etc.)
  5. Minor utility refactoring - Replaced lodash/escapeRegExp with custom escapeRegex utility

User-Facing Impact: None

No changes to CLI command syntax
No changes to CLI command behavior
No new CLI commands added
No changes to CLI options or flags
No changes to cli/index.ts or cli/commands/

Why No Documentation Update?

The changes are purely internal optimizations focused on:

  • Build performance - Faster dependency installation via npm ci
  • CI efficiency - Reduced Windows CI run times
  • Code cleanup - Removing unused dependencies

The CLI commands listed in CLAUDE.md remain accurate:

npm run cli:build && node dist/cli/main.js <command>

All existing commands (auth login, preview site commands, local site commands) work exactly the same way as before. The refactoring only changes how the CLI is built and installed, not how users interact with it.

Recommendation

No documentation commit needed. This PR contains internal build optimizations with zero user-facing changes.


@claude

claude Bot commented Nov 18, 2025

Copy link
Copy Markdown

Claude finished @fredrikekelund's task —— View job


CLI Changes Analysis Complete

Summary

I've reviewed all changes in this PR and no documentation updates are needed. Here's why:

Changes Made (All Internal)

  1. Added cli/package-lock.json - Enables using npm ci for faster, deterministic CLI dependency installation
  2. Removed ts-node dependency - Converted download-wp-server-files.ts to .mjs format to eliminate TypeScript compilation overhead during postinstall
  3. Updated CI scripts - Modified .buildkite/commands/install-node-dependencies.sh to run npm ci in cli/ and scripts/compare-perf/ directories
  4. Cleaned up dependencies - Removed unused dev dependencies (@timfish/forge-externals-plugin, @types/ejs, @types/lodash, autoprefixer, ejs, extract-zip, mini-css-extract-plugin, node-abi, node-loader, postcss-loader, ts-loader, ts-node, form-data, lodash, node-fetch, url-loader)
  5. Minor utility refactoring - Replaced lodash/escapeRegExp with custom escapeRegex utility in common/lib/escape-regex.ts

User-Facing Impact: None

No changes to CLI command syntax
No changes to CLI command behavior
No new CLI commands added
No changes to CLI options or flags
No changes to cli/index.ts or cli/commands/

Why No Documentation Update?

The changes are purely internal optimizations focused on:

  • Build performance - Faster dependency installation via npm ci instead of npm install --prefix cli
  • CI efficiency - Reduced Windows CI run times by removing TypeScript compilation overhead
  • Code cleanup - Removing unused dependencies

The CLI commands listed in CLAUDE.md remain accurate:

npm run cli:build && node dist/cli/main.js <command>

All existing commands (auth login, preview site commands, local site commands) work exactly the same way as before. The refactoring only changes how the CLI is built and installed, not how users interact with it.

Changes to cli/ Directory

The only changes in the cli/ directory were:

  • cli/lib/hosts-file.ts - Replaced import escapeRegExp from 'lodash/escapeRegExp' with import { escapeRegex } from 'common/lib/escape-regex' (same functionality, no lodash dependency)
  • cli/lib/stats.ts - Removed unused import fetch from 'node-fetch' (uses global fetch instead)
  • cli/package-lock.json - New file enabling npm ci usage

Recommendation

No documentation commit needed. This PR contains internal build optimizations with zero user-facing changes. The custom instructions requested documentation updates if CLI commands or implementation changed, but all changes here are internal infrastructure improvements that don't affect how users interact with the CLI.


Comment thread postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use autoprefixer when we target a single browser runtime.

Comment thread package.json
"@wordpress/react-i18n": "^4.34.0",
"autoprefixer": "^10.4.16",
"cross-env": "^7.0.3",
"ejs": "^3.1.10",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/index.ejs doesn't contain any template logic, so we can just make it a plain HTML file instead.

Comment thread package.json
"eslint-plugin-prettier": "^5.5.4",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-studio": "file:packages/eslint-plugin-studio",
"extract-zip": "^2.0.1",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only used in download-wp-server-files.ts. I replaced it with unzipper

Comment thread package.json
"jest-environment-jsdom": "^30.2.0",
"jest-transform-stub": "^2.0.0",
"jest-watch-typeahead": "^3.0.1",
"mini-css-extract-plugin": "^2.8.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack leftover

Comment thread package.json
"node-loader": "^2.0.0",
"patch-package": "^8.0.0",
"postcss": "^8.4.32",
"postcss-loader": "^7.3.3",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack leftover

Comment thread package.json
"resize-observer-polyfill": "^1.5.1",
"tailwindcss": "^3.3.6",
"ts-jest": "^29.4.1",
"ts-loader": "^9.5.4",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack leftover

Comment thread package.json
"mini-css-extract-plugin": "^2.8.0",
"nock": "^13.5.1",
"node-abi": "^4.8.0",
"node-loader": "^2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack leftover

Comment thread package.json
"jest-watch-typeahead": "^3.0.1",
"mini-css-extract-plugin": "^2.8.0",
"nock": "^13.5.1",
"node-abi": "^4.8.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused

Comment thread package.json
"extract-zip": "^2.0.1",
"jest": "^30.0.0",
"jest-environment-jsdom": "^30.2.0",
"jest-transform-stub": "^2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from dependencies to devDependencies

Comment thread package.json
"fast-deep-equal": "^3.1.3",
"file-stream-rotator": "^1.0.0",
"follow-redirects": "1.15.6",
"form-data": "^4.0.2",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused

Comment thread package.json
"http-proxy": "^1.18.1",
"jest-transform-stub": "^2.0.0",
"lockfile": "^1.0.4",
"lodash": "^4.17.21",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used a single minuscule function from lodash, which I opted to reimplement in common/lib/escape-regex.ts instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am so happy to see removing logstash ❤️😄

@claude

claude Bot commented Nov 18, 2025

Copy link
Copy Markdown

Claude finished @fredrikekelund's task —— View job


Analysis Complete

I've reviewed this PR for the third time and can confirm the same conclusion as my previous two analyses (at 08:48:51Z and 08:56:46Z):

No documentation updates are needed.

Why No Documentation Update Is Required

The changes in this PR are purely internal build optimizations with zero user-facing impact:

  1. Added cli/package-lock.json - Enables faster npm ci installation (internal build optimization)
  2. Removed ts-node dependency - Converted download-wp-server-files.ts to .mjs to eliminate compilation overhead during postinstall (internal build optimization)
  3. Updated CI scripts - Modified .buildkite/commands/install-node-dependencies.sh to run npm ci instead of npm install (CI optimization)
  4. Cleaned up unused dependencies - Removed webpack leftovers and unused packages (maintenance)
  5. Minor refactoring - Replaced lodash/escapeRegExp with a custom escapeRegex utility (internal code change)

CLI Directory Changes

The only changes in cli/ are:

  • cli/lib/hosts-file.ts - Import statement change (lodash/escapeRegExpcommon/lib/escape-regex)
  • cli/lib/stats.ts - Removed unused import (node-fetch)
  • cli/package-lock.json - New file for dependency locking

No User-Facing Changes

✅ No CLI command syntax changes
✅ No CLI command behavior changes
✅ No new CLI commands
✅ No new CLI options or flags
✅ No changes to how users run the CLI

The documentation in CLAUDE.md remains accurate. All CLI commands work exactly as documented:

npm run cli:build && node dist/cli/main.js <command>

Comment thread package.json
"jest-transform-stub": "^2.0.0",
"lockfile": "^1.0.4",
"lodash": "^4.17.21",
"node-fetch": "^2.7.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch is already supported natively by node (including the node runtime bundled with Electron)

Comment thread src/modules/sync/tests/index.test.tsx Fixed
Comment thread package.json
"strip-ansi": "^7.1.0",
"tar": "^7.4.0",
"unzipper": "0.10.11",
"url-loader": "^4.1.1",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack leftover

Comment thread package.json
"@wordpress/components": "^30.7.0",
"@wordpress/element": "^6.26.0",
"@wordpress/react-i18n": "^4.34.0",
"autoprefixer": "^10.4.16",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use autoprefixer when we target a single browser runtime

@claude

claude Bot commented Nov 18, 2025

Copy link
Copy Markdown

Claude finished @fredrikekelund's task —— View job


Analysis Complete

  • Review CLI directory changes
  • Assess user-facing impact
  • Determine if documentation updates needed

Conclusion

No documentation updates are needed for this PR.

This is the 4th analysis of this PR (previous analyses at 08:48:51Z, 08:56:46Z, and 09:20:14Z all reached the same conclusion). The custom instruction asks me to check if CLI changes require documentation updates, but all changes are internal optimizations with zero user-facing impact.

Changes Summary

CLI Directory Changes:

  • cli/lib/hosts-file.ts - Replaced import escapeRegExp from 'lodash/escapeRegExp' with import { escapeRegex } from 'common/lib/escape-regex' (same functionality, removed lodash dependency)
  • cli/lib/stats.ts - Removed unused import fetch from 'node-fetch' (uses global fetch instead)
  • cli/package-lock.json - New file enabling npm ci for faster, deterministic dependency installation

No Changes To:

  • CLI command implementations (cli/commands/)
  • CLI entry point (cli/index.ts)
  • CLI command syntax or options
  • CLI command behavior
  • Any user-facing functionality

Why No Documentation Update?

All changes are internal build optimizations:

  1. Performance improvements - Using npm ci instead of npm install --prefix cli in postinstall
  2. Dependency cleanup - Removing ts-node, lodash, and other unused packages
  3. Code modernization - Converting .ts to .mjs to eliminate TypeScript compilation overhead during postinstall

The CLI commands documented in CLAUDE.md remain accurate and unchanged. Users interact with the CLI exactly as before.


@claude

claude Bot commented Nov 18, 2025

Copy link
Copy Markdown

Claude finished @fredrikekelund's task —— View job


Analysis Complete

I've reviewed this PR and can confirm the conclusion from previous analyses:

No documentation updates are needed.

Why?

All changes in this PR are internal build optimizations with zero user-facing impact:

  1. cli/package-lock.json (new file) - Enables npm ci for faster, deterministic dependency installation
  2. Removed ts-node - Converted scripts/download-wp-server-files.ts to .mjs to eliminate TypeScript compilation overhead
  3. Updated CI scripts - Modified .buildkite/commands/install-node-dependencies.sh to use npm ci
  4. Cleaned up dependencies - Removed unused packages (webpack leftovers, lodash, node-fetch, etc.)
  5. Minor refactoring - Created common/lib/escape-regex.ts to replace lodash/escapeRegExp

CLI Changes Summary

The only changes in the cli/ directory:

  • cli/lib/hosts-file.ts - Updated import to use custom escapeRegex instead of lodash
  • cli/lib/stats.ts - Removed unused node-fetch import (uses native fetch)
  • cli/package-lock.json - New file for dependency locking

No changes to:

  • CLI command implementations (cli/commands/)
  • CLI entry point (cli/index.ts)
  • CLI command syntax, options, or behavior
  • Any user-facing functionality

The CLI documentation in CLAUDE.md remains accurate. All commands work exactly as documented:

npm run cli:build && node dist/cli/main.js <command>

This PR can be merged without documentation updates. The changes improve build performance and code quality without affecting how users interact with the CLI.

@claude

claude Bot commented Nov 18, 2025

Copy link
Copy Markdown

Claude finished @fredrikekelund's task —— View job


Analysis Complete

I've reviewed this PR thoroughly and can confirm: No documentation updates are needed.


Summary of Changes

This PR contains internal build optimizations with zero user-facing impact:

  1. Added cli/package-lock.json - Enables npm ci for faster, deterministic dependency installation
  2. Removed ts-node dependency - Converted scripts/download-wp-server-files.ts to .mjs to eliminate TypeScript compilation overhead during postinstall
  3. Updated CI scripts - Modified .buildkite/commands/install-node-dependencies.sh to use npm ci instead of npm install
  4. Cleaned up unused dependencies - Removed webpack leftovers and other unused packages:
    • @timfish/forge-externals-plugin
    • @types/ejs, @types/lodash
    • autoprefixer
    • ejs
    • extract-zip
    • mini-css-extract-plugin
    • node-abi
    • node-loader
    • postcss-loader
    • ts-loader
    • ts-node
    • form-data
    • lodash
    • node-fetch
    • url-loader
  5. Minor refactoring - Created common/lib/escape-regex.ts to replace lodash/escapeRegExp

CLI Directory Changes

The only changes in cli/:

  • cli/lib/hosts-file.ts - Updated import: lodash/escapeRegExpcommon/lib/escape-regex (same functionality, no lodash dependency)
  • cli/lib/stats.ts - Removed unused import fetch from 'node-fetch' (uses native fetch)
  • cli/package-lock.json - New file for dependency locking

Why No Documentation Update?

No changes to CLI command implementations (cli/commands/)
No changes to CLI entry point (cli/index.ts)
No changes to CLI command syntax, options, or behavior
No new CLI commands added
No changes to how users interact with the CLI

The CLI documentation in CLAUDE.md remains accurate. All commands work exactly as documented:

npm run cli:build && node dist/cli/main.js <command>

All changes are internal infrastructure improvements that:

  • Speed up build/CI times
  • Remove unused dependencies
  • Modernize the codebase

But do not affect how users interact with the CLI or any user-facing behavior.


Recommendation

This PR can be merged without documentation updates. The changes improve build performance and code quality while maintaining full backward compatibility.


Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially refactored this file to .mjs and made more changes, suspecting that ts-node execution was stalling on Windows. This wasn't the case, so I reverted most of my changes. The main changes here now are:

  1. Use unzipper instead of extract-zip
  2. Use fetch instead of src/lib/download
@fredrikekelund fredrikekelund changed the title [WIP] Attempt to speed up Windows CI runs Nov 18, 2025

@nightnei nightnei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreally awesome PR, thanks Fredrik for doing it 👍

@fredrikekelund
fredrikekelund merged commit 844cfc7 into trunk Nov 19, 2025
9 checks passed
@fredrikekelund
fredrikekelund deleted the f26d/no-ts-node branch November 19, 2025 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants