Debugging New Plugins

We'll describe the various expectations of plugins, what goes wrong when they don't meet expectations, and point to general debugging tools that have helped us write crazy useful plugins ourselves.

The node server looks for plugins in its own node_modules directory. A plugin FooBar would be in a module named wiki-plugin-foobar with client/foobar.js within it. Does the server have your module installed alongside dozens more?

The server should know of your plugin by name. Does http://localhost:3000/system/plugins.json show your plugin's name? Try restarting the server and check again.

The wiki client will load plugins and related files by http from its origin server. Watch for this request using browser developer tools. Does it 200? Can you fetch it with a browser at http://localhost:3000/plugins/foobar/foobar.js?

The wiki client runs the code it loads and expects that code to install the plugin as a property of the window.plugins global. Check this from the javascript console once the client has tried to load the plugin. Does window.plugins.foobar hold the plugin? Is it an object itself with two properties, emit and bind, both functions?

The wiki client will fall back to an old route for plugins when it can't complete the install from the expected route. Watch for a second request of the server at the old route, http://localhost:3000/plugins/foobar.js. If the client resorts to the old route after successfully fetching javascript from the new route then there is something wrong with that javascript. Try editing 'debugger' into the javascript to start debugging the plugin's installation logic.