Skip to content

LFX'25:Update the pipeline to achieve clean build without any errors #16574

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Ajay-singh1
Copy link
Contributor

@Ajay-singh1 Ajay-singh1 commented Jun 12, 2025

Description

This PR replaces Babel with esbuild as the build tool for this repository. The main goals of this is to improve build performance, reduce configuration complexity, modernize the toolchain, and generate cleaner builds.

Overview

Babel has served as a popular JavaScript transpiler for years, but it comes with some downsides in the context of modern library development:

  • Performance bottlenecks: Babel is significantly slower, especially on large codebases or repeated builds
  • Maintenance concerns: Many Babel plugins and presets are either deprecated, minimally maintained, or lag behind the evolving JavaScript standard.
  • Unnecessary complexity: Babel's plugin-based architecture leads to verbose and often brittle configurations

esbuild, on the other hand, is designed for speed and simplicity, with modern JavaScript/TypeScript support and built-in minification and bundling.

Technical Changes

Removed

  • Babel related dependencies
    • @babel/core
    • @babel/preset-env
    • Anyother babel related dependency

Added

  • esbuildas a dev dependency
  • A new build script using esbuild, capable of:
    • Transpiling modern JavaScript (ES6+) to target environments
    • Minimification of Javascript files to achieve faster builds

Testing

  1. The output structure and exports matches with previous Babel generated output
  2. The site is build successfully without having any errors or warnings

Result

  1. Simplified build setup with fewer and less boilerplate dependencies
  2. More future-proof and modern toolchain

Reviewers

  • Ambient
  • Docs
  • Installation
  • Networking
  • Performance and Scalability
  • Extensions and Telemetry
  • Security
  • Test and Release
  • User Experience
  • Developer Infrastructure
  • Localization/Translation

@Ajay-singh1 Ajay-singh1 requested a review from a team as a code owner June 12, 2025 05:22
@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 12, 2025
@craigbox
Copy link
Contributor

Great initiative.
The new modules would need to be in the build container before the lint will pass.
I don't have enough context to say yes or no without doing a bunch more work.

Can you comment on (or show a diff of) the before/after of the generated JS?

You're asking for approval to merge something that transpiles/touches the site JavaScript; there's no point in showing a video which scrolls a bunch of random pages, we would need to see the before/after for things that are executed by these scripts.

(p.s. generating the site takes ~20 seconds on my laptop. Do I read right that yours takes 440 seconds - 20 times longer? We need to do something about that!)

@AritraDey-Dev
Copy link
Member

I found that this PR is causing the headerAnimation script and the expandable list functionality to break. If you check the js folder, the headerAnimation.js file is likely missing from the build. Additionally, a few other files might also be missing from the js directory.
If you compare the builds generated using Babel and esbuild, you'll notice that the file structures differ significantly.

@Ajay-singh1
Copy link
Contributor Author

@craigbox The work is not completed yet I'll ping you when it does. @AritraDey-Dev Yeah I agree with you that the file structure is different but I have resolved this I will push the changes in the meantime.
Thanks

@istio-testing istio-testing added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 16, 2025
@Ajay-singh1
Copy link
Contributor Author

@craigbox This PR is up for review , after this PR is merged istio/tools PR .Hopefully the lint will pass here.

@craigbox
Copy link
Contributor

istio/tools#3222 LGTM but I'm not in the reviewer set. Daniel is, so I think that will go through today his time.

@Ajay-singh1
Copy link
Contributor Author

@dhawton Can you kindly also review this PR and share your comments?It would be really helpful.

@craigbox craigbox mentioned this pull request Jun 18, 2025
11 tasks
Co-authored-by: Craig Box <[email protected]>
Co-authored-by: Daniel Hawton <[email protected]>
@Ajay-singh1
Copy link
Contributor Author

Thanks @dhawton and @craigbox for the detailed review I have done the necessary changes. @keithmattix Can you kindly also review this PR? just to ensure everything looks good.

@Ajay-singh1 Ajay-singh1 requested a review from keithmattix June 19, 2025 22:54
Copy link
Member

@AritraDey-Dev AritraDey-Dev left a comment

Choose a reason for hiding this comment

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

While running make serve, if I don't delete the tmp/js folder and try to run make serve again, I encounter the following error:

src/ts/callToAction.ts:14:7 - error TS2451: Cannot redeclare block-scoped variable 'callToActionDelayMs'.

14 const callToActionDelayMs = 250;
         ~~~~~~~~~~~~~~~~~~~

  tmp/js/callToAction.js:15:7
    15 const callToActionDelayMs = 250;
             ~~~~~~~~~~~~~~~~~~~
    'callToActionDelayMs' was also declared here.

src/ts/callToAction.ts:16:10 - error TS2393: Duplicate function implementation.

16 function handleCallToAction(): void {
            ~~~~~~~~~~~~~~~~~~

src/ts/kbdnav.ts:15:7 - error TS2300: Duplicate identifier 'KbdNav'.

15 class KbdNav {
         ~~~~~~

  tmp/js/kbdnav.js:15:7
    15 class KbdNav {
             ~~~~~~
    'KbdNav' was also declared here.


Found 3 errors in 2 files.

Errors  Files
     2  src/ts/callToAction.ts:14
     1  src/ts/kbdnav.ts:15
make[1]: *** [Makefile.core.mk:83: site] Error 2
make: *** [Makefile:44: serve] Error 2

this was not the case before

Although this is dev-specific and won't occur in prod

@Ajay-singh1
Copy link
Contributor Author

Nice catch! The error happened because of leftover compiled files from the previous build you won't get this error before because how babel handles files is different then how esbuild handles them.

BTW this is a quick fix.

@AritraDey-Dev
Copy link
Member

AritraDey-Dev commented Jun 22, 2025

I just gave an example that running make serve is throwing errors. If you noticed, it's also throwing errors for other make targets.
Adding the clean target to every make command is not a good solution just to resolve the errors.If you add clean to every make target, it unnecessarily takes time to clean before performing the actual task.

Also, after you build it, you’ll see a bunch of red squiggly lines — this shouldn’t happen.
I'm also not sure why you added so many import and export statements. Previously, when we were using a Babel-based build, the functions or variables that needed to be compiled globally were already there.

@craigbox
Copy link
Contributor

I think it's reasonable for a build to clean up any temporary files after using them?

However the entrypoint.js file should not contain reference to tmp files that aren't normally there:

import "../../tmp/js/constants.js";
import "../../tmp/js/utils.js";
import "../../tmp/js/feedback.js";

@Ajay-singh1
Copy link
Contributor Author

Ajay-singh1 commented Jun 23, 2025

@AritraDey-Dev esbuild isn't a transpiler like babel it also does bundling of files so this has to happen anyways.Regarding the export and imports I already told Craig that the repo is using global legacy code and converting them to ES6 modules is a good idea.Legacy code was used before ES6 and it was a standard then.

It is obvious to clean temporary files before each build so that isn't a major issue here.

For ex:- Try to compile a .ts file with estarget set to es6 you will get errors.

@craigbox
Copy link
Contributor

In this case the entrypoint file should be generated by the build process IMO.

It's just a listing of all the files to compile. Better we don't use one at all?

@Ajay-singh1
Copy link
Contributor Author

Yes you are correct these are for compilation but having an entrypoint.js file seems like a good idea as Daniel mentioned it would be convenient for future maintainers and contributors to look into this file and get the idea of how things are working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants