Hook Tutorial

WARNING! v0.13 was just released, and the tutorial is currently undergoing final testing. It's recommended that you DO NOT follow along until this message is removed (please check back tomorrow).

A tutorial for learning to create your own hooks

Step 7: Publishing the Hook

If you plan on publishing your hook to npm, then you'll need to build it before doing so.

You can view the finished code for this step by checking out the step-7 branch.

Build the Hook

Before you publish, you need to run npm install inside the hook to build it. Doing this will cause the code will be transpiled and placed into two directories; raw ES5 code will be placed in a lib/ directory, and ES5 code that leaves the import/export statements intact (a requirement for tree-shaking) will be placed in an es/ directory.

The final folder structure (after build) will look like this:

polling-hook
|-- es
|   |--index.js
|-- lib
|   |--index.js
|-- src
|   |--index.js
|-- test
|   |-- test.spec.js
|-- .babelrc
|-- package.json
|-- README.md

Next Steps

That's all for this tutorial.

If you want to see a more full-featured version of this hook, check out the official lore-hook-polling hook.