Skip to content

Conversation

animesh1987
Copy link
Contributor

What?

Optimise build times for sdk.

Why?

SDK compilation is very slow, almost taking 3-4 mins for build, 1 min for bundle watch. Switch to esbuild-loader to get faster build times.

Have also added an analysis doc and what the next potential changes should be.

Testing / Proof

  • CI
  • Screenshots

Before

npm run build
Screenshot 2025-07-14 at 4 04 01 pm
npm run bundle:watch
Screenshot 2025-07-14 at 4 05 35 pm

After

npm run build
Screenshot 2025-07-14 at 3 50 43 pm
npm run bundle:watch
Screenshot 2025-07-14 at 3 51 26 pm

@bigcommerce/team-checkout @bigcommerce/team-payments

@animesh1987 animesh1987 requested a review from a team as a code owner July 14, 2025 06:05
@bcsnyk
Copy link
Contributor

bcsnyk commented Jul 14, 2025

🎉 Snyk checks have passed. No issues have been found so far.

code/snyk check is complete. No issues have been found. (View Details)

@@ -0,0 +1,197 @@
# Webpack Build Speed Analysis Results
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this file? I'd say it makes more sense for this to be a blog post rather than a markdown file in the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a working doc for now, since there are follow up items that I want to leverage from this doc. I wanted to break the work before round 2 of improvements as we have achieved a decent state.

"scripts": {
"prepare": "check-node-version --node '>=22' --npm '>=10'",
"build": "npm run bundle && npm run bundle-dts",
"build": "npx nx reset && npm run bundle && npm run bundle-dts",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should reset the cache on every build, otherwise it defeats the purpose of having cache in the first place. We only need to reset cache when we are iterating and testing changes to the build script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were issues with the optimisations and nx cache hence I had to reset cache here.

loader: 'ts-loader',
loader: 'esbuild-loader',
options: {
target: 'es2018', // Modern target without IE 11
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's align the version with checkout-js first as our first step, which is es2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants