Skip to content
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

ESBuild #2298

Merged
merged 8 commits into from Jun 26, 2023
Merged

ESBuild #2298

merged 8 commits into from Jun 26, 2023

Conversation

codyebberson
Copy link
Member

@codyebberson codyebberson commented Jun 24, 2023

Replaces Rollup and Webpack with ESBuild and Vite.

Deployed to staging: https://app.staging.medplum.com/

Context

What is ESBuild?

esbuild is a CLI, NPM package, and Go module that makes bundling JavaScript accessible and fast.

This PR uses ESbuild for building libraries (@medplum/core, @medplum/react, etc).

What is Vite?

Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects.

This PR uses Vite for building apps (@medplum/app, @medplum/graphiql)

Note that we already use Vite in most of our example applications (medplum-hello-world, foomedical).

Why make this change?

There are many reasons to adopt ESBuild and Vite. The main two:

  1. Performance - these tools are much faster than predecessors because (1) they're written with faster tools such as Go and (2) they don't have as much legacy baggage such as support for outdated versions of JS.
  2. Modern alignment - these tools are more aligned with the future of JS/TS, such as better support for ESM.

We have actually tried to make this change many times in the past. However, it has always got stuck for some reason or another (bugs, incompatibilities, dependency conflicts, etc). This time it looks like it's going to work.

Who uses these tools?

Notably, the TypeScript team themselves started using ESBuild for building TypeScript: microsoft/TypeScript#51387

Vite is used by many organizations such as [...]

Benchmarks

Build time

Method:

  • Run "time npm run build"
  • Take the best of 3
  • Calculate speedup as Told / Tnew
image

2x app speedup to 8x react speedup!

Package size

Method:

  • Build
  • Create tar of files shipped to browser
image

Package size is slightly larger (1-2%)

Dev server start time

This is difficult to measure objectively.

Using app:

Webpack reports start time of 15.513 seconds:

image

Vite reports start time of 0.562 seconds:

image

Foo Medical

Before:

image

Main index.js is 188.21 kB gzipped

After:

image

Main index.js is 208.70 kB gzipped

So 11% bigger. Not great. That might warrant some investigation.

@codyebberson codyebberson requested a review from a team as a code owner June 24, 2023 22:35
@vercel
Copy link

vercel bot commented Jun 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
medplum-storybook ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2023 1:29am
medplum-www ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2023 1:29am

@coveralls
Copy link

coveralls commented Jun 25, 2023

Coverage Status

coverage: 94.115% (+0.01%) from 94.105% when pulling aba5973 on cody-esbuild2 into 09379ac on main.

@sonarcloud
Copy link

sonarcloud bot commented Jun 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

85.7% 85.7% Coverage
0.0% 0.0% Duplication

@codyebberson codyebberson marked this pull request as ready for review June 25, 2023 03:56
@reshmakh reshmakh added the self-host Features and fixes related to self hosting label Jun 25, 2023
@reshmakh reshmakh added this to the June 30, 2023 milestone Jun 25, 2023
@reshmakh
Copy link
Member

Glad to see the window opening for this change! I recall it getting stuck 6 months ago and am surprised/pleased that the window opened up now.

@codyebberson codyebberson merged commit 9b7bf74 into main Jun 26, 2023
11 checks passed
@codyebberson codyebberson deleted the cody-esbuild2 branch June 26, 2023 18:05
codyebberson added a commit that referenced this pull request Jun 30, 2023
Update client-cloudwatch-logs manual mock to use aws-sdk-client-mock (#2342)
Log resource for validator latency warning (#2338)
Minor tweaks to aws init tool and docs (#2340)
Allow contentReference elements to override cardinality rules (#2339)
Fixes #2315 - allow bot success without return value (#2336)
Fix app env vars in publish job (#2335)
Fixes #2310 - CLI rest with --fhir-url-path (#2313)
Unify all of the sleep helper functions (#2331)
Increase Fargate health check grace period (#2330)
Remove PWA and service worker (#2329)
Updating subscription documentation to reflect behavior when resources are deleted (#2328)
Add app to publish.sh (#2326)
Fixes #2306 - remove console.log from export tests due to race conditions (#2322)
Fixed landing page for storybook (#2323)
Bring back sourcemaps (#2309)
Split custom Medplum search parameter definitions into separate file (#2178)
Poll status follow Location header (#2307)
Copy .env.defaults to .env if not exists (#2308)
Allow extra URL path content with Bot execute (#2305)
Fixes #2182- All Patient Export (#2293)
Strict validation of property cardinality (#2300)
Request from ACN (#2299)
Fixed CLI shebang (#2301)
ESBuild (#2298)
Add logs and parity tests for new validator (#2291)
Fixes #2277 - Updated access policies docs (#2292)
Add non-null requirements to values in GraphQL array types (#2290)
Validating Fixed and Pattern Values (#2288)
Fixes #2195 - updated cdk init docs (#2289)
codyebberson added a commit that referenced this pull request Jul 1, 2023
Update client-cloudwatch-logs manual mock to use aws-sdk-client-mock (#2342)
Log resource for validator latency warning (#2338)
Minor tweaks to aws init tool and docs (#2340)
Allow contentReference elements to override cardinality rules (#2339)
Fixes #2315 - allow bot success without return value (#2336)
Fix app env vars in publish job (#2335)
Fixes #2310 - CLI rest with --fhir-url-path (#2313)
Unify all of the sleep helper functions (#2331)
Increase Fargate health check grace period (#2330)
Remove PWA and service worker (#2329)
Updating subscription documentation to reflect behavior when resources are deleted (#2328)
Add app to publish.sh (#2326)
Fixes #2306 - remove console.log from export tests due to race conditions (#2322)
Fixed landing page for storybook (#2323)
Bring back sourcemaps (#2309)
Split custom Medplum search parameter definitions into separate file (#2178)
Poll status follow Location header (#2307)
Copy .env.defaults to .env if not exists (#2308)
Allow extra URL path content with Bot execute (#2305)
Fixes #2182- All Patient Export (#2293)
Strict validation of property cardinality (#2300)
Request from ACN (#2299)
Fixed CLI shebang (#2301)
ESBuild (#2298)
Add logs and parity tests for new validator (#2291)
Fixes #2277 - Updated access policies docs (#2292)
Add non-null requirements to values in GraphQL array types (#2290)
Validating Fixed and Pattern Values (#2288)
Fixes #2195 - updated cdk init docs (#2289)
@codyebberson codyebberson mentioned this pull request Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
self-host Features and fixes related to self hosting
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants