Type: New Feature
Affects Version/s: None
Fix Version/s: None
As a developer,
I want to be able to use NPM to install modules and libraries,
So that I can install packages such as bluebird, lodash, or custom libraries from NPM in my application.
Unless I am missing something here, at compile time, you know all the libraries that could possibly be referenced. For all static includes, i.e. require("lodash") or require("../mylib"), you could easily map and change the requires to the correct path before packaging the app.
Dynamic requires, i.e. require(myvar + "mylib") would require a bit more effort such as creating a function that could lookup the desired library at runtime and use that with the relative folder to find it in a list of libraries in the app (assuming the list was generated at compile time.)
You could also look in the package.json files at compile time to see if there is a main referenced. Support for index.js could also be added at compile time.
I've tried a few of the methods such as ti-commonjs which look for things at runtime, but the performance hit from those was far too great.