Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How do you dependency inject a ES module?


You'll export a function from your esModule if you want to inject

export const myFn = (...deps) =>

You don't need anything else, for encapsulation you have the EsModule, that what OP meant.


ah, thanks, I thought it was something different.


You have dynamic imports too if you need IoC.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: