1

I would to pass a module as dependency into another module.

The code looks something like this

const result = module({deps: require(“./dependency”}))

function module expects function dependency as argument.

However I get an error that dependency is not a function

However the same code works if I imported const deps=require('./dependency') and then pass deps into module as argument.

Any guidance how we can do dependency injection without declaring const deps

neo-technoker
  • 369
  • 2
  • 8
  • 26

1 Answers1

0

i am not sure why .default has to be mentioned when the dependency module already defines the function as export default async function dependency. However the below code works

const result = module({deps: require(“./dependency”}).default)
neo-technoker
  • 369
  • 2
  • 8
  • 26