pilwon / node-ib

Interactive Brokers TWS API client library for Node.js
382 stars 133 forks source link

Use ES6 modules #76

Open claude2 opened 7 years ago

claude2 commented 7 years ago

Tried to use node-ib with Webpack (disabled net temporarily), still getting this error:

Uncaught (in promise) Error: Cannot find module './contract'.

It is caused by this line.

This patch seems to work:

IB.prototype.contract = require('./contract/index');
IB.prototype.order = require('./order/index');
IB.prototype.util = require('./util');

But, any plans to use modern ES6 modules?

pilwon commented 7 years ago

@claude2 No immediate plan but I hope to see this library rewritten in TypeScript 2.

pilwon commented 7 years ago

@claude2 Removed dynamic require in v0.1.16. Please try again and let me know if it still has any problem with webpack/browserify.

claude2 commented 7 years ago

Thanks you for the fix, it resolved the modules error. The net-related error is still there. I left a comment in #75 since it's more on topic.

pilwon commented 7 years ago

@claude2 Please see the comment https://github.com/pilwon/node-ib/issues/75#issuecomment-257071116