jvandemo / generator-angular2-library

Yeoman generator to create an Angular library
MIT License
752 stars 122 forks source link

Livereload not working on components in root folder (Angular 5 & Cli 1.7) #287

Open fabriziodebortoli opened 6 years ago

fabriziodebortoli commented 6 years ago

With latest Angular Cli versions, with a npm linked library (or local library imported by "file:..." in package.json), I received the error:

ERROR in ./node_modules/yourlibrary/index.ts
Module build failed: Error: C:\linktest\linkapp\node_modules\yourlibrary\index.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
    at AngularCompilerPlugin.getCompiledFile (C:\linktest\linkapp\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:674:23)
    at plugin.done.then (C:\linktest\linkapp\node_modules\@ngtools\webpack\src\loader.js:467:39)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

webpack: Failed to compile.

solved updating tsconfig.app.json with this configuration:

"compilerOptions": {
   ...
     "paths": {
         "yourlibrary": [
             "../node_modules/yourlibrary"
         ]
     }
 },

After a ng serve, updating a component under a folder, app reload library correctly. Updating a component in src folder of library, server doesn't refresh.

My environment

Angular CLI: 1.7.3 Node: 8.9.4 OS: win32 x64 Angular: 5.2.9

RePro

I created an example repo: https://github.com/fabriziodebortoli/linklibrary.git with a new ng app and a new library generated

In linkapp folder, after a npm i, can test app with ng serve and try to update sample.component.ts or folder/sample2.component.ts