screepers / screeps-typescript-starter

Starter kit for TypeScript-based Screeps AI codes.
https://screepers.gitbook.io/screeps-typescript-starter/
The Unlicense
441 stars 318 forks source link

How do use a module from npm? #39

Closed Ramblurr closed 7 years ago

Ramblurr commented 7 years ago

I would like to use a library from NPM in my code base. In my case I want to use ramda.js http://ramdajs.com/

I installed it with the usual npm install --save, and its working fine locally in WebStorm. But the library isn't being bundled up and uploaded to screeps.

I realize I could manually place the library in the src/lib/ folder, but I'd prefer to use the normal npm workflow if possible.

edit: So adding the ramda.js lib to src/lib/ didn't work either because the gulp file only builds the typescript files in src/

resir014 commented 7 years ago

Hey @Ramblurr! You will need to bundle with Webpack (set bundle to true in your config) while compiling for it to include external modules as well.

Ramblurr commented 7 years ago

Yup, this fixed the issue for me. Using the default flattened config doesn't work, but using webpack via the bundled flag does. Thanks!