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

ng serve - npm linked library changes(updates) are not reflected in UI

Open tirnovanuaurel opened this issue 9 years ago • 85 comments

Bug Report or Feature Request (mark with an x)

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

Versions.

@angular/cli: 1.0.1 node: 6.10.1 os: darwin x64 @angular/common: 4.1.1 @angular/core: 4.1.1 @angular/forms: 4.1.1 @angular/http: 4.1.1 @angular/platform-browser: 4.1.1 @angular/platform-browser-dynamic: 4.1.1 @angular/router: 4.1.1 @angular/cli: 1.0.1 @angular/compiler: 4.1.1 @angular/compiler-cli: 4.1.1

macOs Sierra 10.12.4 Node: v6.10.1 Npm: 3.10.10

Repro steps.

  • Generate 'myProject' with angular-cli
  • Add a private npm package: npm install @private/etcPackage --save (it's a angular4 library)
  • Go to the private package local path and 'npm link'
  • Go to 'myProject' and run: npm link @private/etcPackage
  • Delete 'node_modules' from 'myProject/node_modules/@private/etcPackage'
  • start serve: ng serve --aot
  • on library project, '/localpath/etcPackage' run gulp (this will trigger watch and build on change)

Since this dist folder it's linked with node_modules one in my angular project 'myProject' for every build the package is update.

The log given by the failure.

Doesn't update UI on changes.

Desired functionality.

When the library (etc - in our case) it's compiled along with it's resources, the angular-cli project should see the changes and update the UI. Eg: external html templates and css - not updated.

Mention any other details that might be useful.

  • I'm using templateUrl: 'etc.html' and not have any template inline;
  • If any change is made to componentName.ts file - this is reflected on screen (eg: variables);
  • Changes exist after library it gets build in 'myProject/node_modules/@private/etcPackage' folder, so link it's working;
  • Even if i refresh page, and I check main.bundle.js - changes are there compiled, but still are not visible on screen unless I stop serve and start it again.

--

Question is, anything can be done or need create a separate watch script to support both the library and myProject?

tirnovanuaurel avatar May 05 '17 13:05 tirnovanuaurel

Can you kindly provide the output of ng version?

alan-agius4 avatar Jan 04 '19 16:01 alan-agius4

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

Package Version

@angular-devkit/architect 0.11.4 @angular-devkit/build-angular 0.11.4 @angular-devkit/build-optimizer 0.11.4 @angular-devkit/build-webpack 0.11.4 @angular-devkit/core 7.1.4 @angular-devkit/schematics 7.1.4 @angular/cdk 7.2.0 @angular/flex-layout 7.0.0-beta.22 @angular/material 7.2.0 @ngtools/json-schema 1.1.0 @ngtools/webpack 7.1.4 @schematics/angular 7.1.4 @schematics/update 0.11.4 ng-packagr 4.4.5 rxjs 6.3.3 typescript 3.1.6 webpack 4.23.1

ToniaDemchuk avatar Jan 04 '19 18:01 ToniaDemchuk

I'm sorry, but we can't reproduce the problem.

Remember that we have a large number of issues to resolve, and have only a limited amount of time to reproduce your issue. Short, explicit instructions make it much more likely we'll be able to reproduce the problem so we can fix it.

If the problem persists, please open a new issue following our submission guidelines.

A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

alan-agius4 avatar Jan 07 '19 07:01 alan-agius4

😃 I was able to solve my issue. I'm not using any npm/yarn/lerna linked packages. Instead I'm just using tsconfig.json paths. All of my shared libraries are imported from @shared/.... The key to getting change detection working for shared libraries was to set the baseUrl and rootDir to the parent folder of my shared folder.

File Structure:

- api
- shared
- ui
  - angular.json
  - src
    - app
      - tsconfig.app.json
    - tsconfig.json

tsconfig files:

// ui/src/tsconfig.json
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "../",
    "rootDir": "../",
    "outDir": "./dist/out-tsc",
    // ...
    "paths": {
      "@ui/*": ["./ui/src/app/*"],
      "@shared/*": ["./shared/*"]
    }
  }
}

// ui/src/app/tsconfig.app.json
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app"
  },
  "include": [
    "./**/*.ts",
    "../../shared/**/*.ts"
  ],
  "exclude": [
    "test.ts",
    "**/*.spec.ts",
    "../../api/**/*.ts"
  ]
}

I'm on Angular 7.

sparebytes avatar Feb 13 '19 23:02 sparebytes

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.