-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
build(ui): improve performance with esbuild-loader
#12516
Conversation
70c68f6
to
879bdfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, this is so much faster.
Works as expected
Build failed |
@terrytangyuan you need to merge this one first: #12514 |
Head branch was pushed to by a user without write access
879bdfa
to
9d49b09
Compare
Fixed another merge conflict in the |
@isubasinghe are you comfortable being the Assignee for this one, so you may be able to merge it once you officially have access to? |
Merged I was trying to partly workaround a CSS side-effect import in #12158 for similar reasons to this, but otherwise this requires a few changes upstream in I guess I'll kick this back to draft as a result since it is pretty blocked on |
Okay, yes! |
Yup happy to merge when the tests pass |
I might be able to get this working again now that argoproj/argo-ui#509 and argoproj/argo-ui#552 have been merged |
- similar to [Argo CD](https://github.com/argoproj/argo-cd/blob/d9df2525c57d4870215a6ce149dbedd08ae05fdb/ui/src/app/webpack.config.js#L37) and many other projects, we can use `esbuild` instead of TS etc to significantly speed up build times - (as `esbuild` is written in Go and compiled instead of using interpreted TS/JS) - we don't use any Babel or TS plugins, so I think this codebase is a good candidate for that - it also simplifies the build process as well, removing & replacing many other deps - caveats: - `esbuild` does not do type-checking, so we have to run `tsc --noEmit` as part of the `lint` phase - `isolatedModules` config is needed to ensure compatibility with this - `esbuild` does not currently support React Fast Refresh - `react-hot-loader` was replaced by [React Fast Refresh](https://github.com/pmmmwh/react-refresh-webpack-plugin) and is deprecated / hasn't received an update in 2 years - remove `module.hot` etc usage of `react-hot-loader` as well - that being said, `esbuild` is significantly faster than using Babel or TS for builds, so hot reloading is nice but not necessary - also hot reloading can be buggy - further optimize dev builds by using cheaper `eval` sourcemaps as [recommended by Webpack for performance](https://webpack.js.org/configuration/devtool/) - prod builds should always have highest quality sourcemaps, so do not change those - remove unused `react-paginate` `exclude` - it's not a dep we currently use; it doesn't exist in the lockfile - (nor in `argo-ui`'s lockfile, of which all prod deps would be in Workflows's lockfile) some simple performance testing when running natively on macOS, taken directly from Webpack's reported stats: - before: - prod build: ~65s - dev build: ~22s - dev rebuild: ~1.8s - after: - prod build: ~50s (~25% faster) - dev build: ~16s (~25% faster) - dev rebuild: ~.8s (~50% faster) - these are not as good improvements as I would have liked, which mean there are bigger bottlenecks elsewhere - e.g. Webpack itself (analysis, source maps, running loaders), sass-loader, etc - switching to `esbuild` directly may further improve these stats - i.e. instead of Webpack + `esbuild-loader` Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
147fff6
to
f52df81
Compare
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Guh, this is now failing to typecheck due to another dep, this time very transitive: ramda/ramda#3415 (comment), swagger-api/swagger-js#3176, swagger-api/apidom#3279 |
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Ok had to fix that by pinning |
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Re-verified, seems to all be fine |
I'm gonna go ahead and merge this since I only made the changes necessary to fix CI since this was last approved. It also fixes a bunch of warnings and improves performance etc, so it's pretty darn nice to have sooner rather than later |
Follow-up to #11628
Motivation
esbuild
instead of TS etc to significantly speed up build timesesbuild
is written in Go and compiled instead of using interpreted TS/JS)esbuild
does not do type-checking, so we have to runtsc --noEmit
as part of thelint
phaseesbuild-loader
does not currently support React Fast Refresh (c.f. about hmr react-refresh/babel privatenumber/esbuild-loader#250, Using with esbuild-loader? pmmmwh/react-refresh-webpack-plugin#366)react-hot-loader
was replaced by React Fast Refresh and is deprecated / hasn't received an update in 2 yearsesbuild
is significantly faster than using Babel or TS for builds, so hot reloading is nice but not necessaryModifications
babel-loader
,ts-loader
,react-hot-loader
, andsource-map-loader
source-map-loader
is still present in theyarn.lock
as it is used under-the-hood by other depssource-map-loader
are no longer present in the buildautolinker
etc dep in the bundle, but potentially other reasons (I did not check in-depth)add
esbuild-loader
add
tsc --noEmit
to thelint
scriptadd
isolatedModules
config to ensure compatibility withesbuild
's compilersince it has no type-checking, it can't do full program analysis, meaning there are certain types it doesn't support
same as when using Babel to compile TS
fix some resulting type-check errors:
argo-ui
to useexport type
syntax: fix: Use type export for interface reexports argo-ui#552types-ramda
due to requiring newer TS: build(ui): improve performance withesbuild-loader
#12516 (comment)Intl
typings missing in older TS: a4511f6remove
mdl.hot
etc usage ofreact-hot-loader
Related config / performance changes
further optimize dev builds by using cheaper
eval
sourcemaps as recommended by Webpack for performanceremove unused
react-paginate
exclude
argo-ui
's lockfile, of which all prod deps would be in Workflows's lockfile as well)Verification
yarn build
works finemake start UI=true
works fine and UI seems to function as expectedPerformance Testing
some simple performance testing when running natively on macOS, taken directly from Webpack's reported stats:
Future Work
these are not as good improvements as I would have liked, which mean there are bigger bottlenecks elsewhere
sass-loader
, etcsass
has been slow in the past and is ripe to be replaced with more modern PostCSS as wellesbuild
directly may further improve these statsesbuild-loader
argo-ui
instead of as part of the Workflows (and CD) builds perargo-ui
: future state of this repo argo-ui#453moment
, consolidating similar deps, etc