Skip to content

Module Imports inconsistent on re-building via ng build --watch #16613

Description

@shawnwildermuth

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: ....

No.

Description

A clear and concise description of the problem...

🔬 Minimal Reproduction

  • Create a blank project
  • Import and Add CommonModule to the imports of the module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CommonModule } from '@angular/common';
import { FormsModule } from "@angular/forms";

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    CommonModule
  ],
  providers: [
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • Use *ngIf in a component:
    <div class="alert alert-secondary" *ngIf="message">
      {{ message}}
    </div>
  • Run ng build --watch=true --prod=false

  • See it work.

  • make any change to the project

  • Watch it fail with:

ERROR Error: "Template error: Can't bind to 'ngIf' since it isn't a known property of 'div'."
  • Stop the build and re-run it with identical parameters (ng build --watch=true --prod=false
  • Watch it work again (no code changes)

🔥 Exception or Error





ERROR Error: "Template error: Can't bind to 'ngIf' since it isn't a known property of 'div'."
    Angular 3
    AppComponent_Template app.component.html:4
    Angular 32
    ts main.ts:11
    Webpack 6
core.js:6014:19
    Angular 29
    ts main.ts:11
    Webpack 6

🌍 Your Environment





Angular CLI: 8.3.22
Node: 13.0.1
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.22
@angular-devkit/build-angular     0.803.22
@angular-devkit/build-optimizer   0.803.22
@angular-devkit/build-webpack     0.803.22
@angular-devkit/core              8.3.22
@angular-devkit/schematics        8.3.22
@angular/cli                      8.3.22
@ngtools/webpack                  8.3.22
@schematics/angular               8.3.22
@schematics/update                0.803.22
rxjs                              6.4.0
typescript                        3.5.3
webpack                           4.39.2

Anything else relevant?

Activity

  1. alan-agius4 commented on Jan 9, 2020

    @alan-agius4
    Collaborator

    Are you using ivy? Ie: when creating a new project are you using —-enableIvy?

  2. alan-agius4 commented on Jan 9, 2020

    @alan-agius4
    Collaborator

    Also there is no need for CommonModule when using BrowserModule as the latter re-exports CommonModule.

    https://github.com/angular/angular/blob/8815ace4188a77bc93caa5eb9696681a47fef10d/packages/platform-browser/src/browser.ts#L99

  3. shawnwildermuth commented on Jan 9, 2020

    @shawnwildermuth
    Author

    I don't think we're using Ivy. How could I tell, I don't recall when we created it whether we would have enabled it. I doubt it.

    I'll try to remove CommonModule, but I added it when I it complained about missing *ngIf and *ngFor

  4. shawnwildermuth commented on Jan 9, 2020

    @shawnwildermuth
    Author

    Looks like It might be an issue with using a subst drive on Win10. I'll continue to investigate but I'll close this for now.

  5. angular-automatic-lock-bot commented on Feb 9, 2020

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions