Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
BroccoliBridge
✓ const BroccoliBridge = require('broccoli-bridge');
✗ import BroccoliBridge from 'broccoli-bridge';
The package is published as CommonJS. ESM import syntax is not directly supported by this version (v1.0.0). TypeScript users would typically rely on `@types/broccoli-bridge` for type declarations.
Demonstrates how to use `broccoli-bridge` to manage dependencies between Broccoli nodes, allowing for flexible instantiation order by using named placeholders that are later fulfilled.
class MockBroccoliNode {
constructor(name) {
this.name = name;
this.inputPaths = []; // Mock required property for some Broccoli contexts
this.outputPath = `/tmp/broccoli-${name}`;
}
}
// Mock Broccoli Plugin classes for demonstration
class PluginA {
constructor(inputNodes) {
this.inputNodes = inputNodes;
this.name = 'PluginA_Node';
console.log('PluginA instantiated with inputs:', inputNodes.map(n => n.name || 'placeholder'));
}
// In a real scenario, PluginA would implement a `build` method.
}
class PluginB {
constructor(inputNodes) {
this.inputNodes = inputNodes;
this.name = 'PluginB_Node';
console.log('PluginB instantiated with inputs:', inputNodes.map(n => n.name || 'unknown'));
}
// In a real scenario, PluginB would implement a `build` method.
}
const BroccoliBridge = require('broccoli-bridge');
// Stash your bridge instance somewhere central for later access
let bridge = new BroccoliBridge();
console.log('BroccoliBridge instance created.\n');
// Create your `PluginA` instance using a placeholder for PluginB's output
const inputOne = new MockBroccoliNode('InputOne');
const placeholderForB = bridge.placeholderFor('plugin-b');
console.log('Placeholder for "plugin-b" created.');
let a = new PluginA([
inputOne,
placeholderForB // PluginA depends on the future output of 'plugin-b'
]);
console.log('PluginA created, its second input is currently a placeholder.\n');
// Instantiate PluginB and fulfill the placeholder with its actual instance
const inputTwo = new MockBroccoliNode('InputTwo');
const inputThree = new MockBroccoliNode('InputThree');
let b = new PluginB([inputTwo, inputThree]);
console.log('PluginB created with its own inputs.');
bridge.fulfill('plugin-b', b);
console.log('Placeholder "plugin-b" fulfilled with the actual PluginB instance.\n');
// At this point, if a Broccoli build process were to start,
// PluginA would correctly receive the output of PluginB
// via the fulfilled placeholder. The conceptual dependency is resolved.
console.log('During a Broccoli build, PluginA will effectively receive the node named: ' + b.name + ' as its second input.');
console.log('The order of instantiation for PluginA and PluginB did not matter thanks to broccoli-bridge.');
Errors
Common errors & fixes
TypeError: node.inputPaths is not a function
The underlying internal Broccoli Plugin API that `broccoli-bridge` relies on has changed, making the placeholders incompatible with how Broccoli nodes are expected to be processed.
fixCheck the `broccoli` changelog for breaking changes related to its Plugin API. Verify if a newer version of `broccoli-bridge` or a patch exists, or if a manual update to your build configuration is required to adapt to Broccoli's new internal structure.
ReferenceError: BroccoliBridge is not defined
This error typically occurs when attempting to use ESM `import` syntax (`import BroccoliBridge from 'broccoli-bridge'`) with `broccoli-bridge` v1.0.0, which is a CommonJS package, or if the `require` statement itself is missing or malformed.
fixEnsure you are using the correct CommonJS `require` syntax: `const BroccoliBridge = require('broccoli-bridge');`. Error: Placeholder 'some-name' was never fulfilled before build started.
While `placeholderFor(name)` can be called before `fulfill(name, node)`, the Broccoli build process expects all node dependencies to be resolvable. If a placeholder is created but never fulfilled with an actual Broccoli node before the build begins, it will result in a build-time error.
fixConfirm that every `bridge.placeholderFor(name)` call has a corresponding `bridge.fulfill(name, node)` call with a valid Broccoli node for that exact `name` before your Broccoli build command is executed.
Audit
Dependencies
broccolirequiredThis utility operates within the Broccoli build system and depends on its core APIs and node structure. While not a direct runtime dependency in `package.json`, it is a fundamental peer/conceptual dependency.