Is it possible to bundle node-red with webpack?

I would like to bundle only the necessarry code from node-red. I tried to use webpack for this purpose, but it`s always throws errors. I was wondering if it is possible, at all.
Any tips to reduce size/ number of files are greatly appreciated.

Could you explain your specific use case for this, e.g., are you attempting to embed your node-red install into a different application? There might be solutions based on the kind of use case you’re working with.

Yes it is embedded in to a nodejs application.

Webpack is surely for front-end packaging not back-end?

Webpack does

  • transformations (e.g. Javascript Contructs not supported on target platform),
  • bundling (creating one file with the relevant code parts)
  • treeshaking (remove all code parts which are not relevant for the use case)
  • compressing

My use case is embedding node-red for AWS Lambda. Bundeling and tree shaking helps a lot to reduce the cold start timings.

Hi,

We have used Node-RED inside AWS Lambda successfully. It can work pretty well.

Cheers,

Paul

@paulkeates I know - I have it working too, but the bundle size is 10MB+

OK - I got it now bundled an compressed with parcel down to on javascript file with 1.3MB. This file needs no node_modules folder and runs on any system with node 14.x :slight_smile:

I will update this thread with my configuration when I have finished my tests next week.

Hi,

Awesome compression results! I'd be interested to see how you accomplished that...

Cheers,

Paul

I am happy to share a first ALPHA version of my Node-RED bundler:

Current Results:

  • Packagesize (Simple Event IN->OUT flow): 1.5MB
  • Lambda Coldstart Duration: 50ms / Init Duration: 350.54 ms
  • Lambda recurrent calls Duration: 1.8-2.0ms (Memory Size: 1024 MB Max Memory Used: 89 MB)

I am happy to hear your Feedback.

4 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.