andreypopp / andreypopp/typescript-loader

Problems in dependency resolution

Ouverte
#13 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
JavaScript
Étoiles
81
Forks
9
Métriques de merge des PR
Aucune PR mergée en 30 j

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.