I am trying to create a javascript module by TypeScript which is compatible with ES5 browsers and NodeJs modules. So I don't want to use the import and export in TypeScrtipt because it makes the output depends on SystemJS or RequireJS or commonJs. I have just created a library with namespace and add the following code to make it compatible with SystemJs:
// global html object (pure javascript compatiblity)
if (typeof window !="undefined") (<any>window).myNamespace = myNamespace;
// create exports
declare var module:any;
if (typeof module !="undefined") module.exports = {myNamespace};
Everything is OK, I just need to add the following code so I can use the library in NodeJS modules and have propery typing information
export {myNamespace}
So I can use my library in NodeJs lib like this:
import {myNamespace} from "../lib/myNamespace.js";
But I couldn't find how to tell the TypeScript compiler to add that export without creating a module in its own way. How can I add a few lines directly at the end of generated d.ts automatically after each compile such as:
Generated typing ..
...
...
// Custom declaration
// Remark Remark
export {myNamespace}
// Remark Remark
**Note: ** The modulation is none and many things are custom, I cannot use the regular export feature of typescript modulation.