angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.73k stars 11.98k forks source link

compiler fails on simplest of generated apps (with windows 10 junctions) #8603

Closed bealtine closed 5 years ago

bealtine commented 6 years ago

Versions

Angular CLI: 1.5.3
Node: 6.11.3
OS: win32 x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.3
@angular-devkit/build-optimizer: 0.0.33
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.36
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.3
@schematics/angular: 0.1.5
typescript: 2.6.1
webpack: 3.8.1

Repro steps

using the most basic ng cli, using a "local dir" for "common files"works perfectly, however if I switch to a windows junction (with the same name and exactly the same files) compilation fails with:

Observed behavior

D:\web\angular4\teststuff\test-cli>ng build
Date: 2017-11-22T19:06:43.880Z
Hash: 68750acea9ebd39ab42b
Time: 4174ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 8.51 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 200 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.3 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 1.92 MB [initial] [rendered]

ERROR in D:/web/tslibs5/tlibs.module.ts
Module build failed: Error: D:\web\tslibs5\tlibs.module.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
    at AngularCompilerPlugin.getCompiledFile (D:\web\angular4\teststuff\test-cli\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:619:23)
    at plugin.done.then (D:\web\angular4\teststuff\test-cli\node_modules\@ngtools\webpack\src\loader.js:467:39)
 @ ./src/app/app.module.ts 10:0-50
 @ ./src/main.ts
 @ multi ./src/main.ts

Desired behavior

What did you expect to see?

compiler to finish compilation...

test-cli.zip

Always happy to provide as much information as required...

zohar1000 commented 6 years ago

glad I've found this thread, I have the same error message and I would never thought it's the windows junction issue. for me as well - if I copy the junction folder to a local folder and work with it then the above error is gone. I'm on windows 7.

On previous projects that I worked with junction folders this problem didn't happen. I used to work with angular 4 without angular cli. I now started a new angular 5 project with angular cli by issuing 'new new ..' and added the source files from the angular 4 project just to end up with this error message. so I'm not sure which fault it is, angular 5 or angular cli.

It still looks strange that the windows junction is causing this kind of a problem, as far as I understand the os handles it and this junction folder should be seen as a local folder to the referring code.

I'm waiting for a solution on this one, the junction folder has a major importance since the code within it is shared among several projects, and now that it is not synced with the other code can lead to consistency bugs. please let us know once you can find something on this one. thanks.

zohar1000 commented 6 years ago

a correction on the previous note, I use hard link and not a soft link, which is actually a junction.

filipesilva commented 6 years ago

This issue is very similar to https://github.com/angular/angular-cli/issues/5167 but then it only happened to CSS files. Here it is also happening with TS files.

zohar1000 commented 6 years ago

I've found this thread, they show how to use the --preserve-symlinks parameter, it worked for me, for example: ng serve --host 0.0.0.0 --disable-host-check --preserve-symlinks --base-href /

however, it would be better to have this parameter in angular-cli.json, it's there for ng build, but not for serve or test.

bealtine commented 6 years ago

This setup worked fine before the upgrade to the 1.6 branch though, I had used symlinks (junctions) in lots of projects. In the interim I've reverted to the 1.5 branch...

I used ng build --watch

bealtine commented 6 years ago

for anyone stumbling onto this thread in the future...

One possible solution is to add the following build entry to your .angular-cli.json defaults section

"defaults": { "build": { "preserveSymlinks": true }, "styleExt": "css", "component": {} }

As outlined here: https://stackoverflow.com/questions/48797135/missing-ts-files-due-to-npm-link/48798373#48798373

mgechev commented 5 years ago

@bealtine thanks for sharing this!

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.