I admire Evan W., the creator of esbuild, and I believe we'll eventually get the JS/TS instant builds one day. Same as in Deno-land. I wish I could help somehow. I hope I messed up my configs, and it's me not esbuild.
In this context...
Programs built by esbuild v0.11.5 appear to perform on average 27% slower than the same code built by Rollup. Some packages perform more than 90% slower though!
Here are the details of the benchmarks. I hope it's me, not esbuild.
- MacOS 11.2.3 Big Sur
- node 15.13
- npm 7.7.6
also, the particulars:
- esbuild config
- rollup config generator - also example of config per-package
- babel config
- benchmarks script
|CJS built using Rollup, ops/s.||CJS built using esbuild, ops/s.||difference|
Check, does a plain object (AST/JSON) has any unique keys, not present in a reference object (another AST/JSON)
Validate and normalise user choice: array, object or both?
Checks if index is within any of the given string index ranges
Extract values and paths from AST by keys OR set them by keys
Delete all plain objects in AST if they contain a certain key/value pair
Sort string index ranges
Lay one string on top of another, with an optional offset
Split string into array by chunks of whitespace
Convert between native JS string character indexes and grapheme-count-based indexes
Edit package.json without parsing, as string, to keep the formatting intact
Your next best friend when editing complex nested code
Recursively walk the input and set all found values in plain objects to something
Utility library to traverse AST
Does a given character belong to XML spec's "Production 4 OR 4a" type (is acceptable for XML element's name)
Utility library of AST helper functions
Replace strings with optional lookarounds, but without regexes
Expands string index ranges within whitespace boundaries until letters are met
Compare anything: AST, objects, arrays and strings
Merge and flatten any arrays found in all values within plain objects
Does the AST/nested-plain-object/array/whatever contain only one kind of value?
Increment or decrement each index in every range
Splits the CSV string into array of arrays, each representing a row of columns
Answers, is the string input string more an HTML or XHTML (or neither)
Is given character suitable to be in an HTML attribute's name?
Looks up the first non-whitespace character to the left/right of a given index
Replace all n/m dashes, curly quotes with their simpler equivalents
Generate BitBucket readme header anchor slug URLs. Unofficial, covers whole ASCII and a bit beyond
List of all named HTML entities
Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else
Convert shorthand hex color codes into full
Flatten complex nested objects according to a reference objects
Sorts double-entry bookkeeping CSV coming from internet banking
Consumes a defaults object with booleans, generates all possible variations of it
Regular expression for detecting JSP (Java Server Pages) code
Tells, is given character a part of astral character, specifically, a high and low surrogate
Is the input (plain object, array, string or whatever) not empty?
All HTML attributes known to the Humanity
All HTML entities which are not email template friendly
Delete keys from all arrays or plain objects, nested within anything, by key or by value or by both, and clean up afterwards. Accepts wildcards
Find out, is nested array/object/string/AST tree is empty
Regular expression for matching HTML empty conditional comments
Regular expression for detecting Python-specific Jinja code
Does an HTML tag start at given position?
Regular expression for detecting Jinja or Nunjucks code
Detects various templating languages present in string
Does AST contain only empty space?
Is given string a language code (as per IANA)
Compare anything: AST, objects, arrays, strings and nested thereof
Add missing keys into plain objects, according to a reference object
Traverse and edit AST
Getter/setter for nested parsed HTML AST's, querying objects by key/value pairs
Is given string a valid media descriptor (including media query)?
Test helper to generate function opts object variations
Is given string a relative URI?
The inner core of
Convert string index to line-column position
Removes frivolous entries from
Validate options object
Take an array of string index ranges, delete/replace the string according to them
Recursive HTML entity decoding for Ranges workflow
Recursively, deeply merge of anything (objects, arrays, strings or nested thereof), which weighs contents by type hierarchy to ensure the maximum content is retained
Integrate regex operations into Ranges workflow
Resolves custom-marked, cross-referenced paths in parsed JSON
Shorten sets of strings deterministically, to be git-friendly
Extracts, cleans and encodes text
Utility library to traverse AST, reports upcoming values
Turns an array of arrays of data into a nested tree of plain objects
Generate Atomic CSS
Helps to prevent widow words in a text
Parses raw Tap: string-to-object or stream-to-a-promise-of-an-object
Groups array of strings by omitting number characters
Scans all characters within a string and checks are they within ASCII range
Iterate string considering ranges, as if they were already applied
Merge and sort string index ranges
Finds where are arbitrary templating marker heads and tails located
Match substrings on the left or right of a given index, ignoring whitespace
Detects and removes thousand separators (dot/comma/quote/space) from string-type digits
Visual helper to place templating code around table tags into correct places
Invert string index ranges
Extracts chunks from possibly comma or whatever-separated string
Detect and (recursively) remove head and tail wrappings around the input string
Extracts or deletes HTML, CSS, text and/or templating tags from string
Replace chunks of whitespace with a single spaces
Crop array of ranges when they go beyond the reference string's length
HTML and CSS lexer aimed at code with fatal errors, accepts mixed coding languages
Is a character on a given index a closing of an HTML attribute?
Parser aiming at broken or mixed code, especially HTML & CSS
Finds and fixes common and not so common broken named HTML entities, returns ranges array of fixes
Parse SASS variables file into a plain object of CSS key-value pairs
Collapse the leading and trailing whitespace of a string
Extracts CSS class/id names from a string
Sort array of arrays by column, rippling the sorting outwards from that column
Gather string index ranges
Update all row numbers in all
Comprehensive, HTML-entities-aware tool to typographically-correct the apostrophes and single/double quotes
Iterate a string and any changes within given string index ranges
Search for a malformed string. Think of Levenshtein distance but in search
Strips HTML tags from strings. No parser, accepts mixed sources
§ Maybe my
esbuild settings are wrong?
Programs benchmarked above were built using esbuild on the following settings :
bundleon, but exclude any dependencies or peer dependencies (ends up bundling local imports only)
minifyon (to strip
console.timeinstances which we keep in the source to help the maintainability)
There shouldn't be any surprises, though?
§ You can try yourself
- Clone codsen monorepo,
git clone https://github.com/codsen/codsen.git
npm run bootstrap(it's a monorepo, you don't
npm i, Lerna does it)
cdinto any package's root,
- for Rollup, build and benchmark
npm run build && npm run perf
- for esbuild, build and benchmark
npm run esbuild && npm run perf
Benchmarks run on a
cjs build and vary depending on thermal throttling, machine's load and other factors.
esbuild still feels not production-ready yet, even the perf issues aside:
- code coverage comment stripping challenge is unsolved
- missing plugins to remove
console.logwithout minifying the bundle — @rollup/plugin-strip equivalent
iifebuilds which we can't unit-test
- even then,
iifebuilds are hard to tailor for the widest spectrum of browsers, compared to rollup + babel
Fingers crossed, maybe esbuild will mature in a year or so. After all, it took three years and seven months for Rollup to reach v.1, and esbuild is still one-year-old!