Using ESBuild as development server #4330
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Changes
Description
Using ESBuild as development server, while keeping Webpack@5 for our production build.
This greatly improve DX. Build time is down from 5-7 seconds to 500 ms.
Currently, we have 3 build favors:
Goals
npm start
at root must start the development server (same as current experience)docs/BUILD_SCRIPTS.md
Design
Dual build approach
We will run dual bundle approach: build and serve. This enables us to both serve the development build to our Docker container and development server.
/packages/bundle/dist/
for Docker containers orhttp://localhost:5000/
webchat-es5.js
as we did not use them for developmentCurrently, we have 2 development servers (port 5000 and 5001). We will keep the existing port 5000 serving files from
/packages/bundle/dist/
.Build on-the-fly with ESBuild serve
We will be hosting ESBuild server on port 8000 (default) and writing a new development server for port 5001:
/__dist__/
to ESBuildserve-test.json
)We observed the size of the bundle from ESBuild is 20-30% larger than Webpack. As we are not using ESBuild for production build, this is okay.
For simplicity, with
NODE_ENV=development
(or unset), runningnpm run build
will use Webpack, whilenpm start
will use ESBuild. As our builds should not deviate significantly, they should perform very similar.Specific Changes
packages/bundle/script/devServer.cjs
for the development serverI have added tests and executed them locallyCHANGELOG.md
Review Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)CSS styles reviewed (minimal rules, noz-index
)Internationalization reviewed (strings, unit formatting)package.json
andpackage-lock.json
reviewedSecurity reviewed (no data URIs, check for nonce leak)Tests reviewed (coverage, legitimacy)