Import modules using absolute paths


#1

Hi,

Is there any way to import absolute modules? For instance today I have some imports libe this:

import { ModuleName } from './../../../module-filename'

In big projects, where you end up having many nested folder to organize a large amount of files this approach is not good, specially if you have to reorganize some files and folders.

Typescipt has the baseUrl compiler option to import modules with the absolute path. But it seems that {N} is ignoring this option.

Does anyone know if this is supported or if is there any other way of doing this?


#2

NativeScript follows Node’s Module specification, so whatever you can do there, you can do in NativeScript too.

One thing that NS has in addition is ~/ which will resolve to app/tns_modules.

Developers in this SO thread share a few good options:
http://stackoverflow.com/questions/10860244/how-to-make-the-require-in-node-js-to-be-always-relative-to-the-root-folder-of-t