Faster build times 🚀

NodeBB Development
  • @baris looked into speeding up build times without sacrificing payload size in webpack, and found esbuild, which has been very helpful in reducing the build times, especially on lower-end machines.

    We're seeing a 100% (or more) speedup on build times, down from ~140 seconds to ~30 seconds (these of course are wildly approximate numbers, YMMV).

    Traditionally, the thought in a lot of programming contexts is "it doesn't matter how long it takes to build, it matters the payload size", but thanks to the work of the esbuild team, and Baris for implementing, now we can have our cake and eat it too!

  • For reference, I just rebuilt and restarted this forum:

    info: [build] Asset compilation successful. Completed in 32.083sec.

    💨

  • For reference on v3.x alpha with this change my local build goes from 11.2 seconds down to 5.1 seconds.

    info: [build] Asset compilation successful. Completed in 11.296sec.
    

    with esbuild

    info: [build] Asset compilation successful. Completed in 5.123sec.
    
  • This is epic, great work guys. My build times went from close to a min I think... to around 16s.
    This makes quickly iterating so much more enjoyable.

  • It gets even faster when you pass in development under the NODE_ENV flag!

    ... but of course you don't want to enable that flag in production.


Suggested Topics


  • 0 Votes
    5 Posts
    449 Views

    Beautiful. Thanks a bunch!

  • 5 Votes
    2 Posts
    978 Views

    @faizanzahid Honestly, we've never tried it. If you enable it, let us know what happens 😬

  • 0 Votes
    5 Posts
    1k Views

    You may also want to consider using cron.

  • 5 Votes
    1 Posts
    1k Views

    Related issue https://github.com/NodeBB/NodeBB/issues/4587

    As discussed in the issue, we had a bunch of hooks to modify a page on some routes like filter:recent.build. These were added as required but most pages didn't have a hook so if you needed one you would have to ask us to add it and wait for the next release. With the above change every route has a hook. The hook name is derived from the template name passed to the res.render(template, data); method. For example if your template is named myAwesomePage, you render it with res.render('myAwesomePage', data); and the hook that will be fired is filter:myAwesomePage.build

    Every hook gets 3 parameters {req: req, res: res, templateData: data}, data is the parameter you pass into the res.render method.

    We had a few inconsistencies in the parameters passed to the hook and the hook name below are the changes that needs to be fixed if you have a plugin that is listening to these hooks.

    filter:groups.build is now called filter:group/details.build as that is the correct name for that template. filter:popular.build used to pass in a extra term parameter, this moved into the templateData parameter. filter:header.build this is removed it was deprecated a while ago. Use filter:navigation.available instead. filter:search.build parameters changed, data is no longer passed in use req.query and req.params instead. results is now the templateData parameter.

    Feel free to ask any questions if anything isn't clear.

  • 1 Votes
    2 Posts
    2k Views

    NodeBB w/ MongoDB still works just fine even though the kerberos dependency doesn't build, it just means you can't connect to MongoDB servers utilising kerberos authentication.

    Would prefer not to have to add libkrb5-dev to the list of dependencies, so investigating alternatives...