I would like to share with you that I released the first iteration of the nrg
cli.
- This is a template you can use to test the cli, and later use to create your own node-red node projects: GitHub - AllanOricil/node-red-node-esm-template: Build Node-red nodes using ES6+ and esm module system with the nrg cli
- This is the nrg-cli repository: GitHub - AllanOricil/nrg-cli: A CLI tool to quickly generate, build, and manage Node-RED nodes and plugins, empowering your development workflow.
- This is the nrg-core repository: GitHub - AllanOricil/nrg: A builder that enables developers to build node-red nodes with modern javascript and css
- This is the lib that makes node-red-node repository: GitHub - AllanOricil/node-red-node: A very simple lib that aims to ease the creation of node-red nodes
Release Notes
I'm excited to introduce the nrg
(acronym for Node-RED Generator - reads as "energy") builder for Node-RED nodes. It streamlines your development workflow with powerful tools and features. Below is an overview of the features you can leverage to build, test, and optimize your custom Node-RED nodes.
Core Features
1. Process Client and Server Javascript with esbuild
Harness the power of esbuild, a modern JavaScript bundler known for its speed and efficiency. Here’s how it supercharges your development:
- Tree Shaking: Automatically eliminates unused code, keeping your builds clean and lightweight.
- Bundling: Consolidates multiple files into a single output, optimizing your deployment.
- Source Maps: Easily debug production code with source maps that link back to your original code.
- Minification: Compresses and obfuscates your JavaScript, reducing file size and improving load times.
These features ensure that your Node-RED nodes are performant, compact, and production-ready.
2. Process Stylesheets with PostCSS
We’ve integrated PostCSS to process your stylesheets, giving you full control over CSS transformations:
- Scoped styles for your node: Automatically prefixes all styles with the node’s unique type, ensuring styles are encapsulated and preventing any leakage into other nodes.
- Vendor Prefixing: Automatically adds necessary vendor-specific prefixes, ensuring your styles work seamlessly across different browsers.
- Minification: Compresses CSS files by removing unnecessary characters, improving load times and performance.
- Customization: Use PostCSS plugins to extend its capabilities, from autoprefixing to advanced CSS features.
This integration ensures your nodes not only perform well but also look polished and professional in the UI.
3. HTML Minification with html-minifier
Optimizing HTML content is just as important as your JavaScript and CSS. With html-minifier, your HTML files, including node templates and documentation, are automatically:
- Minified: Reduces file sizes by removing redundant spaces, comments, and other unnecessary characters.
- Optimized for Performance: Smaller HTML files mean faster load times and reduced bandwidth usage.
4. Pre-Configured Node-RED dev environment
Quickly iterate on your node development with a seamless testing workflow:
- Pre-configured Node-RED Environment: it provides a fully configured Node-RED instance that’s ready to go as soon as you start developing.
- Immediate Testing: Simply start Node-RED, and begin testing your node’s functionality without any manual setup or additional configuration.
This fast feedback loop allows you to focus on writing and improving your nodes without worrying about configuration.
5. Structured Project Layout
The generator introduces a well-organized project structure, making it easier for developers to organize their code and maintain large projects:
- Clear Separation of Concerns: Code is neatly organized into folders for source files, styles, assets, and more, allowing for logical code management.
- Scalability: As your project grows, the structured layout ensures that you can easily add new features without clutter or confusion.
This structure promotes cleaner code and simplifies collaboration among team members, and cross projects.
Developer Experience
7. Seamless Debugging for Client and Server Code
It provides robust debugging tools, allowing developers to debug both client and server-side code with ease:
- Chrome DevTools Support: Debug client-side code directly in Chrome using the built-in developer tools.
- VS Code Debugger Integration: Use the VS Code debugger to step through server-side code, inspect variables, and troubleshoot issues.
This enables a smooth debugging experience, ensuring that you can diagnose and resolve issues in both environments efficiently.
8. Watch Mode for Auto Rebuilds
Boost your productivity with Watch Mode:
- Automatic Rebuilds: As soon as you save your source files, esbuild jumps into action to rebuild your JavaScript.
- Node-RED Restart: The development server automatically restarts Node-RED, loading the latest changes for immediate testing.
No need to manually stop and restart Node-RED anymore. Watch mode ensures you stay in the flow of development, letting you see your changes in real time.
Optimized for Speed and Simplicity
By leveraging esbuild, PostCSS, html-minifier , and a well-organized project layout, nrg
ensures a fast and modern development experience. It keeps your code optimized for performance and compatibility, while also:
- Ensuring Compatibility with Current and Future Browsers: PostCSS vendor prefixing and ES module support ensure that your code is compatible with current browser standards, and future-proof for emerging technologies.
- Seamless Debugging and Development: Modern tools and watch mode ensure smooth iteration and debugging, allowing you to focus on building better nodes.
Whether you’re aiming for high performance, clean modularity, or smooth debugging,nrg
provides the tools to build and optimize robust Node-RED nodes.
Get Started Today!
Experience the improved speed and ease of building Node-RED nodes with nrg
.