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

Created on 4 Jun 2018  Â·  15Comments  Â·  Source: angular/angular-cli

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.

blocked library feature

Most helpful comment

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.

All 15 comments

This is not supported yet. I'm eagerly awaiting for this PR to be merged in ng-packagr.

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

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...

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
.

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?

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

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

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
.

Hi @bezysoftware @alan-agius4 !
How can I install the latest 6.2.0 beta.{0,1}?
Thanks

You can use

ng update @angular/cli --next

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!

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.

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?

@arm1n I can confirm it for Angular CLI 7.0.4. Althought I didn't extensively check, it seems the only working flags are those few reported by the ng build --help command, not those described in documentation page: https://angular.io/cli/build
NOTE: I'm referring to a lib project

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngvarKofoed picture IngvarKofoed  Â·  3Comments

5amfung picture 5amfung  Â·  3Comments

rwillmer picture rwillmer  Â·  3Comments

rajjejosefsson picture rajjejosefsson  Â·  3Comments

MateenKadwaikar picture MateenKadwaikar  Â·  3Comments