Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broccoli Plugin Authorship Docs #7

Open
oligriffiths opened this issue Jan 30, 2019 · 0 comments
Open

Broccoli Plugin Authorship Docs #7

oligriffiths opened this issue Jan 30, 2019 · 0 comments

Comments

@oligriffiths
Copy link
Contributor

oligriffiths commented Jan 30, 2019

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
@oligriffiths oligriffiths changed the title Broccoli Plugin Docs Broccoli Plugin Authorship Docs Feb 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant