Skip to main content

Using user Modules

YepCode Modules allow to define an isolated set of JavaScript or Python functions to be reused from any of your process.

These modules may help to share functions between processes to solve some business logic problem, to encapsulate access to some service, or any other purpose where splitting the code in modules makes sense.

Modules work slightly differently in JavaScript or Python. Here you have some guide:

To use a module you need to use the custom import syntax into the process (or other module) where you want to use it.

const { myFunc } = yepcode.import("your-module");

You can have as much modules as you need, and all of them work like any CommonJS module, exporting the functions that you want to use from processes source code.

A sample of js module exporting only one function to say hello:

module.exports = () => console.log("Hello world!");

If you need to use this library from a YepCode process, and it has a name say_hello, the piece of code to do that would be:

const sayHello = yepcode.import("say_hello");


A module may also export several functions:

const sayHelloToMike = () => console.log("Hello Mike!");
const sayHelloToDavid = () => console.log("Hello David!");

module.exports = { sayHelloToMike, sayHelloToDavid };

To use that functions, you have to read it from the returned object:

const sayHelloModule = yepcode.import("say_hello");


Writing modules from process edition screen

You can easily view and change modules from the process edition page, opening a component with this shortcut:

With that, a modal window shows you the defined modules, making easy to modify or consult them.