Commit 0f771f1
fix(@ngtools/webpack): better AoTPlugin instance error
Currently, having multiple @ngtools/webpack installed yields a cryptic error in typescript:
```
ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
```
This happens because a plugin is found, but it isn't an instance of the right class. This makes the loader assume it's being ran without a plugin (just transpiling TS). Then it tries to load a missing tsconfig and the error above is shown.
This PR introduced better errors for both the wrong plugin instance and missing tsconfig.
```
ERROR in ./src/main.ts
Module build failed: Error: AotPlugin was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed.You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
at Object.ngcLoader (D:\work\cli\packages\@ngtools\webpack\src\loader.ts:371:19)
@ multi ./src/main.ts
```
```
ERROR in ./src/main.ts
Module build failed: Error: @ngtools/webpack is being used as a loader but no `tsConfigPath` option norAotPlugin was detected. You must provide at least one of these.
at Object.ngcLoader (D:\work\cli\packages\@ngtools\webpack\src\loader.ts:442:19)
@ multi ./src/main.ts
```
See #3781 (comment) and #3781 (comment) for context.1 parent ef0e08e commit 0f771f1
1 file changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
431 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
432 | 440 | | |
433 | 441 | | |
434 | 442 | | |
| |||
500 | 508 | | |
501 | 509 | | |
502 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
503 | 518 | | |
504 | 519 | | |
505 | 520 | | |
| |||
0 commit comments