Skip to content

In latest angular-cli: 1.0.0-beta.22 getting exceptions.... #3384

Closed

Description

@born2net

In latest angular-cli: 1.0.0-beta.22 getting exceptions....

$ ng serve
** NG Live Development Server is running on http://localhost:4200. **
  0% compilingError encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 41:36 in the original .ts file), resolving symbol providing in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts
Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 41:36 in the original .ts file), resolving symbol providing in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts
    at positionalError (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:595:18)
    at simplifyInContext (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:473:27)
    at StaticReflector.simplify (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:478:22)
    at StaticReflector.annotations (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:60:36)
    at NgModuleResolver.resolve (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:14261:46)
    at CompileMetadataResolver._loadNgModuleMetadata (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:14646:45)
    at CompileMetadataResolver.getUnloadedNgModuleMetadata (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:14636:23)
    at addNgModule (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12944:43)
    at C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12957:16
    at Array.forEach (native)
    at _createNgModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12956:28)
    at analyzeNgModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12700:16)
    at analyzeAndValidateNgModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12704:20)
    at OfflineCompiler.compileModules (C:\msweb\msbarcode\node_modules\@angular\compiler\bundles\compiler.umd.js:12775:20)
    at CodeGenerator.codegen (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\codegen.js:58:30)
    at AotPlugin._make (C:\msweb\msbarcode\node_modules\@ngtools\webpack\src\plugin.js:193:43)
    at Compiler.<anonymous> (C:\msweb\msbarcode\node_modules\@ngtools\webpack\src\plugin.js:157:75)
    at Compiler.applyPluginsParallel (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:156:14)
    at Compiler.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:463:8)
    at Compiler.applyPluginsAsync (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:73:70)
    at Compiler.compile (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:456:7)
    at Watching.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:46:17)
    at next (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:81:11)
    at Compiler.invalidAsyncPlugin (C:\msweb\msbarcode\node_modules\webpack-dev-middleware\middleware.js:119:3)
    at next (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:83:14)
    at Compiler.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\CachePlugin.js:31:4)
    at Compiler.applyPluginsAsync (C:\msweb\msbarcode\node_modules\tapable\lib\Tapable.js:85:13)
    at Watching._go (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:44:16)
    at Watching.<anonymous> (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:36:8)
    at Compiler.readRecords (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:367:10)
    at new Watching (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:33:16)
    at Compiler.watch (C:\msweb\msbarcode\node_modules\webpack\lib\Compiler.js:204:17)
    at module.exports (C:\msweb\msbarcode\node_modules\webpack-dev-middleware\middleware.js:146:27)
    at new Server (C:\msweb\msbarcode\node_modules\webpack-dev-server\lib\Server.js:43:20)
    at Class.run (C:\msweb\msbarcode\node_modules\angular-cli\tasks\serve-webpack.js:85:22)
    at C:\msweb\msbarcode\node_modules\angular-cli\commands\serve.js:102:26
    at process._tickCallback (internal/process/next_tick.js:103:7)

As you can see I have a simple providing array which causes the problem (works fine in ng cli beta .21)

export var providing = [{
    provide: AppStore, useFactory: (ngRedux: NgRedux<any>, devTools: DevToolsExtension) => {
        const reducers = combineReducers({notify, sample_reducer});
        const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware);
        const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
        const enhancers: any = compose(middlewareEnhancer, applyDevTools);
        const store = createStore(reducers, enhancers);
        ngRedux.provideStore(store);
        return new AppStore(store);
    }, deps: [NgRedux, DevToolsExtension]
}, {
    provide: "OFFLINE_ENV",
    useValue: false
}, {
    provide: SampleActions,
    useClass: SampleActions
}];

@NgModule({
    declarations: [
        AppComponent,
        // MyComp
    ],
    imports: [
        BrowserModule,
        FormsModule,
        HttpModule,
        // MsLibModule.forRoot(),
        // NgReduxModule.forRoot(), //toggle
        MaterialModule.forRoot()
    ],
    providers: [providing],
    bootstrap: [AppComponent]
})

so ng cli is not happy about the fact I am running a factory with functions (which is the proper way of setting up Redux). If I remove the entire providing function, .22 passes the ng serve, but again, have to do it in order to bootstrap Redux.

You can take a look at the very small project at:
https://github.com/born2net/msbarcode/tree/hmr

will be happy to help test as I'd like to get hmr running which requires .22.

regards,

Sean

Activity

  1. slubowsky commented on Dec 4, 2016

    @slubowsky

    Almost certainly due to AOT. See #3354

  2. clydin commented on Dec 4, 2016

    @clydin
    Member

    Try extracting the lambda into a separate function for the provider factory.

  3. born2net commented on Dec 4, 2016

    @born2net
    Author

    tried this with same results:

    export var fac = (ngRedux: NgRedux<any>, devTools: DevToolsExtension) => {
        const reducers = combineReducers({notify, sample_reducer});
        const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware);
        const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
        const enhancers: any = compose(middlewareEnhancer, applyDevTools);
        const store = createStore(reducers, enhancers);
        ngRedux.provideStore(store);
        return new AppStore(store);
    }
    
    export var providing = [{
        provide: AppStore, useFactory: fac, deps: [NgRedux, DevToolsExtension]
    }, {
        provide: "OFFLINE_ENV",
        useValue: false
    }, {
        provide: SampleActions,
        useClass: SampleActions
    }];
    

    anyway to disable AOT for now so I can focus on hrm testing?

  4. born2net commented on Dec 4, 2016

    @born2net
    Author

    this is the error:

    root@DESKTOP-VEUHFOL /cygdrive/c/msweb/msbarcode
    $ ng serve
    ** NG Live Development Server is running on http://localhost:4200. **
      0% compilingError encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 40:18 in the original .ts file), resolving symbol fac in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol providing in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts
    Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 40:18 in the original .ts file), resolving symbol fac in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol providing in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/msbarcode/src/app/app.module.ts
        at positionalError (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:595:18)
        at simplifyInContext (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:473:27)
        at StaticReflector.simplify (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:478:22)
        at StaticReflector.annotations (C:\msweb\msbarcode\node_modules\@angular\compiler-cli\src\static_reflector.js:60:36)
    
  5. beeman commented on Dec 5, 2016

    @beeman
    Contributor

    @born2net ran into the same issue trying to get @ngrx/store working.

    This fixed it for me: ngrx/store#190 (comment)

  6. ruggedy commented on Dec 5, 2016

    @ruggedy

    @beeman Is there a way to make dev tools and store log monitor work with AOT?

    Thanks

  7. born2net commented on Dec 5, 2016

    @born2net
    Author

    I tried to modify my code as follows with no luck:

    var fac = (ngRedux: NgRedux<any>, devTools: DevToolsExtension) => {
        const reducers = combineReducers({notify, sample_reducer});
        const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware);
        const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
        const enhancers: any = compose(middlewareEnhancer, applyDevTools);
        const store = createStore(reducers, enhancers);
        ngRedux.provideStore(store);
        return new AppStore(store);
    }
    
    export var providing = [{
        provide: AppStore, useFactory: fac, deps: [NgRedux, DevToolsExtension]
    }, {
        provide: "OFFLINE_ENV",
        useValue: false
    }, {
        provide: SampleActions,
        useClass: SampleActions
    }];
    

    any ideas?

    regards

    Sean

  8. ruggedy commented on Dec 5, 2016

    @ruggedy

    @born2net have you tried making the var "fac" into an untyped funciont rathar than a var .... eg

    function fac (ngRedux, devTools) {
    .....
    ...........
    ....
    }
    

    that might work

  9. born2net commented on Dec 5, 2016

    @born2net
    Author

    I haven't gotten that far to trying and getting the dev tools work...
    regards

  10. born2net commented on Dec 5, 2016

    @born2net
    Author

    ya same error:

    function fac (ngRedux, devTools) {
        const reducers = combineReducers({notify, sample_reducer});
        const middlewareEnhancer = applyMiddleware(<any>thunkMiddleware);
        const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
        const enhancers: any = compose(middlewareEnhancer, applyDevTools);
        const store = createStore(reducers, enhancers);
        ngRedux.provideStore(store);
        return new AppStore(store);
    }
    
    export var providing = [{
        provide: AppStore, useFactory: fac, deps: [NgRedux, DevToolsExtension]
    }, {
        provide: "OFFLINE_ENV",
        useValue: false
    }, {
        provide: SampleActions,
        useClass: SampleActions
    }];
    
  11. born2net commented on Dec 5, 2016

    @born2net
    Author

    actually that fixed it!!!! tx!!!!!!!!!!

    export function fac (ngRedux, devTools) {
        const reducers = combineReducers({notify, sample_reducer});
        const middlewareEnhancer = applyMiddleware(thunkMiddleware);
        const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
        const enhancers: any = compose(middlewareEnhancer, applyDevTools);
        const store = createStore(reducers, enhancers);
        ngRedux.provideStore(store);
        return new AppStore(store);
    }
    
    export var providing = [{
        provide: AppStore, useFactory: fac, deps: [NgRedux, DevToolsExtension]
    }, {
        provide: "OFFLINE_ENV",
        useValue: false
    }, {
        provide: SampleActions,
        useClass: SampleActions
    }];
    
  12. born2net commented on Dec 5, 2016

    @born2net
    Author

    and no, dev tools is not working :(
    seems like AOT is still in very early stages...

  13. born2net commented on Dec 5, 2016

    @born2net
    Author

    the issue seems to be that while it is compiling now, it's not running my fac function

    export function fac (ngRedux, devTools) {
        alert('111')
        const reducers = combineReducers({notify, sample_reducer});
        const middlewareEnhancer = applyMiddleware(thunkMiddleware);
        const applyDevTools = () => devTools.isEnabled() ? devTools.enhancer : f => f;
        const enhancers: any = compose(middlewareEnhancer, applyDevTools);
        const store = createStore(reducers, enhancers);
        ngRedux.provideStore(store);
        return new AppStore(store);
    }
    
    export var providing = [{
        provide: AppStore, useFactory: fac, deps: [NgRedux, DevToolsExtension]
    }, {
        provide: "OFFLINE_ENV",
        useValue: false
    }, {
        provide: SampleActions,
        useClass: SampleActions
    }];
    
  14. born2net commented on Dec 5, 2016

    @born2net
    Author

    @beeman
    Do you know of any way to run ng cli experiential in JIT mode instead of AOT?

  15. ruggedy commented on Dec 5, 2016

    @ruggedy

    maybe try changing useFactory: fac => useFactory: fac()

    just a thought as you are not actually running the function.

  16. 5 remaining items

  17. hansl commented on Dec 6, 2016

    @hansl
    Contributor

    Okay I cloned your repo and checked out the hmr branch.

    Putting back the MsLibModule in your app results in Error encountered resolving symbol values statically.. I checked the MsLibModule and it doesn't have a metadata.json file, so it's not compatible with the CLI. We will contact them and have them try to deploy the proper files on npm.

    Closing this as working as intended.

  18. born2net commented on Dec 6, 2016

    @born2net
    Author

    ok but let just make sure we are on the same page.
    MsLibModule is my module and NgReduxModule is Redux.
    Redux now seems fine for me on .22 (not sure what changed but now it works).
    My own MsLibModule gets the cli to hang (but works fine .21)...

  19. hansl commented on Dec 6, 2016

    @hansl
    Contributor

    We don't use static analysis in .21 to get your lazy routes, and because of that we were missing some routes. Both options have pros and cons, but we will not move back to reading your TS. External dependencies can define lazy routes and we were missing those.

    I just checked and didn't know it was your library. In order to build metadata files you need to install @angular/tsc-wrapped and run ./node_modules/.bin/ngc with the same arguments you would your typescript compiler.

    If you need further help, let us know.

  20. hansl commented on Dec 6, 2016

    @hansl
    Contributor

    BTW, it doesn't hang locally. You might have something wrong in your node_modules.

  21. born2net commented on Dec 6, 2016

    @born2net
    Author

    ok but I don't use lazy loading...
    so if I understand correctly there is a major change between .21 and .22 that is causing this?
    if you can provide me more info (or command to run since you cloned my project now) I would greatly appreciate it. Also, once all is working I will share this with the community as I am working with @beeman to get the docs corrected for proper --hmr

    so to recap, I want to be able to use .22 and uncomment the line of: MsLibModule.forRoot(), in app.modules and have it work with .22 just as it is in .21.

    tx again,

    Angular 2 Kitchen sink: http://ng2.javascriptninja.io
    and source@ https://github.com/born2net/Angular-kitchen-sink
    Regards,

    Sean

  22. born2net commented on Dec 6, 2016

    @born2net
    Author

    and you mean to run tsc-wrapped and run ./node_modules/.bin/ngc in my npm project MsLibModule?
    MsLibModule is my external npm lib project (module) which I import in.

  23. hansl commented on Dec 6, 2016

    @hansl
    Contributor

    Sorry, more info here (it's actually compiler-cli): https://angular.io/docs/ts/latest/cookbook/aot-compiler.html

    That should cover questions you have about the process. Cheers!

  24. hansl commented on Dec 6, 2016

    @hansl
    Contributor

    And yes, I mean you need to generate metadata files in your MsLibModule.

  25. hansl commented on Dec 6, 2016

    @hansl
    Contributor

    It's our best practices and our recommended way to publish Angular component libraries to also publish metadata.json files along js and d.ts files.

  26. born2net commented on Dec 6, 2016

    @born2net
    Author

    perfect tx

  27. born2net commented on Dec 6, 2016

    @born2net
    Author

    didn't have much luck with ngc.

    $ ../node_modules/.bin/ngc
    Error: Error at C:/msweb/ng-mslib/node_modules/typescript/lib/lib.d.ts:18770:11: Duplicate identifier 'ActiveXObject'.
    Error at C:/msweb/ng-mslib/node_modules/typescript/lib/lib.d.ts:18773:13: Duplicate identifier 'ActiveXObject'.
    Error at C:/msweb/ng-mslib/typings/app.d.ts:172:16: Duplicate identifier 'ActiveXObject'.
    Error at C:/msweb/ng-mslib/src/ng-mslib.ts:3:25: Cannot find module 'immutable'.
    Error at C:/msweb/ng-mslib/src/ng-mslib.ts:5:20: Cannot find module 'lodash'.
    Error at C:/msweb/ng-mslib/src/ng-mslib.ts:6:26: Cannot find module 'moment'.
    Error at C:/msweb/ng-mslib/src/ng-mslib.ts:7:28: Cannot find module 'immutable'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/di/reflective_provider.d.ts:88:123: Cannot find name 'Map'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/di/reflective_provider.d.ts:88:165: Cannot find name 'Map'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/facade/lang.d.ts:12:17: Cannot find name 'Map'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/facade/lang.d.ts:13:17: Cannot find name 'Set'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts:24:15: Cannot find name 'Map'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/change_detection/differs/default_keyvalue_differ.d.ts:28:16: Cannot find name 'Map'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/application_init.d.ts:16:18: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/linker/compiler.d.ts:53:49: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/linker/compiler.d.ts:61:65: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/rxjs/Observable.d.ts:10:66: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/rxjs/Observable.d.ts:66:60: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/rxjs/Observable.d.ts:66:70: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/application_ref.d.ts:106:67: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/application_ref.d.ts:122:101: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/application_ref.d.ts:148:67: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/application_ref.d.ts:150:101: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/linker/ng_module_factory_loader.d.ts:14:34: Cannot find name 'Promise'.
    Error at C:/msweb/ng-mslib/node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts:28:25: Cannot find name 'Pro
    

    and still same issue with latest .22-1

    hangs at 20%

    root@DESKTOP-VEUHFOL /cygdrive/c/msweb/msbarcode
    $ ng serve
    ** NG Live Development Server is running on http://localhost:4200. **
    20% building modules 85/85 modules 0 active

  28. davyvanlaere commented on Jan 2, 2017

    @davyvanlaere

    Problem seems to have disappeared in beta 24 ...

  29. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    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.

  30. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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