Skip to content

AoT lazy loaded chunk includes both template source and compiled template, vendor.js has no compiled template #4136

Closed
@aaronleestic

Description

@aaronleestic

OS

Mac OSX (El Capitan)

Versions.

Angular 2.4.4 / CLI Beta.24

Repro steps.

Refactored a module, 'FooModule', into another repository, and used ngc to make it into an AoT compatible library

In main application, I npm install'd my library, and imported it for use,
pages/foo/module.ts:

import { FooModule, FOO_CONFIG } from "my-component-library"
@NgModule({ 
  imports: [ FooModule ],
  providers: [ { provide: FOO_CONFIG, useValue: { title: 'hello bar' } } ]
 })
export class WrappedFooModule {}

routes.ts:

... { path: 'foo', loadChildren: 'pages/foo/module#WrappedFooModule' } ...

The log given by the failure.

Examining foo.chunk.js, I can see my entire template source:

template: '<div><h1>Foo component</h1><*ngIf="bar">...</div>'

But I also see the AoT pre-compiled code:

... this.renderer.createText(this._el_6, "Foo component", null)) ... 

This was not the case prior to the refactoring. Prior, the same chunk only had AoT compiled code.

Also, I refactored some components that are not lazy loaded at all. Prior, these eager components were in the main.bundle.js, only as aot-compiled code. After refactoring, these eager components are in vendor.bundle.js (as expected), but only as a template-source.

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfultype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions