Skip to content

Broccoli Plugin Authorship Docs #7

@oligriffiths

Description

@oligriffiths

List of use cases for the different types of plugin you might want to build...

We want people to think about a broccoli plugin in the right way.
It's kind of like a component.
Does not break encapsulation.
Has defined inputs and output.
It should be isolated.
Errors.
Debugging, broccoli test helper

Common questions

Encapsulation, what you get/write
Why/how do I use multiple inputNodes?
How do you go from naive plugin, to cached and/or persisted
What hooks need to be implemented? Build and constructor
What do I export? How do I compose/inherit?

What do I export? How do I compose/inherit?

Use cases: building a pipeline, extending a plugin (authorship)
Explain why with below:

// MyPlugin.js
module.exports = myPlugin(...params) => {
    return new MyPlugin(...params);
}
module.exports.Plugin = MyPlugin;

// consumption
const oliPlugin = require('oli-plugin');
oliPlugin(previousNode);

// extension
const { Plugin: OliPlugin } = require('oli-plugin');
class OtherPlugin extends OliPlugin{}

What hooks need to be implemented? Build and constructor

Constructor: https://github.com/broccolijs/broccoli-plugin#new-plugininputnodes-options
Build:

  • when is it invoked? When broccoli needs the output of your plugin, it will ensure that your inputs are ready.
  • What are you given?
  • inputPaths resolved with absolute paths for input files
  • do not write to inputs
  • use paths relative to inputPaths
  • respect node resolution, don't use cwd()
  • return a promise or nothing
  • only 1 plugin is built at any given time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions