cryptpad / chainpad-crypto

Pluggable cryptography module for chainpad
GNU Affero General Public License v3.0
4 stars 3 forks source link

Add support for `exports`. #1 #2

Closed chmac closed 5 years ago

chmac commented 5 years ago

Not sure if this is the correct strategy or not, but it fixes the issue I described in #1 for me.

ansuz commented 5 years ago

It's a bit surprising that Typescript can't use what should be supplied by module.exports, since that would make it incompatible with the majority of the nodejs ecosystem.

I'm not against just accepting this PR, but we're planning on adding support for nodejs in a bunch of other modules which are currently clientside-only, and I'd like to know the underlying reason why this format isn't compatible with Typescript.

I don't know much about typescript but a short search suggests that it might have something to do with our code not having a clearly defined type.

I also found this repo which provides examples of how to define modules for various use cases. I'm not sure if Typescript is considered.

chmac commented 5 years ago

@ansuz Likewise, I assumed that Typescript would define module.exports, but that didn't seem to work. To be clear though, I'm running typescript via create-react-app which actually uses webpack to build the bundle and then serve it from typescript. To get the same setup running here is a minimum reproduction to show the error: https://github.com/chmac/typescript-chainpad-crypto

My typescript fu is limited, I was surprised I found such a simple option in adding exports!

chmac commented 5 years ago

I'm going to close this because this approach doesn't actually work with TypeScript. I'll post more info on the issue I opened #1 and hope we can figure out a solution there.