andreypopp / andreypopp/typescript-loader

Problems in dependency resolution

Đang mở
#13 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
JavaScript
Star
81
Fork
9
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.