alpaca-trade-api-js icon indicating copy to clipboard operation
alpaca-trade-api-js copied to clipboard

Migrate to ES modules

Open neeschit opened this issue 5 years ago • 10 comments

With node 10 officially entering maintenance mode, There's no good reason for anyone being on a version of node below 10 now. Converting this to use ES modules would be forward looking, and make this module easier to consume for typescript and Node 10+ users who prefer ESM.

While the community TS project is nice, most people would loathe to diverge too far from the officially supported API interface. Switching this module to ESM would be relatively straightforward as well, and I'd be happy to throw out a PR if the community is bought into this. This would allow us to write a good index.d.ts file as well, which will provide great IDE support without a synthetic default export

neeschit avatar Aug 11 '20 03:08 neeschit

@shlomikushchi - curious on your thoughts on this.

neeschit avatar Nov 08 '20 23:11 neeschit

let's talk. can you contact me on the alpaca slack channels?

shlomiku avatar Nov 09 '20 09:11 shlomiku

Hi, is this moving forward? If not I'll be forking and implementing myself.

anonrose avatar Dec 03 '20 07:12 anonrose

btw have you seen this?

https://github.com/117/alpaca

neeschit avatar Dec 04 '20 01:12 neeschit

@neeschit I haven't, I'm going to move forward with that. Thank you!

anonrose avatar Dec 04 '20 06:12 anonrose

Out of curiosity, what versions of Node does this library support? @shlomikushchi

neeschit avatar Dec 07 '20 18:12 neeschit

let's talk. can you contact me on the alpaca slack channels?

To summarize what we spoke offline, maintaining backwards compatibility takes priority over migrating to ESM. We will need to publish a hybrid npm package.

The approach I was looking to use is somewhat detailed here:

https://2ality.com/2019/10/hybrid-npm-packages.html#option-2%3A-bare-import-commonjs%2C-deep-import-esm-(maximum-backward-compatibility)

I will try to create a PR when I have time

neeschit avatar Dec 07 '20 18:12 neeschit

@neeschit I am unaware of any limitations right now, but if you are - let me know so we could document it.

shlomiku avatar Dec 08 '20 15:12 shlomiku

Ok, it would be great if we could limit support to Node 12+ or even better, Node 14+ which is now LTS/Default recommended on https://nodejs.org/en/.

If we are comfortable doing that @shlomikushchi, I can cut a PR to migrate to ES modules, building on the work by @anonrose to tweak the package.json to support both CJS and ESM

neeschit avatar Dec 08 '20 20:12 neeschit

image

node 10 eol is in a few months, so that makes sense moving forward. node 12 has more than a year, so it is better to keep that

shlomiku avatar Dec 09 '20 09:12 shlomiku