Skip to content

ng test fails to build lazy loading modules #8066

@tsangste

Description

@tsangste

Bug Report or Feature Request (mark with an x)

- [x] bug report
- [ ] feature request

Versions.

Angular CLI: 1.5.0-rc.0
Node: 8.5.0
OS: win32 x64
Angular: 5.0.0-rc.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0-rc.0
@angular-devkit/build-optimizer: 0.0.27
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.33
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.0
@schematics/angular: 0.0.45
typescript: 2.3.4
webpack: 3.7.1

Repro steps.

  • ng new apptest
  • update packages to latest pre-releases angular 5.0.0-rc.2, angluar/cli 1.5.0-rc.0 and typescript 2.4.0
  • Create a module to be lazy loaded
  • run ng test

The log given by the failure.

C:\Users\development\apptest>ng test
 10% building modules 1/1 modules 0 active16 10 2017 08:13:36.642:WARN [karma]: No captured browser, open http://localhost:9876/
16 10 2017 08:13:36.662:WARN [karma]: Port 9876 in use
16 10 2017 08:13:36.665:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9877/
16 10 2017 08:13:36.665:INFO [launcher]: Launching browser Chrome with unlimited concurrency
16 10 2017 08:13:36.690:INFO [launcher]: Starting browser Chrome                                                                                                                                                              [../../../../../src/polyfills.ts] ./src/po
lyfills.ts 299 bytes {polyfills} [built] [failed] [1 error]
   [0] multi ./src/polyfills.ts 28 bytes {polyfills} [built]
[../../../../../src/test.ts] ./src/test.ts 299 bytes {main} [built] [failed] [1 error]

ERROR in ./src/test.ts
Module build failed: Error: TypeScript compilation failed.
    at plugin.done.then (C:\Users\development\apptest\node_modules\@ngtools\webpack\src\loader.js:479:27)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

ERROR in ./src/polyfills.ts
Module build failed: Error: TypeScript compilation failed.
    at plugin.done.then (C:\Users\development\apptest\node_modules\@ngtools\webpack\src\loader.js:479:27)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
 @ multi ./src/polyfills.ts

ERROR in Error: C:/Users/development/apptest/src/app/lazy/lazy.module.ts is not part of the TypeScript compilation. Please include it in your tsconfig via the 'files' or 'include' property.
    at sourceFiles._getChangedTsFiles.map (C:\Users\development\apptest\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:517:31)
    at Array.map (<anonymous>)
    at Promise.resolve.then.then.then (C:\Users\development\apptest\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:513:63)
    at <anonymous>

Desired functionality.

Should build and run tests

Mention any other details that might be useful.

  • ng build works fine (jit + aot)
  • current workaround is changing tsconfig.spec.json include section to **/*.ts
  • works fine in angular 5 with angular-cli 1.4.7(with typescript 2.4.2) and angular 4.4.5 with angular-cli 1.5.0-rc.0 (with typescript 2.3.4)

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