Skip to content

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

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

Closed
born2net opened this issue Dec 4, 2016 · 33 comments
Closed

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

born2net opened this issue Dec 4, 2016 · 33 comments

Comments

@born2net
Copy link

born2net commented Dec 4, 2016

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

@slubowsky
Copy link

Almost certainly due to AOT. See #3354

@clydin
Copy link
Member

clydin commented Dec 4, 2016

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

@born2net
Copy link
Author

born2net commented Dec 4, 2016

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?

@born2net
Copy link
Author

born2net commented Dec 4, 2016

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)

@beeman
Copy link
Contributor

beeman commented Dec 5, 2016

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

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

@ruggedy
Copy link

ruggedy commented Dec 5, 2016

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

Thanks

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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

@ruggedy
Copy link

ruggedy commented Dec 5, 2016

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

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

that might work

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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
}];

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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
}];

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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
}];

@born2net
Copy link
Author

born2net commented Dec 5, 2016

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

@ruggedy
Copy link

ruggedy commented Dec 5, 2016

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

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

@born2net
Copy link
Author

born2net commented Dec 5, 2016

so I did that with no luck.
I actually disabled aot mode in ng serve so I get no errors, but it still doesn't actually run the fac, it's odd.

@beeman
Copy link
Contributor

beeman commented Dec 5, 2016

@beeman
Do you know of any way to run ng cli experiential in JIT mode instead of AOT?
@born2net nope, haven't played around with that yet...

@born2net
Copy link
Author

born2net commented Dec 5, 2016

I figured that one out, --aot false
but at this time I think .22 is in pretty bad shape from what I can see as a ton of stuff is causing the error of:

** 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/ap

I was able to fix the factory, but more issues with same error, so I am just going to wait until .22 gets to npm so its stable enough

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

If you aren't specifying --aot on the command line, it's going to build using JIT.

BUT, we are still using the AotPlugin to figure out the lazy loaded routes from your app. The problem is that (it seems) NgReduxModule forRoot() function is not statically analyzable. If the functions are simple, we understand them.

Look for a metadata.json file next to the one that actually declares the forRoot() method. Since we cannot statically analyze ES5 code, we need that metadata file to understand what NgReduxModule is declaring. It can actually declare lazy loaded routes, for example, and without the metadata file we wouldn't know. Since we cannot know, we throw an error.

I'm going to investigate this further and come back to you.

@born2net
Copy link
Author

born2net commented Dec 6, 2016

so some more updates, I went ahead and updated all the libs again and latest cli .22 again.
now it seems to work if I don't include my lib module via:

MsLibModule.forRoot(),

but if I do include it, ng-cli will hang on compilation:

$ ng serve --aot false
** NG Live Development Server is running on http://localhost:4200. **
 20% building modules 85/85 modules 0 active

When I switch back to ng-cli .21, all is well, so I have somewhat confidence something broke in .22
the project can be easily tested against if you have time:
https://github.com/born2net/msbarcode/tree/hmr
(note it's the hmr branch)

and so NgReduxModule forRoot() works now, but MsLibModule.forRoot() gets the ng-cli compiler to hang. I would at least expect some error but it just hangs at 20%... and again, all works great in .21.

regards

Sean.

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

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.

@hansl hansl closed this as completed Dec 6, 2016
@born2net
Copy link
Author

born2net commented Dec 6, 2016

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)...

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

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.

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

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

@born2net
Copy link
Author

born2net commented Dec 6, 2016

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

@born2net
Copy link
Author

born2net commented Dec 6, 2016

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.

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

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!

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

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

@hansl
Copy link
Contributor

hansl commented Dec 6, 2016

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.

@born2net
Copy link
Author

born2net commented Dec 6, 2016

perfect tx

@born2net
Copy link
Author

born2net commented Dec 6, 2016

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

@davyvanlaere
Copy link

Problem seems to have disappeared in beta 24 ...

@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

No branches or pull requests

7 participants