andreypopp / andreypopp/typescript-loader
Problems in dependency resolution
- Dominant language
- JavaScript
- Stars
- 81
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Hello @andreypopp. Thanks for the great library! I have been using it a little and I have found several big problems. The main problem right now is that is doesn't collect all the files that TypeScript needs. Consider this code from your library:
https://github.com/andreypopp/typescript-loader/blob/master/lib/TypeScriptWebpackHost.js#L177-L193
``` typescript
TypeScriptWebpackHost.prototype._addDependencies = function(resolver, filename) {
var dependencies = this._findImportDeclarations(filename).map(function(dep) {
return this._resolve(resolver, filename, dep).then(function(filename) {
var alreadyExists = this._files[filename];
var added = this._readFileAndAdd(filename);
// This is d.ts which doesn't go through typescript-loader separately so
// we should take care of it by analyzing its dependencies here.
if (/\.d.ts$/.exec(filename) && !alreadyExists) {
added = added.then(function() {
return this._addDependencies(resolver, filename);
}.bind(this));
}
return added;
}.bind(this));
}.bind(this));
return Promise.all(dependencies);
}
```
In this function you traverse only one level of the regular (non `.d.ts`) dependencies. But to compile the file TS needs the _whole dependency tree_ to be loaded into the service.
We don't see any errors because [here](https://github.com/andreypopp/typescript-loader/blob/master/lib/TypeScriptWebpackHost.js#L212-L215) you collect only current file diagnostics, but the actual errors are **in the file deps**.
Several days ago I have forked your library to [awesome-typescript-loader](https://github.com/s-panferov/awesome-typescript-loader) and completely rewritten all the things there.
I wrote this issue because:
1. I want to warn you and your users about the problem.
2. If you want I can explain all the changes I made there so you could port them to your library if you want.
I added the info about your authorship into the README, but your project doesn't contain the LICENSE file so just say if you want me to add some additional copyright notice.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.