Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec files in subdirs included in AOT compilation #3973

Closed
mattdistefano opened this issue Jan 12, 2017 · 18 comments
Closed

Spec files in subdirs included in AOT compilation #3973

mattdistefano opened this issue Jan 12, 2017 · 18 comments

Comments

@mattdistefano
Copy link

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

@Codenator81
Copy link

@mattdistefano can you try reproduce it on updated angular-cli? now it is 1.0.0-beta.25.5

@mattdistefano
Copy link
Author

Ah man you guys are killing me - just spent the afternoon upgrading from beta 23 to beta 24.

But yeah I'll check.

@antonybudianto7
Copy link

antonybudianto7 commented Jan 13, 2017

dup related #3928

@mattdistefano
Copy link
Author

@antonybudianto7 It looks similar but this issue is specifically re. spec files in subdirectories. Also the errors we're seeing look different.

@antonybudianto7
Copy link

@mattdistefano I used @angular/router/testing module, that's why it's different, but the fact is our spec file still get compiled 😄

@mattdistefano
Copy link
Author

Can confirm this is present in beta 25.5 too:

angular-cli: 1.0.0-beta.25.5
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

@willgm
Copy link

willgm commented Jan 16, 2017

I think I was with the same issue, and after update to beta 25 it disappears.

@filipesilva
Copy link
Contributor

This is fixed at the moment but I know some older versions of the CLI were more lenient with the dependency versions.

Make sure to follow the instructions in https://github.com/angular/angular-cli#updating-angular-cli, especially the bits where you delete your local node_modules.

@mattdistefano
Copy link
Author

@filipesilva Are you saying this is fixed in beta 26?

@filipesilva
Copy link
Contributor

@mattdistefano probably even before that, but there might have been some old version of @ngtools/webpack sticking around.

@mattdistefano
Copy link
Author

Gotcha. Alright, I'll try again.

@eilensm
Copy link

eilensm commented Jan 29, 2017

Hi, have got the same problem, i.e. one of my tests (.component.spec.ts) has an import to BrowserDynamicTestingModule in order to set the entryComponents property, and keeps failing with the error message mentioned above.

The problem is still there with the current version (angular-cli: 1.0.0-beta.26).

angular-cli: 1.0.0-beta.26 node: 7.1.0 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 @angular/platform-server: 2.4.3 @angular/tsc-wrapped: 0.5.1

@mattdistefano
Copy link
Author

@filipesilva I just confirmed this issue is still present in beta 26. See https://github.com/mattdistefano/ng-cli-beta26-spec-issue

@andyrue
Copy link

andyrue commented Feb 6, 2017

I think I might be running into this too. Things were working fine in beta.22-1 but upgrading to beta.26 started producing the exact error. It's still present with beta.30 and I haven't been able to figure out why test files are being loaded. Node_modules folder has been removed when upgrading each time.

@clarenceh
Copy link

I have updated to cli 1.0.0-beta.32.3 and having the same issue too.

@filipesilva filipesilva reopened this Feb 21, 2017
@filipesilva
Copy link
Contributor

Will investigate.

@filipesilva
Copy link
Contributor

Followed your repro and got this error:

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 D:/sandbox/master-project/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in D:/sandbox/master-project/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in D:/sandbox/master-project/node_modules/@angular/platform-browser/testing/browser.d.ts

filipesilva added a commit to filipesilva/angular-cli that referenced this issue Feb 21, 2017
The `karma` entry in `.angular-cli.json` now supports an `include` property, listing the test specific files to be included in the TypeScript compilation:

```
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    },
    "include": [
      "**/*.spec.ts",
      "test.ts"
    ]
  },
```

Existing projects will default to the list abose.

This list will also be used as an exclude list for AoT Compilations.

Fix angular#3973
filipesilva added a commit to filipesilva/angular-cli that referenced this issue Feb 22, 2017
asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this issue Apr 12, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants