andreypopp / andreypopp/typescript-loader

Problems in dependency resolution

Aperta
#13 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
JavaScript
Stelle
81
Fork
9
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.