m4ss1m0g / mediatr-ts

Mediator patter for Typescript, inspired to MediatR csharp library
MIT License
46 stars 9 forks source link

ES Modules support #11

Closed brunovinicius closed 1 year ago

brunovinicius commented 1 year ago

Hello! I am just starting to use your lib on commercial application I am developing and I think it rocks.

Although I am quite aware that rarely would someone use such for the frontend, I would like to request support for ES Modules additionally to CommonJS. Publishing ESM would make the project more friendly so maybe more people could enjoy some CQRS when building corporate apps :)

I am not very versed in publishing packages to NPM but we could have a second package named mediatr-ts/esm as an alternative for frontend endeavors like mine.

m4ss1m0g commented 1 year ago

Hi! Thanks for the suggestion. I think (but I'm not sure) that to transpile with ES support is sufficient to change the property module of tsconfig file to build to es. You can try to clone the repo and try.

brunovinicius commented 1 year ago

Yep! Thats exactly right. My concern is that maybe this causes a breaking change for CommonJS users. If you think its ok to change on the main repo (since its a new lib, we could say this might be ideal) I will gladly test it and submit a PR.

Let me know.

m4ss1m0g commented 1 year ago

You can use an alternative tsconfig, see the build script inside the package.json, the objective is to build an ES compatibility npm package without altering the source code. For a PR: you can try to submit it but I have to check the possibility of publishing a new npm package.