neo4j-documentation / docs-ui

Mozilla Public License 2.0
4 stars 23 forks source link

Use esbuild to bundle JavaScript code #40

Closed ggrossetie closed 3 years ago

ggrossetie commented 3 years ago

What I did

  1. Replace browserify + uglify by esbuild
  2. Remove unnecessary development dependencies
  3. Integrate esbuild in the Gulp build (first step to avoid significant changes)
  4. esbuild is configured to be compatible with:
    • chrome58
    • firefox57
    • safari11
    • edge16
  5. Introduce a entry file src/js/site.js (as you can see we can now use ES6+ syntax)

The build is a lot faster (esbuild is written in Go with a JavaScript API) from ~12s to ~2s. We will probably need to perform extensive tests to ensure that there is no regression.

Before
$ gulp pack             
(...)
[15:08:18] Finished 'pack' after 12 s
After
$ gulp pack
(...)
[15:00:00] Finished 'pack' after 1.69 s

Files generated by esbuild are roughly equivalent to browserify + uglify in size.

ggrossetie commented 3 years ago

I also have another prototype based on https://rollupjs.org/ (instead of esbuild) which relies on a Babel plugin to transpile the code and https://github.com/terser/terser to minify the code.

adam-cowley commented 3 years ago

I've merged #41 - Can I just close this one without merging or is there anything we need from it?

ggrossetie commented 3 years ago

I've merged #41

Cool :+1:

Can I just close this one without merging or is there anything we need from it?

Yes, we can close this pull request, it was only intended to showcase benefits and drawbacks of esbuild compared to rollup.