{"action":"created","issue":{"url":"https://api.github.com/repos/appcelerator/hyperloop-module-template/issues/8","repository_url":"https://api.github.com/repos/appcelerator/hyperloop-module-template","labels_url":"https://api.github.com/repos/appcelerator/hyperloop-module-template/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/appcelerator/hyperloop-module-template/issues/8/comments","events_url":"https://api.github.com/repos/appcelerator/hyperloop-module-template/issues/8/events","html_url":"https://github.com/appcelerator/hyperloop-module-template/issues/8","id":138432698,"number":8,"title":"How can we support depending on JS libraries (on NPM)","user":{"login":"FokkeZB","id":2699409,"avatar_url":"https://avatars.githubusercontent.com/u/2699409?v=3","gravatar_id":"","url":"https://api.github.com/users/FokkeZB","html_url":"https://github.com/FokkeZB","followers_url":"https://api.github.com/users/FokkeZB/followers","following_url":"https://api.github.com/users/FokkeZB/following{/other_user}","gists_url":"https://api.github.com/users/FokkeZB/gists{/gist_id}","starred_url":"https://api.github.com/users/FokkeZB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FokkeZB/subscriptions","organizations_url":"https://api.github.com/users/FokkeZB/orgs","repos_url":"https://api.github.com/users/FokkeZB/repos","events_url":"https://api.github.com/users/FokkeZB/events{/privacy}","received_events_url":"https://api.github.com/users/FokkeZB/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-04T09:56:59Z","updated_at":"2016-03-22T10:11:00Z","closed_at":null,"body":"There's a lot of valuable JS libraries out there developers would love to use in Titanium apps and as part as modules.\r\n\r\nAlloy comes with Underscore, Backbone and Momentjs but the last two need to be modified in order to work in Titanium.\r\n\r\n* Backbone because we don't have a shim for `XMLHttpRequest` which it relies on via `jQuery/Zepto/ender`.\r\n* Momentjs because [our `require()` is not Nodejs compliant](https://jira.appcelerator.org/browse/TIMOB-16078).\r\n\r\nIt would be great if we could resolve TIMOB-16078 and/or integrate [Titaniumifier](https://github.com/smclab/titaniumifier/wiki) in the app/module build process to wrap Nodejs dependencies into a single CommonJS module including common shims."},"comment":{"url":"https://api.github.com/repos/appcelerator/hyperloop-module-template/issues/comments/199733688","html_url":"https://github.com/appcelerator/hyperloop-module-template/issues/8#issuecomment-199733688","issue_url":"https://api.github.com/repos/appcelerator/hyperloop-module-template/issues/8","id":199733688,"user":{"login":"yuchi","id":646609,"avatar_url":"https://avatars.githubusercontent.com/u/646609?v=3","gravatar_id":"","url":"https://api.github.com/users/yuchi","html_url":"https://github.com/yuchi","followers_url":"https://api.github.com/users/yuchi/followers","following_url":"https://api.github.com/users/yuchi/following{/other_user}","gists_url":"https://api.github.com/users/yuchi/gists{/gist_id}","starred_url":"https://api.github.com/users/yuchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuchi/subscriptions","organizations_url":"https://api.github.com/users/yuchi/orgs","repos_url":"https://api.github.com/users/yuchi/repos","events_url":"https://api.github.com/users/yuchi/events{/privacy}","received_events_url":"https://api.github.com/users/yuchi/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T10:10:59Z","updated_at":"2016-03-22T10:10:59Z","body":"First of all we need some lexicon to start with. I hope Appc will starts following CommonJS and now standard terminology.\r\n\r\n- **modules** are\r\n  - akin to *compilation units*\r\n  - they `import` (or `require()`) stuff from other *modules*\r\n  - they `export` stuff\r\n- **packages** are\r\n  - a way to *distribute* a module or a set of modules\r\n  - the concept of *dependencies* is delegated to *package managers*\r\n\r\nGiven this terminology we build up some more:\r\n\r\n- **package managers** are\r\n  - tools (mostly CLI and registries) that download *packages*\r\n  - they enforce their (or someone else’s) *dependency declaration system*\r\n- **bundlers** are\r\n  - tools that, by implementing a package manager or environment *imports resolution algorithm*, can *squash packages* into a *single deliverable module*\r\n\r\nThis dicotomy started when a server-oriented environment (cheap and fast file access, higher memory availability) became the target environment for thousands of libraries/packages and was to be somewhat ported to a remote client (costly and slow resource access, lower memory availability). We are of course talking about **Node.js**, **npm** and the **browser**.\r\n\r\nWhen talking about mobile apps we are in a slightly different environment, “Distributed Client”.\r\n\r\n×                     | Server  |   | Browser |   | Distr. Cl.\r\n--------------------- | ------- |---| ------- |---| ----------\r\n**Memory avail.**     | High    |   | Low     | = | Low\r\n**Resource access**   | Fast    |   | Slow    | ≠ | Fast\r\n**Space Constraints** | None    |   | Tight   | = | Tight\r\n**Network Access**    | Good    |   | Unknown | = | Unknown\r\n**Cross-target**      | No      |   | Yes     | = | Yes\r\n**Cross-envir.** ¹    | Yes     |   | No      | ≠ | Yes\r\n\r\nNote n. 1: I’m referring to the complete different ways to access APIs. On the server we have Window and ＊nix environments. On Distributed Clients we have to **add** the Mobile Environments"}}