Can you write your own custom extensions without them being a node module / on npm?

Hey,

I’ve written a custom JS function that acts as a ‘mini algorithm’ on a set of data. Currently its just running client side but I’d like to move it server side and use it through the Wappler Extensions.

I’ve already got a couple of custom extensions, but they are all based on available NPM packages that have already been installed in the node_modules folder.

My question, Can i still create a custom NodeJS Wappler Extension, but just use my own JS code? Or does it need to be written and packaged up as a node module first?

NB. I’m semi-familiar with the two files used to create the Wappler Extension (the HJSON and the JS config file) its just my only examples have all been based on existing node modules.,

Nope, there is no requirement for existing node modules.

Thanks @mebeingken

So seems like I’d forgoe the ‘require’ and just include the code in the JS file in the extensions folder?

Making sure the relevant ‘exports’ syntax is set up correctly of course…

If your javascript doesn’t require any package, then you would not need a require statement. require is like an import statement, it makes a library available to that script.

You still might need require statements, even if you are not using external packages. For example, if you are writing files, you might use fs or fs-extra in a require statement.