Skip to content

bug(commonjs): erroneous ngfactory #7910

@CaerusKaru

Description

@CaerusKaru

Bug Report or Feature Request (mark with an x)

- [x] bug report
- [ ] feature request

Versions.

@angular/cli: 1.5.0-beta.2
node: 8.6.0
os: darwin x64
@angular/animations: 5.0.0-rc.0
@angular/cdk: 2.0.0-beta.11
@angular/common: 5.0.0-rc.0
@angular/compiler: 5.0.0-rc.0
@angular/core: 5.0.0-rc.0
@angular/forms: 5.0.0-rc.0
@angular/http: 5.0.0-rc.0
@angular/material: 2.0.0-beta.11
@angular/platform-browser: 5.0.0-rc.0
@angular/platform-browser-dynamic: 5.0.0-rc.0
@angular/platform-server: 5.0.0-rc.0
@angular/router: 5.0.0-rc.0
@angular/cli: 1.5.0-beta.2
@angular/compiler-cli: 5.0.0-rc.0
@angular/language-service: 5.0.0-rc.0
typescript: 2.5.3

Repro steps.

  1. Clone the sample repo found here
  2. Change into the cli directory
  3. Run npm install and npm run build:dynamic

To show the second type of error (detailed below):

  1. After the steps above, remove MatCardModule from app.module.ts, and remove the reference to <mat-card> in app.component.ts.
  2. Run npm run build:dynamic && npm run serve:dynamic (which should succeed this time)
  3. Navigate to localhost:4000. Disable JavaScript and reload the page
  4. Attempt to navigate to the lazy route, examine the server for the error log

To show the third type of error (detailed below):

  1. Re-enable JavaScript on localhost:4000 and reload the page
  2. Attempt to navigate to the lazy route, examine the browser console for the error log

The log given by the failure.

ERROR in ./dist/server/main.bundle.js
Module not found: Error: Can't resolve '@angular/material/card/typings/index.ngfactory' in '/Users/main/universal-cli-bug/cli/dist/server'
 @ ./dist/server/main.bundle.js 1:2433-2490
 @ ./prerender.ts

Desired functionality.

AOT compilation needs to work for commonjs bundling where the bundle includes a lazy-loaded module that also includes an external module like Angular Material.

Mention any other details that might be useful.

This is an issue only when the external module is included in a lazy-loaded module. If it's included at the top-level, it works as expected. It also works as expected in cli@1.4.4

Metadata

Metadata

Assignees

Labels

P1Impacts a large percentage of users; if a workaround exists it is partial or overly painfulseverity3: broken

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions