npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-bundler

v1.0.0-alpha.2

Published

Bundle Node-RED and all required node into one minified javascript file for AWS Lambda and command line apps.

Downloads

1

Readme

Node-RED Bundler

Bundle Node-RED and all required Nodes into one minified javascript file.

Typical use cases:

  • AWS Lambda (Serverless Functions)
  • Command line apps

The destination folder will contain all required files including the flows to start the Node-RED App on any system with node but without the Node-RED source code. You can change the flow, but any change which requires a new Node will require a rebuild of the base file build/index.js.

The final size depends mainly on the included Nodes and a starts with 1.5Mb compressed code for the base file. Alle code for Administraion and the editor have been removed and are not avialiable in the final Application!

The scope of the project is only to provide runtimes to execute flows. For managing and editing of flows use existing solutions.

Install

Install this package into your node environment to allow direct access to your installed nodes.

$ npm install --save-dev node-red-contrib-bundler

Usage

$ npm run node-red-bundler build path/to/flows.js path/to/ -o ./build

run the create Node-RED App:

$ cd ./build; node index.js

Options

$ npm run node-red-bundler build --help
node-red-bundler build [flowFile] [nodesFile]

bundle Node-RED to single file with required Nodes

Positionals:
  flowFile   path to flow.js file                           [default: "flow.js"]
  nodesFile  path to .config.nodes.json file     [default: ".config.nodes.json"]

Options:
      --version    Show version number                                 [boolean]
      --help       Show help                                           [boolean]
  -o, --output     Directory for the final bundle
                                          [string] [required] [default: "build"]
  -t, --type       Specify the type of wrapper for Node-RED
      [string] [required] [choices: "aws_lambda", "cmd"] [default: "aws_lambda"]
      --minify     minify the javascript bundle        [boolean] [default: true]
      --sourcemap  create sourcemap for the javascript bundle
                                                       [boolean] [default: true]

Notes:

  • Only --type aws_lambda is supported - see Roadmap
  • Created Javascript code is optimized for node >=14.0.0

Wrapper Types

AWS Lambda

This wrapper allows to upload a flow to AWS Lambda. The flow needs the node-red-contrib-lambda-io Nodes to get triggered by AWS Events and to return a Output to finish the Lambda Request.

Simple Example Flow: [lambda in] -> [function] -> [debug] ->[lambda out]

flow.json

[
    {
        "id": "523972b2.04908c",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "92a73334.57bf48",
        "type": "lambda in",
        "z": "523972b2.04908c",
        "name": "",
        "x": 90,
        "y": 120,
        "wires": [
            [
                "b4871dda.ccf24"
            ]
        ]
    },
    
    {
        "id": "b4871dda.ccf24",
        "type": "function",
        "z": "523972b2.04908c",
        "name": "",
        "func": "\n\nreturn {payload: msg.payload.resource, test:2};",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 290,
        "y": 120,
        "wires": [
            [
                "78ce54d8.6bd434",
                "26ed8d3d.b32b9a"
            ]
        ]
    },
    {
        "id": "26ed8d3d.b32b9a",
        "type": "debug",
        "z": "523972b2.04908c",
        "name": "XX1",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 470,
        "y": 200,
        "wires": []
    },
    {
        "id": "78ce54d8.6bd434",
        "type": "lambda out",
        "z": "523972b2.04908c",
        "name": "",
        "lambda_proxy_helper": false,
        "x": 480,
        "y": 120,
        "wires": []
    }
]

Deployment to AWS:

  • Zip the created output of the bundler
  • create or update a AWS Lambda function

Environment Configurations:

NODE_RED_USERDIR : relative path to userDir directory inside the zip (Default: "./userDir/") NODE_RED_LOG_LEVEL : Node-RED logging levels (Default: error)

Roadmap

  • [ ] Node RED projects support
  • [ ] Fix code in Node RED @node-red/loader package
  • [ ] Options to customize Wrapper and Javascript target optimizations (e.g. Node 16.x)
  • [ ] Command Line Wrapper
  • [ ] Export binary for MacOS, Linux, Windows
  • [ ] tests
  • [ ] speed tests

Contribution

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Built With

License

Distributed under the "bsd-2-clause" License. See LICENSE.txt for more information.