Commit e0f2406
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 60146ac commit e0f2406
1 file changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
445 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
446 | 454 | | |
447 | 455 | | |
448 | 456 | | |
| |||
514 | 522 | | |
515 | 523 | | |
516 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
517 | 532 | | |
518 | 533 | | |
519 | 534 | | |
| |||
0 commit comments