Open enanox opened 7 years ago
Is it still an issue with latest updates?
All - not sure if the problem I was running into matches the problem reported here, but I was able to share typescript code among multiple projects with awesome-typescript-loader and webpack. This issue was one of the resources that I ran across in Google who were having a similar problem.
Anyway, see my Stack Overflow Q&A for more details: https://stackoverflow.com/questions/52487112/sharing-code-between-projects-using-typescript-and-webpack
Hi, I am facing a tough issue trying a few things for AoT. When I try to add an
*ngFor
reference in a template with its corresponding metadata (importingCommonModule
in theMainModule
and so) and runningnpm run start
orstart-prod
, the compilation step throws:ERROR in [at-loader] TS6059: File 'C:/Users/mathiasr/Documents/angular2-aot-webpack/node_modules/@angular/common/src/directives/ng_for.ngfactory.ts' is not under 'rootDir' 'C:/Users/mathiasr/Documents/angular2-aot-webpack/src/app'. 'rootDir' is expected to contain all source files.
hello-world.template.html
main.module.ts
I've been trying a few things and came across a workaround, which I am not sure if it's something to patch with TypeScript config,
ngc
orat-loader
.1. Adding a symlink to the "offender"
I tried to add a symlink to the missing file (which
ngc
crawls innode_modules
to generate) withln ../../node_modules/@angular/common/src/directives/ng_for.ngfactory.ts
below therootDir
(I mean,src/app
) to no avail. This was using the same scenario described above.2. Remove reference to
CommonModule
and import thengc
generatedWrapper_NgFor
fromHelloWorldComponent
Pretty much the same, it isn't able to import the directive.
3. Workaround: discard
compilerOptions.rootDir
overfiles
This is the verbose option and the strangest working one. If I remove the
compilerOptions.rootDir
property fromtsconfig.json
and add eachts
file in thefiles
array, as inEven more, if I remove the references to the
CommonModule
, it works as well. I believe it has to do with the fact that the references innode_modules
are never excluded from the compilation step, but I'm not sure.Hope this helps, I'm X-posting this issue to
at-loader
to see if there's something to do on their end. Please let me know if you need further information.