bazel-contrib / vscode-bazel

Bazel support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel
Apache License 2.0
244 stars 79 forks source link

chore: Bundle the extension using esbuild #421

Open cwahbong opened 3 weeks ago

cwahbong commented 3 weeks ago

This should not affect the existing build and test flow, but adding an additional step right before building vsix package.

The esbuild.js is copied from VSCode extension generator template then format fixed by prettier.

This reduces the package size from ~5MB -> ~250KB.

cwahbong commented 3 weeks ago

Thanks for this PR! Properly bundling and minifying the extensions has been on my TODO list for a long time already.

I know that there were discussions on "should we build this extension via Bazel", but afaik they stalled. As such, I would be happy to move on with this PR. We can later still switch to Bazel, in case somebody is willing to put in the effort for this switch

I did a quick try (still not working) for using Bazel build for building this extension. It is more complicated even for only making a pbts command works in the build system. At first I thought it was at most just a bunch of genrules but it turns out it would be making npm repositories and I don't think I can finish them in a short time. (comparing to this pull request the first version is just done in under 10 minutes...)

Just saw #340 working on Bazel build, would move the discussion there.

cwahbong commented 2 weeks ago

Icon paths need to be fixed.

cwahbong commented 2 weeks ago

I just made the corresponding changes in launch.json to support the debugging. I only validate that local breakpoint could be set in either "Launch Extension" and "Launch Extension Tests".

However I don't think I'm really understand how / why Debug Server works. It seems to be a debugging service for bazel build file instead of the plugin or typescript/javascript stuffs. I just made them into another binary, updating the referencedin package.json as well.

cwahbong commented 2 weeks ago

Still looking into the "watch" flow. I also have no idea for how to test these flow automatically to prevent regression. For now I assume all developers are daily using it and would be triggered once broken again.