Titanium: require a module inside a commonjs module

Here’s a blog post from Appcelerator talking about CommonJS modules: developer.appcelerator.com/blog/2011/12/commonjs-module-guide-for-1-8.html

And here’s the guide / documentation from Appcelerator: wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium

Right now, all module references are relative to the application root:

  • in app.js, require(‘main’);
  • in main.js, require(‘ui/CommonView’)
  • in CommonView.js, require(‘ui/SpecificView’)

And packaged CommonJS modules (such as ti.cloud, installed in the “modules” directory of your application or Application Support) only support a single JavaScript file.

Hint: I found these guides by just typing “Appcelerator CommonJS” in to Google. I’m not sure what method you used to find the documentation. “require” is also documented extensively in the “Global” object in the Titanium Mobile documentation:
docs.appcelerator.com/titanium/2.1/index.html#!/api/Global

Read more here: Source link