when I added into tsconfig.json some outDir, the test with use your library has crashed
nskazki opened this issue · 5 comments
nskazki commented
All my tests that depend on the espower-typescript
started to crash after I've added an outDir
into my tsconfig.json
.
Small research:
mocha
loads the test file: http://i.imgur.com/w2QHaDf.pngmodule
callsespower-typescript
: http://i.imgur.com/z1wcEgo.pngespower-typescript
passes a file content but not a filename tosimple-typescript
: http://i.imgur.com/9fiUsnM.pngsimple-typescript
incorrectly identifies the filename of the given content: http://i.imgur.com/tnOaDOX.png & http://i.imgur.com/hSYeFRc.png- because of that the computed name http://i.imgur.com/TCwm24d.png doesn't match the default name http://i.imgur.com/tyF1WLA.png
- because of that
file
becomesundefined
http://i.imgur.com/mtFBOcd.png and the process crashes http://i.imgur.com/sbXdNvw.png
The filename should have been passed alongside the file content to solve this problem.
nskazki commented
nskazki commented
I won't make a PR because I'm not confident enough but this works for me:
function loadTypeScript(localModule, filepath) {
var result = tss.compile(fs.readFileSync(filepath, 'utf-8'), filepath.replace(process.cwd(), ''));
// var result = tss.compile(fs.readFileSync(filepath, 'utf-8'));
if (minimatch(filepath, pattern)) {
result = espowerSource(result, filepath, options);
}
localModule._compile(result, filepath);
};