andreypopp / andreypopp/typescript-loader

Problems in dependency resolution

オープン
#13 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
JavaScript
スター
81
フォーク
9
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。