Plugin development: environment setup


  • Plugin & Theme Dev

    Hello plugin developers,

    Please, share your experience: how do you develop plugins for NodeBB?

    • Do you use git-submodules?
    • Do you use npm link?
    • Do you use unix links?
    • Do you use separate nodebb setup per versioned plugin?

  • Plugin & Theme Dev

    It's been a while since it got an update, but I still use my nodebb-grunt-development to create and modify my plugins (written in coffeescript).

    Using one NodeBB setup for all plugins, can't see any reason not to do...


  • Plugin & Theme Dev

    I suck so I copy/pasta a general structure I currently use in my plugins into a new folder and npm link that into one big messy NodeBB install.

    One of these days I'll do it properly and I'll use something similar to grunt with maybe TypeScript, possibly in combination with Vagrant. One of these days...


  • Plugin & Theme Dev

    After some work with npm link I have found, that links do not fit NodeBB development (Main problem, that you should reuse NodeBB modules, it looks like this (../../../src/topics) and It does not work Ok with linked modules, of course you could use parent-require solution with try-catches, but I don't like such approach)

    So my development is based on File Watchers (reusable solution). I have extended plugin.json to provide syncing path, and every plugin is in separate project/repository, file watchers just sync plugins 😉


  • Plugin & Theme Dev

    @Nicolas I can't find the topic or post right now but you really should use require.parent or even better require.main when using NodeBB modules. Path traversal is scary and error prone. require.main will be app.js, so you can do require.main.require('./src/{module_name}') and it'll work everytime.

    I usually solve this like this.


  • Plugin & Theme Dev

    @Schamper Interesting 😉 I definitely will try it.


  • Admin

    Yes, as @Schamper recommends, do not use relative paths to break out of the plugin's root directory, just use module.parent.require to require from the context of plugins.js, or require.main.require to require from the context of app.js

    To answer OP, I use npm link to link my folders together. I have one big messy NodeBB install ( 😉 ) and next to it is a plugins/ folder where all the plugins live.

    @psychobunny integrated grunt into NodeBB, so I just use grunt --verbose to develop now, instead of ./nodebb dev 😄


 

| |

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.