Configure `tns` to look in different directory for transpiled JavaScript in NativeScript build from TypeScript?


tns appears to require that TypeScript be transpiled to JavaScript files in the same source directory for its build process to work. Is it possible to configure tns to look in a different directory for its JavaScript?

I am trying to share code with another build process and keeping the transpiled JavaScript separate would be extremely useful. I can simply add an outDir property to the project’s tsconfig.json to have tsc transpile to a different output directory, but I don’t know how to point tns to this location.


TSC as you mentioned can be set to put the JS into this other folder, but TNS during its build phase has no idea about it, and last time I looked had no build in support for that.

HOWEVER, TNS has the ability to have hooks that do things during certain stages of the build process. So the only way you would be able to get TNS to point to this directory would be to create a new -hook that could copy the data out of that outDir folder into the build folder during prepare stage of building.

Nathanael A.


Do you think it’s worth filing an issue on Nativescript repo?
I’d say it’s an interesting feature that other people might want out of the box rather than having to write custom hooks.
I’d extend that to the sass plugin which also pollutes (imo) the source folder with compiled css.
The only way I found to change its output was directly in nativescript-dev-sass/lib/converter.js setting node-sass --output parameter to what I want.


We’d certainly appreciate this modification to the tns build process, which I agree in its current form “pollutes” the source directory with the compiled output. Is opening a Github Issue the avenue for making an enhancement request?


We too would very much appreciate separation of .js and .css in a TypeScript/SCSS project. Would like the app source folder to be as clean as possible for easier navigation between files.