I've discovered that we can create CommonJS modules instead of native or web ones (take a look at your Titanium folder and search the ti.cloud module). But there is no documentation I can find that explains it...
So, I tried to add my own CommonJS module inside the Titanium folder "commonjs" and imported it to my application using "require". It runs like a charm.
Now, I want to add some other files to my CommonJS module and make modules referencing each other inside the module.
For example in my app I have:
- main.js
- ui
- CommonView.js
In this structure, main.js is my main module and has a method createCommonView() that tries to require the module CommonView (require('./ui/CommonView')) but the compiler complains that the module is not found.
How do I create a CommonJS module with multiple modules that reference each other?
To be precise, I don't want to copy these modules inside my project. I want to keep them in the Titanium folder so it is available to all projects.