{"id":10592,"library":"broccoli-node-info","title":"Broccoli Node Information Utility","description":"broccoli-node-info is a low-level JavaScript utility package designed to interact with Broccoli.js plugin instances (nodes). Its primary function is to provide a thin, normalized wrapper around the `node.__broccoliGetInfo__()` internal API, abstracting away differences between various Broccoli node API versions to consistently return a `nodeInfo` object conforming to the latest specification. This package is primarily leveraged by the core Broccoli `Builder` class but is also invaluable for developers performing node inspection, testing, diagnostics, or creating wrappers, offering a safer alternative to directly accessing private node variables like `_name` or `_inputNodes`. The current stable version is 2.2.0, with recent updates like 2.0.0 and 2.1.0 indicating active maintenance and compatibility updates, such as tracking input changes and support for the `volatile` option. Its release cadence aligns with major Broccoli.js ecosystem updates, ensuring it remains a foundational piece for interacting with Broccoli nodes programmatically.","status":"active","version":"2.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/broccolijs/broccoli-node-info","tags":["javascript","broccoli"],"install":[{"cmd":"npm install broccoli-node-info","lang":"bash","label":"npm"},{"cmd":"yarn add broccoli-node-info","lang":"bash","label":"yarn"},{"cmd":"pnpm add broccoli-node-info","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Main function to retrieve normalized info for a Broccoli node. The README shows CJS 'require', but ESM imports are preferred for modern Node.js applications.","wrong":"const broccoliNodeInfo = require('broccoli-node-info');\nbroccoliNodeInfo.getNodeInfo(node);","symbol":"getNodeInfo","correct":"import { getNodeInfo } from 'broccoli-node-info';"},{"note":"Custom Error class thrown by `getNodeInfo` when an invalid Broccoli node is passed.","wrong":"const { InvalidNodeError } = require('broccoli-node-info');","symbol":"InvalidNodeError","correct":"import { InvalidNodeError } from 'broccoli-node-info';"},{"note":"A hash representing the supported feature flags for the current node API version, used internally by `getNodeInfo`.","wrong":"const { features } = require('broccoli-node-info');","symbol":"features","correct":"import { features } from 'broccoli-node-info';"}],"quickstart":{"code":"import { getNodeInfo } from 'broccoli-node-info';\nimport BroccoliPlugin from 'broccoli-plugin';\n\nclass MyBroccoliPlugin extends BroccoliPlugin {\n  constructor(inputNodes, options) {\n    super(inputNodes, {\n      annotation: options?.annotation || 'MyBroccoliPlugin',\n      name: options?.name || 'MyBroccoliPlugin',\n      persistentOutput: true,\n      ...options\n    });\n  }\n\n  async build() {\n    // Simulate some build process\n    console.log(`Building with ${this.inputNodes.length} input nodes.`);\n  }\n}\n\nconst dummyNode = new MyBroccoliPlugin([], { annotation: 'my-plugin-instance' });\n\ntry {\n  const nodeInfo = getNodeInfo(dummyNode);\n  console.log('Node Name:', nodeInfo.name);\n  console.log('Node Annotation:', nodeInfo.annotation);\n  console.log('Persistent Output:', nodeInfo.persistentOutput);\n  console.log('Input Nodes (raw):', nodeInfo.inputNodes);\n} catch (error) {\n  console.error('Error getting node info:', error.message);\n}\n\n// Example of an invalid node\nconst invalidNode = 'path/to/my/files'; // Plain string node (deprecated)\ntry {\n  getNodeInfo(invalidNode);\n} catch (error) {\n  console.error('Caught expected error for invalid node:', error.message);\n}","lang":"typescript","description":"Demonstrates how to use `getNodeInfo` to safely extract information from a Broccoli plugin instance, including handling potential `InvalidNodeError`."},"warnings":[{"fix":"Upgrade your Node.js environment to version 8 or higher to ensure compatibility with `broccoli-node-info` v2 and above.","message":"Version 2.0.0 of `broccoli-node-info` raised the minimum required Node.js version to `8.* || >= 10.*`. Projects running on older Node.js versions (e.g., Node.js 6) will experience failures.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"For source directories, use `broccoli-source` instances instead of plain strings. Ensure any custom Broccoli plugins adhere to the latest Broccoli node API specification.","message":"Calling `getNodeInfo()` with plain string nodes (e.g., `'app'`) or nodes conforming to the legacy `.read/.rebuild` API (from Broccoli 1.0 and earlier) will now throw an `InvalidNodeError`. These node types are considered deprecated in the modern Broccoli ecosystem.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Always use `broccoli-node-info.getNodeInfo(node)` to safely inspect Broccoli nodes and retrieve their information in a future-proof manner.","message":"Directly calling `node.__broccoliGetInfo__()` or accessing private properties like `node._name` or `node._inputNodes` on Broccoli plugin instances is strongly discouraged. These internal APIs are subject to change and may lead to unstable or incorrect behavior across different Broccoli versions.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"If the string represents a source directory, use `broccoli-source` to create a proper source node. Otherwise, ensure the argument is a valid Broccoli plugin instance.","cause":"The `getNodeInfo` function was invoked with a plain string instead of a valid Broccoli plugin instance. Plain string nodes are deprecated.","error":"broccoliNodeInfo.InvalidNodeError: Invalid node: [object String]"},{"fix":"Verify that the object passed to `getNodeInfo` is an instance of a Broccoli plugin that conforms to the current node API specification. For legacy nodes, consider updating them to the latest API.","cause":"The `getNodeInfo` function was called with an object that is not a recognized Broccoli node, or it is a node using the deprecated `.read/.rebuild` API.","error":"broccoliNodeInfo.InvalidNodeError: Invalid node: [object Object]"}],"ecosystem":"npm"}