@ngtools/webpack - Error encountered resolving symbol values statically
Versions.
Repro steps.
Not really repro steps, but the not-changed webpack config used to work with [email protected] and @ngtools/[email protected], since upgrading I get the error described below and I have no idea what to do about it.
The log given by the failure.
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AnimationDriver in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts
ERROR in ./src/bootstrap.ts
Module not found: Error: Can't resolve './../$$_gendir/src/app/main.module.ngfactory' in '/Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/src'
@ ./src/bootstrap.ts 3:0-83
ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/$$_gendir' in '/Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/core/src/linker'
@ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
@ ./~/@angular/core/src/linker.js
@ ./~/@angular/core/src/core.js
@ ./~/@angular/core/index.js
@ ./src/bootstrap.ts
angular-cli beta-24 ng build and serve error at finish but dist directory creates:
Hash: 5e16130df6044b0b8bb7
Time: 26102ms
chunk {0} main.f9a9d29d3531b5bb577d.bundle.js, main.f9a9d29d3531b5bb577d.bundle.map (main) 18.7 kB {2} [initial] [rendered]
chunk {1} styles.4a4db805ac49f2977add.bundle.css, styles.4a4db805ac49f2977add.bundle.map, styles.4a4db805ac49f2977add.bundle.map (styles) 1.69 kB {3} [initial] [rendered]
chunk {2} vendor.721d51ad17cc097115fc.bundle.js, vendor.721d51ad17cc097115fc.bundle.map (vendor) 3.28 MB [initial] [rendered]
chunk {3} inline.3ee6c85492759d2c86ad.bundle.js, inline.3ee6c85492759d2c86ad.bundle.map (inline) 0 bytes [entry] [rendered]
ERROR in this.symbolResolver.getSymbolByModule is not a function
Also on ng build -prod --aot
ERROR in this.host.isSourceFile is not a function
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/alex/Dev/ng2/tour-of-heroes-angularfire2/src'
@ ./src/main.ts 4:0-74
@ multi main
ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/home/alex/Dev/ng2/tour-of-heroes-angularfire2/src/$$_gendir' in '/home/alex/Dev/ng2/tour-of-heroes-angularfire2/node_modules/@angular/core/src/linker'
@ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
@ ./~/@angular/core/src/linker.js
@ ./~/@angular/core/src/core.js
@ ./~/@angular/core/index.js
@ ./src/main.ts
@ multi main
Something similar for me after upgrading
ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 79:22 in the original .ts file), resolving symbol AUTH_PROVIDERS in C:/Xacte2/XacteUI-D/node_modules/angular2-jwt/angular2-jwt.d.ts, resolving symbol AppModule in C:/Xacte2/XacteUI-D/src/app/app.module.ts, resolving symbol AppModule in C:/Xacte2/XacteUI-D/src/app/app.module.ts
I have the same issue reported by @martinmasse with angular2-jwt after upgrading.
With ng build --aot I also get a similar error:
ERROR in Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 7:12 in the original .ts file), resolving symbol Ng2BootstrapConfig in /foo/node_modules/ng2-bootstrap/components/ng2-bootstrap-config.d.ts, resolving symbol TypeaheadContainerComponent in /foo/node_modules/ng2-bootstrap/components/typeahead/typeahead-container.component.d.ts, resolving symbol TypeaheadContainerComponent in /foo/node_modules/ng2-bootstrap/components/typeahead/typeahead-container.component.d.ts
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/i18n/app/app.module.ngfactory' in '/foo/src'
@ ./src/main.ts 4:0-73
@ multi main
ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/foo/src/app/i18n' in '/foo/node_modules/@angular/core/src/linker'
@ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
@ ./~/@angular/core/src/linker.js
@ ./~/@angular/core/src/core.js
@ ./~/@angular/core/index.js
@ ./src/main.ts
@ multi main
I'm getting this error too.
same issue https://github.com/PointInside/ng2-toastr/issues/109 also happens with ng2-google maps and other libs... the good news, at least this version works as 1.22 was no good! regards
Had the same issue using angular 2.1.2 and angular-cli 1.0.0-beta.1
I upgraded to angular 2.4.0 and angular-cli 1.0.0-beta.4
After fixing some templateUrl and styleUrls that no longer worked (relative urls have to start with ./ now) everything works again
my error is:
chunk {0} main.bundle.js, 0.a8cf7fdcc46f9bd210ec.hot-update.js, main.bundle.map, main.bundle.map (main) 1.16 MB {3} [initial] [rendered]
chunk {1} styles.bundle.css, styles.bundle.map, styles.bundle.map (styles) 324 kB {4} [initial]
chunk {2} scripts.bundle.js, scripts.bundle.map (scripts) 232 kB {4} [initial]
chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 6.34 MB [initial]
chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
ERROR in Error encountered resolving symbol values statically. Calling function 'ToastOptions', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AppModule in C:/msweb/studioDashboard/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/studioDashboard/src/app/app.module.ts, resolving symbol AppModule in C:/msweb/studioDashboard/src/app/app.module.ts
latest everything...
project: https://github.com/born2net/studioDashboard
@born2net your issues seems related to https://github.com/angular/angular/issues/11262#issuecomment-244266848
Check if you have any lambda expressions in your app.module.ts and replace them with export function
I have the same issue, error encountered resolving static symbol statically, since upgrading from beta.22 / 2.2.3 to beta.24 / 2.4.0
@ajantsch You're trying to compile test files. Try to exclude spec files and test.ts from your tsconfig.json file. If you're using the CLI we do that for you.
@Codenator81 if this.host.isSourceFile is a function and should be working with AOT, please file a separate issue with a project we can look at. New issues that are solved always contain project that we test against to avoid regressions in the future, so they really really help.
@martinmasse @mgarcs angular2-jwt does not seem to be compatible with Angular > 2.3.x. https://unpkg.com/[email protected]/ they didn't publish metadata. I reported this to our relation team and they'll contact them.
@aaronleeucla please provide a reproduction project we can look at. This is not helpful. Please file a separate issue with a project we can look at. New issues that are solved always contain project that we test against to avoid regressions in the future, so they really really help.
Closing this issue; the original issue is a configuration issue on the part of the creator and I gave him a fix.
the issue is deeper as you can see here: https://github.com/PointInside/ng2-toastr/issues/109#issuecomment-268609244 it appears to happen anytime you call forRoot (or method on module)
NgReduxModule.forRoot()
please open bug or reference a diff one. even using the popular angular 2 google maps results in same issue: https://github.com/SebastianM/angular2-google-maps
error:
@hansl spec files should be excluded by my webpack config:
{
test: /\.(ts|tsx)$/,
exclude: [isTest ? /\.(e2e)\.(ts|tsx)$/ : /\.(spec|e2e)\.(ts|tsx)$/],
loaders: isProd ? ['@ngtools/webpack'] : [{loader: 'awesome-typescript-loader', query: awesomeTypescriptLoaderOptions}, 'angular2-template-loader']
},
isTest and isProd are set based on the npm command used, in the case mentioned isTest is false and isProd is true.
edit: My AotPlugin config is also pretty straight forward:
new AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: './src/app/main.module#MainModule'
}),
@ajantsch you need to exclude them from the tsconfig as well. We use the tsconfig for analyzing your code statically.
@hansl I tried this now, have excluded *.spec.ts files in my tsconfig, but the error stays the same.
@ajantsch did you exclude test.ts?
The error you're seeing is this (from your own log):
ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol AnimationDriver in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/src/dom/animation_driver.d.ts, resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts, resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts
The last part (copied here):
resolving symbol BrowserTestingModule in /Users/ajantsch/Dropbox/Projects/22_9Cookies/transmission-web-client/webkick/node_modules/@angular/platform-browser/testing/browser.d.ts
Is trying to resolve BrowserTestingModule, which should only be used in tests. If you're using that module in your own code then you shouldn't. The most likely explanation is you still have some test code in your build.
@hansl that was actually true, I forgot to exclude the karma-main.ts. Now I'm down to only one more error:
ERROR in Could not resolve "./src/app/main.module" from "./src/app/main.module".
```
Me too... working with angular-cli is being so painful..
Could not resolve "app/+home/home.module" from "/src/app/app.module.ts".