Skip to content

Spec files in subdirs included in AOT compilation #3973

@mattdistefano

Description

@mattdistefano

OS?

Windows 10

Versions.

angular-cli: 1.0.0-beta.24
node: 6.9.1
os: win32 x64
@angular/common: 2.4.3
@angular/compiler: 2.4.3
@angular/core: 2.4.3
@angular/forms: 2.4.3
@angular/http: 2.4.3
@angular/platform-browser: 2.4.3
@angular/platform-browser-dynamic: 2.4.3
@angular/router: 3.4.3
@angular/compiler-cli: 2.4.3

Repro steps.

  1. ng init a new app.
  2. Create a subdir under src/app and cd into it
  3. ng g c test-comp
  4. Edit the test-comp.component.spec.ts file to include import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; (This is somewhat arbitrary - I just know this particular module breaks AOT.)
  5. run ng build -prod --aot

You'll get an error (see the log).

Note that if you do this directly under src/app you won't get an error, because the spec file is correctly excluded from the AOT build.

I believe the culprit is here:

.replace(/\*/g, '(?:[^/]*)')

The single-star replacement looks like it's clobbering the previous double-star replacement so you go from **/*\.spec\.ts after line 120 to (?:.*)/*\.spec\.ts after line 122 to (?:.(?:[^/]*))/(?:[^/]*)\.spec\.ts after line 124, when you probably actually want (?:.*)/(?:[^/]*)\.spec\.ts.

The log given by the failure.

ERROR in Error encountered resolving symbol values statically. Calling function 'NoOpAnimationDriver', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AnimationDriver.NOOP in C:/wsecug it/ng-cli-beta-24/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in C:/wsecugit/ng-cli-beta-24/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in C:/wsecugit/n g-cli-beta-24/node_modules/@angular/platform-browser/testing/browser.d.ts

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