let fs = require('fs') function embedJs(src, dst) { fs.readFile(src, 'utf8', function(err, data) { if(err) throw err; data = data.replace(/\\"/g, '\\\\"'); data = "(window)['"+src.replace(/^.*[\\\/]/, '')+"'] = `" + data + "`;"; fs.writeFile(dst, data, function(err) { if(err) throw err; }); }); } let toolsDir = __dirname; let dataDir = toolsDir + "/../data"; let srcDir = toolsDir + "/../src"; let intermediateDir = toolsDir + "/../.intermediate"; embedJs(intermediateDir+'/app.js', intermediateDir+'/app.js.ts');