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!
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.