angular-cli: Build with --watch flag does not work with a lib project

Versions

Angular CLI: 6.0.7
Node: 9.6.1
OS: darwin x64
Angular: 6.0.3
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.6.5
@angular-devkit/build-angular      0.6.5
@angular-devkit/build-ng-packagr   0.6.5
@angular-devkit/build-optimizer    0.6.5
@angular-devkit/core               0.6.5
@angular-devkit/schematics         0.6.5
@angular/cdk                       6.1.0
@angular/cli                       6.0.7
@angular/material                  6.1.0
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.0.5
@schematics/angular                0.6.5
@schematics/update                 0.6.7
ng-packagr                         3.0.0
rxjs                               6.2.0
typescript                         2.7.2
webpack                            4.8.3

Observed behavior

Running ng build --watch works perfectly fine on the default app in a monorepo with the default app.

However, running ng build mylib --watch or ng build --watch mylib after generating a lib with the CLI gives Unknown option: '--watch'

Desired behavior

Can build any of the apps or libs in an Angular cli monorepo in --watch mode.

Mention any other details that might be useful (optional)

Have tried various combinations of ordering the arguments as well as --watch=true and -w. None seem to work.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 24
  • Comments: 15

Commits related to this issue

Most upvoted comments

It’s working for me with:

@angular-devkit/build-angular": "^0.8.1
@angular-devkit/build-ng-packagr": "^0.8.1
@angular/cli": "^6.2.1
ng-packagr": "^4.1.1

However, if I make any changes in the lib, it reloads the page twice.

So they launch a new major version of the CLI breaking one of the commands? 😂

Watch mode works for these versions 😃 @angular-devkit at 0.8.0-rc.0 @angular at 6.1.4 ng-packagr at 4.1.0

sweet!

@bezysoftware you need to update all @angular-devkit/<packages> to 0.8.0-beta.0

This should become available in Angular-CLI v6.2

On Wed, 25 Jul 2018 at 19:50, Jon notifications@github.com wrote:

Any idea on when this might be available? We are doing a lot of work with libs at the moment, no ability to watch is really rough…

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/11100#issuecomment-407839661, or mute the thread https://github.com/notifications/unsubscribe-auth/AQv-WphapVqx1FHOJi4O854VwhtAljFjks5uKK_ogaJpZM4UYh58 .

Although it’s working for --watch now, it seems that no one of the other flags are working though, f.e. --output-path or --delete-output-path when using with a library. Im using Angular CLI 6.2.2. Can anyone else confirm this?

You can use

ng update @angular/cli --next

Any idea on when this might be available? We are doing a lot of work with libs at the moment, no ability to watch is really rough…

That is a known error, if you are trying to change a file that is not part of the compilation.

https://github.com/dherges/ng-packagr/pull/1029

On Thu, 02 Aug 2018 at 14:02, Tomas Bezouska notifications@github.com wrote:

Thanks, that worked. Now first time compilation works, but the diff compilation fails:

File change detected. Starting incremental compilation…

BUILD ERROR no elements in sequence EmptyError: no elements in sequence at new EmptyError (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\util\EmptyError.js:16:28) at C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\last.js:11:294 at Object.complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\throwIfEmpty.js:12:23) at TapSubscriber._complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\tap.js:76:31) at TapSubscriber.Subscriber.complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:76:18) at TakeLastSubscriber._complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\takeLast.js:71:21) at TakeLastSubscriber.Subscriber.complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:76:18) at MergeMapSubscriber._complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\operators\mergeMap.js:80:30) at MergeMapSubscriber.Subscriber.complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:76:18) at FilterSubscriber.Subscriber._complete (C:\Users*\projects\Nexus\WidgetMessaging\node_modules\rxjs\internal\Subscriber.js:94:26)

Compilation failed. Watching for file changes…

I guess tha’ts worth a separate issue

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/11100#issuecomment-409902555, or mute the thread https://github.com/notifications/unsubscribe-auth/AQv-WgG0lBcWgK2CNHRQeZ55Fq1-AJNoks5uMupmgaJpZM4UYh58 .

I installed the latest 6.2.0 beta.0, but am still unable to do ng build --watch for a library (“unknown switch”). Here’s outcome of ng --version:

Angular CLI: 6.2.0-beta.0
Node: 8.11.3
OS: win32 x64
Angular: 6.1.0
... common, compiler, compiler-cli, core, platform-browser
... platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.7.2
@angular-devkit/build-angular      0.7.2
@angular-devkit/build-ng-packagr   0.7.2
@angular-devkit/build-optimizer    0.7.2
@angular-devkit/build-webpack      0.7.2
@angular-devkit/core               0.7.2
@angular-devkit/schematics         0.8.0-beta.0 (cli-only)
@ngtools/json-schema               1.1.0
@ngtools/webpack                   6.1.2
@schematics/angular                0.8.0-beta.0 (cli-only)
@schematics/update                 0.8.0-beta.0 (cli-only)
ng-packagr                         4.0.1
rxjs                               6.2.2
typescript                         2.9.2
webpack                            4.9.2

Whats should I do?