Working with ES6

Feature(s) impacted

I’m working with an Express app using es6 modules. When trying to add smart actions, I use a cjs file but the requireAll method built into forest-express-mongoose filters these files out.

Observed behavior

files with .cjs extension are filtered out and not imported.

Expected behavior

under /forest dir - .cjs files should be imported to achieve smart actions in an express app that uses es6 modules.


  • Project name: Hoox
  • Team name: Operations
  • Environment name: Express Mongoose
  • Agent type & version: .v8
  • Recent changes made on your end if any:
    When I change the DEFAULT_FILTER in require-all function everything works well but when I deploy to heroku, node install is called and deletes the workaround. please see the attached snippet (that works).

Hello and welcome @GuyFreedman,
In the app.js file, you can pass to the requireAll method a filter option to pass your own filter. Did you try this ?
You can find some examples from this repository in the test.js file.

1 Like

Thanks for your reply.
I know that (and tried). I get the correct object from require-all method but for some reason I can’t get forest to read these files.
I tried again (after a million trials yesterday) and it works. You answer did magic.
Thanks a lot!