# Is it possible to bundle node-red with webpack?

**URL:** <https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213>\
**Category:** General\
**Created:** [25 March 2021 18:36 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213 "2021-03-25T18:36:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norberg95](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Norberg95](https://discourse.nodered.org/u/Norberg95)\
**Post date:** [25 March 2021 18:36 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/1 "2021-03-25T18:36:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [25 March 2021 18:57 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/2 "2021-03-25T18:57:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Norberg95](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@Norberg95](https://discourse.nodered.org/u/Norberg95)\
**Post date:** [25 March 2021 19:08 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/3 "2021-03-25T19:08:30Z")

</div>

Yes it is embedded in to a nodejs application.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 March 2021 01:38 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/4 "2021-03-26T01:38:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aheissenberger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aheissenberger/32/41388_2.png) [@aheissenberger](https://discourse.nodered.org/u/aheissenberger)\
**Post date:** [6 May 2021 22:37 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/5 "2021-05-06T22:37:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [7 May 2021 01:04 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/6 "2021-05-07T01:04:13Z")

</div>

Hi,

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

Cheers,

Paul

---

<div class="post-metadata">

**Author:** ![aheissenberger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aheissenberger/32/41388_2.png) [@aheissenberger](https://discourse.nodered.org/u/aheissenberger)\
**Post date:** [7 May 2021 10:10 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/7 "2021-05-07T10:10:15Z")

</div>

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

OK - I got it now bundled an compressed with [parcel](https://v2.parceljs.org/) down to on javascript file with 1.3MB. This file needs no node\_modules folder and runs on any system with node 14.x 🙂

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

---

<div class="post-metadata">

**Author:** ![paulkeates](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@paulkeates](https://discourse.nodered.org/u/paulkeates)\
**Post date:** [7 May 2021 21:45 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/8 "2021-05-07T21:45:50Z")

</div>

Hi,

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

Cheers,

Paul

---

<div class="post-metadata">

**Author:** ![aheissenberger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aheissenberger/32/41388_2.png) [@aheissenberger](https://discourse.nodered.org/u/aheissenberger)\
**Post date:** [12 May 2021 22:20 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/9 "2021-05-12T22:20:03Z")

</div>

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

> **[node-red-contrib-bundler](https://www.npmjs.com/package/node-red-contrib-bundler)**
>
> Bundle Node-RED and all required node into one minified javascript file for AWS Lambda and command line apps.

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 July 2021 22:20 UTC](https://discourse.nodered.org/t/is-it-possible-to-bundle-node-red-with-webpack/43213/10 "2021-07-11T22:20:51Z")

</div>

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