What do you think about bundling flows?

I've been thinking about it for a week now. What if I scan a flow.json, get all node types, find their nodes, and then build a single bundled dependency which has all nodes required to run that flow? It is going to feel like Im building an application.

Because I will be bundling all nodes that are part of a flow, all the code from node dependencies that are not used is going to be removed (tree shaking), and there will be a single minified javascript in both server and client. I believe the flow startup will load so much faster, dockerized flows will be smaller, and there will be no longer thousands of duplicate dependencies!

Has anyone tried it?

Hi @AllanOricil

This might interest you - its a framework that I built to create "Single File Executables"
the READ-ME has all the gory bits.

It basically compiles Node RED with embedded flows/modules to an S.F.E
Not sure it's related - but maybe useful for you

its based on Node RED v4 + ESBuild + PKG

EDIT
See original post : Node RED v4 : Single File Executable
and lets not forget @dceejay also had fun here : GitHub - dceejay/electron-node-red: Electron Node-RED template

1 Like

Will check that out. Thanks @marcus-j-davies

I read the build.js and what I have in mind is different. Im not packing a flow into a standalone app, I'm just optmizing the flow by bundling all its depndencies, and not copying them over to the packaged app. This would result in 1 single dependency, like a huge node package. All code that isn't used would he gone. In node_modules there would exist only a single package, with a single huge minified index.js. The same for index.html, locales, icons, examples assets.

After bundling the flow, I could use your build.js to pack it. There would exist 1 dependency in node_modules.

Worth a try to see how it goes

1 Like