Skip to content

Component inside another component is not rendered using webpack CLI production packaging #1722

Closed
@nhenneaux

Description

@nhenneaux

Hi,

When I include a component in another component, the ng serve command renders the sub-component while ng serve --prod does not render it. The same problem occurs when using the bundle created by command ng build --prod.

  1. OS? Windows 7
  2. Versions.
    (node:4412) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
    angular-cli: 1.0.0-beta.11-webpack.2
    node: 6.3.1
    os: win32 x64
  3. how to reproduce ?
    The Angular CLI base application (using ng new) can be used with the following changes.

Change app.component.ts with the following content.

import { Component } from '@angular/core';
import { SubComponent } from './sub.component';

@Component({
directives: [
        SubComponent
    ],
  selector: 'app-root',
  template: `
<h1>
  {{title}}
</h1>
<sub></sub>`
})
export class AppComponent {
  title = 'app works!';
}

Create a new file sub.component.ts with the following content.

import { Component } from '@angular/core';

@Component({
  selector: 'sub',
 template: '<div>This is not render using --prod flag</div>'
})
export class SubComponent {
}

Then run ng serve and then ng serve --prod, the first one render SubComponent while the second one does not render it.
I have created a GitHub repository with the file to reproduce (here).

I tried to ask if I am missing something on stackoverflow but it seems it is a problem with cli ?

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