angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Changes to npm linked library are not reflected to running angular cli app

Open synctom opened this issue 9 years ago • 2 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.3 node: 8.4.0 os: darwin x64 @angular/animations: 4.4.3 @angular/common: 4.4.3 @angular/compiler: 4.4.3 @angular/core: 4.4.3 @angular/forms: 4.4.3 @angular/http: 4.4.3 @angular/platform-browser: 4.4.3 @angular/platform-browser-dynamic: 4.4.3 @angular/router: 4.4.3 @angular/cli: 1.4.3 @angular/compiler-cli: 4.4.3 @angular/language-service: 4.4.3 typescript: 2.3.4

Repro steps.

  • Generate my-project with angular-cli.
  • Clone any-lib from https://github.com/synctom/any-lib
  • Go to the any-lib package folder and npm install & npm link
  • Go to my-project and run: npm link any-lib
  • Open my-project/src/app/app.module.ts and paste this after the last import:
import { MyService } from 'any-lib';

const service: MyService = new MyService();

console.log(service.doSomething());
  • Run any-libwith npm start
  • Run my-project with ng serve
  • All good
  • Try to add a new function to MyService and try to call it in app.module.ts
  • Function could not be found, unless you stop ng serve and execute it again.

My solution so far

It's a caching issue located in a Webpack plugin that compiles the angular code.

Check @ngtools/webpack/src/plugin.js in the node_modules folder of your cli application.

Just remove or uncomment:

this._compilerHost.enableCaching();

After then, it works.

see https://github.com/angular/angular-cli/issues/6195

synctom avatar Oct 05 '17 11:10 synctom

Heya, this seems to be a duplicate of #6195 (you even linked in in your comment). I appreciate your detailed reproduction but it's much better to keep the conversation in the same thread instead of having multiple issues for the same thing.

The solution you propose is not correct. Caching is essential for rebuild performance. It would drastically slow down rebuilds.

filipesilva avatar Oct 10 '17 09:10 filipesilva

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.