Skip to content

multiple instances, errors only shown of single instance #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MichaReiser opened this issue Aug 22, 2016 · 7 comments
Closed

multiple instances, errors only shown of single instance #268

MichaReiser opened this issue Aug 22, 2016 · 7 comments

Comments

@MichaReiser
Copy link

MichaReiser commented Aug 22, 2016

Hy

I'm working on a project that targets node and the browser (using web workers). The project consists of a code base that is shared between node and the browser, and other parts that are browser, node or even web worker specific. To benefit the most from type script, multiple type script instances should be used with different libraries included (only es5, es5+dom, es5+web worker...).

Setup
I created a sample project with a similar structure in DatenMetzgerX/ts-loader-multiple-instances. Files located in src/common are es5 only and can be used by node or in the browser. At the other hand, files located in src/browser are specific for the browser environment. Different tsconfig.json files are used for each directory to configure the different libraries (es only, es + dom...). In each directory (common and browser) a single file is located that contains some trivial typescript errors (browser-defaults: a is a string, but a number is assigned, simple.js: n is a number, but a string is assigned).

The webpack configuration contains 2 configured ts-loader instances pointing todifferent tsconfig.json's and are distinguished by their name.

Actual Result
If webpack is executed, only errors of one of the ts-loader instances are shown in detail:

[micha@mbp ~/git/ts-loader-mutliple-instances (master)]$ webpack
ts-loader: Using [email protected] and /Users/micha/git/ts-loader-mutliple-instances/src/common/tsconfig.json
ts-loader: Using [email protected] and /Users/micha/git/ts-loader-mutliple-instances/src/browser/tsconfig.json
Hash: 98e778fd3041495f122c
Version: webpack 1.13.2
Time: 1798ms
         Asset     Size  Chunks             Chunk Names
parallel-es.js  4.78 kB       0  [emitted]  main
   [0] ./src/common/simple.ts 154 bytes {0} [built] [3 errors]
   [1] ./src/browser/browser-defaults.ts 123 bytes {0} [built] [2 errors]

ERROR in ./src/browser/browser-defaults.ts
(5,7): error TS2322: Type 'number' is not assignable to type 'string'.

ERROR in ./src/browser/browser-defaults.ts
(5,7): error TS6133: 'a' is declared but never used.

But the output also shows... that simple.ts contains 3 errors, but the error details are not printed to the console (why so ever).

Expected Result
Ts-loader should also output the errors in simple.ts in detail and not only summarize the number of errors behind the asset.

ts-loader: Using [email protected] and /Users/micha/git/ts-loader-mutliple-instances/src/common/tsconfig.json
Hash: 80d550dad79efdd5ca47
Version: webpack 1.13.2
Time: 759ms
         Asset     Size  Chunks             Chunk Names
parallel-es.js  4.78 kB       0  [emitted]  main
   [0] ./src/common/simple.ts 154 bytes {0} [built] [3 errors]
   [1] ./src/browser/browser-defaults.ts 123 bytes {0} [built] [2 errors]

ERROR in ./src/browser/browser-defaults.ts
(5,7): error TS2322: Type 'number' is not assignable to type 'string'.

ERROR in ./src/browser/browser-defaults.ts
(5,7): error TS6133: 'a' is declared but never used.

ERROR in ./src/common/simple.ts
(3,7): error TS2322: Type 'string' is not assignable to type 'number'.

ERROR in ./src/common/simple.ts
(3,7): error TS6133: 'n' is declared but never used.

ERROR in ./src/common/simple.ts
(4,7): error TS6133: 'x' is declared but never used.
MichaReiser pushed a commit to MichaReiser/ts-loader that referenced this issue Aug 22, 2016
If multipe typescript instances are used, then the errors of only
one instance are outputted to the console. The error has been caused by
the removeTSLoaderErrors function that removes the errors for all
instances, therefore, only the errors of the last instance are left in
the errors array. This is fixed by including the instance name in the
loaderSource and refining removeTSLoaderErrors to only remove errors of
the same instance.

Fixes TypeStrong#268
@AlexeyMz
Copy link

I'm currently having the same issue.

@jbrantly is there any obstacle to merge #269 ?

@johnnyreilly
Copy link
Member

Related to #54

@johnnyreilly
Copy link
Member

Hi @DatenMetzgerX

Sorry about the delay in responding.
I've just given ts-loader a good refactor. The code is essentially the same as it was before, just modularised and slightly more efficient. We'd really like to take your PR if you'd be willing to reapply it to the new codebase. If that's something you'd consider we can assure you of a warm reception!

@MichaReiser
Copy link
Author

@johnnyreilly

Sorry, I'm actually not using ts-loader anymore. Therefore, I'm not going to rework my PR, sorry.

@johnnyreilly
Copy link
Member

Fair enough - thanks for letting us know

@rileyjbauer
Copy link

rileyjbauer commented Aug 10, 2018

Should this option be re-opened? I'm still running into the same problem that @MichaReiser described with webpack 4.16.5 and ts-loader 4.4.2

I have two ts-loader instances for different parts of my project, each with their own tsconfig, and when I run with both instances, I just get a small message like

./test/components/test-runner.ts] 1.05 KiB {index} [built] [3 errors]

and then Compiled successfully., but when I run with a single instance, I get a all of the errors and their details and the output ends with Failed to compile.

@johnnyreilly
Copy link
Member

Feel free to open a new issue that links to this with a minimal repro repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants