-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Bug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [x] feature request (Edited to update to a feature request)
Versions.
OS
macOS Sierra 10.12.6
ng--version
@angular/cli: 1.4.1
node: 8.5.0
os: darwin x64
@angular/animations: 4.4.1
@angular/common: 4.4.1
@angular/compiler: 4.4.1
@angular/core: 4.4.1
@angular/forms: 4.4.1
@angular/http: 4.4.1
@angular/platform-browser: 4.4.1
@angular/platform-browser-dynamic: 4.4.1
@angular/router: 4.4.1
@angular/cli: 1.4.1
@angular/compiler-cli: 4.4.1
@angular/language-service: 4.4.1
typescript: 2.3.4
node --version
v8.5.0
npm --version
5.3.0
Repro steps.
Fresh install using ng new
, no added packages. Rearranged my directory structure so that my app is a subdirectory of a web directory. Reconfigured tsconfig.json
in the root so that it uses an @app
prefix for importing from the ./web/app/src
folder. Modify main.ts
to import from '@app/app.module'
instead of './src/app.module'
.
Sample repo demonstrates the issue; the README contains commands run (both non-AOT and AOT) and the two different (but related) error messages:
https://github.com/dohpaz42/aot-static-module
The log given by the failure.
Without AOT
Date: 2017-09-16T17:07:17.938Z
Hash: 46e01467dc96583bd7a2
Time: 4621ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 311 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 331 bytes {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.7 kB {inline} [initial] [rendered]
ERROR in 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 194:50 in the original .ts file), resolving symbol NgModule in /users/dohpaz42/development/paths-poc-app/node_modules/@angular/core/core.d.ts, resolving symbol AppModule in /users/dohpaz42/development/paths-poc-app/web/app/src/app.module.ts, resolving symbol AppModule in /users/dohpaz42/development/paths-poc-app/web/app/src/app.module.ts
at positionalError (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler/bundles/compiler.umd.js:25266:35)
at simplifyInContext (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler/bundles/compiler.umd.js:25109:27)
at StaticReflector.simplify (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler/bundles/compiler.umd.js:25123:13)
at StaticReflector.annotations (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler/bundles/compiler.umd.js:24553:41)
at _getNgModuleMetadata (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler-cli/src/ngtools_impl.js:138:31)
at _extractLazyRoutesFromStaticModule (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
at Object.listLazyRoutesOfModule (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:207:44)
at _donePromise.Promise.resolve.then.then.then.then.then (/Users/dohpaz42/Development/paths-poc-app/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:443:24)
at <anonymous>
With AOT
Date: 2017-09-16T17:26:00.176Z
Hash: 46e01467dc96583bd7a2
Time: 1968ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 311 bytes [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 331 bytes {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.7 kB {inline} [initial] [rendered]
ERROR in Error: Error encountered resolving symbol values statically. Calling function 'ɵmakeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /users/dohpaz42/development/aot-static-module/node_modules/@angular/core/core.d.ts, resolving symbol HashLocationStrategy in /users/dohpaz42/development/aot-static-module/node_modules/@angular/common/common.d.ts, resolving symbol HashLocationStrategy in /users/dohpaz42/development/aot-static-module/node_modules/@angular/common/common.d.ts
at syntaxError (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:1729:34)
at simplifyInContext (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:25111:23)
at StaticReflector.simplify (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:25123:13)
at StaticReflector.annotations (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:24553:41)
at NgModuleResolver.resolve (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:14891:70)
at CompileMetadataResolver.getNgModuleMetadata (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:15546:60)
at addNgModule (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:24403:58)
at /Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:24414:14
at Array.forEach (<anonymous>)
at _createNgModules (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:24413:26)
at analyzeNgModules (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:24288:14)
at analyzeAndValidateNgModules (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:24298:35)
at AotCompiler.analyzeModulesAsync (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler/bundles/compiler.umd.js:23932:46)
at CodeGenerator.codegen (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler-cli/src/codegen.js:32:14)
at Function.NgTools_InternalApi_NG_2.codeGen (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/compiler-cli/src/ngtools_api.js:73:30)
at _donePromise.Promise.resolve.then (/Users/dohpaz42/Development/aot-static-module/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:386:44)
at <anonymous>
Desired functionality.
I am trying to structure my application so that I can use the @
-style references when importing local code. It works well for non-modules, but when I go to import any module defined by the @NgModule
annotation, I get the above errors. Ideally, I would expect Angular's build process to be able to compile my code regardless of how I reference imports (assuming it's set up correctly).
e.g.
// Goal
import { MyModule } from '@app/mymodule';
// vs.
import { MyModule } from '../../src/modules/mymodule';
Mention any other details that might be useful.
The .angular-cli.json
, tsconfig.json
, and tsconfig.app.json
are copied directly from the project where I discovered this problem.