ts-module-ignore
v1.0.6
Published
ts-module-ignore receives a TypeScript module code and removes export keywords.
Readme
ts-module-ignore 
This receives a TypeScript module code and removes export keywords.
Why remove export?
Standalone libraries that never imports anything still wants to export itself to be available both on web browsers and on module-based system e.g. Node.js. As browsers does not natively support module syntax yet as of April 2017, ts-module-ignore achives this by simply removing export keyword to target browsers.
How to use?
Use ts-module-ignore on build tool e.g. Jake:
import ignore = require("ts-build-ignore").ignore;
desc("browser")
task("browser", async () => {
const ignored = await ignore(originalFilePath, newFilePath); // 1.
// 2. call tsc
});Note
export-ignored file will not work on Node.js anymore so you have to keep your original code.- Non-exported variables will also be exposed globally. If you don't want it you will want to wrap them by
namespace.namespace A { function foo() {} export function bar() {} } export default A; - This does not read TypeScript syntax tree but simply remove any of
exportstring that appear on the line start. You need to be careful when you use strings containingexport:var foo = ` export this! this export! `; // output will: var foo = ` this! this export! `;
