I am using the simple starter angular cli example that is on the angular cli site. I created a service OUTSIDE the app folder and included it in the app module in the providers ..etc. Dont ask me why..Just imagine its a service i create that I plan to share between different angular projects. Now ng serve works but ng serve --aot breaks build. Here's the error I receive. Any ideas how to fix it? Thanks
Here is a link to my project structure
https://s3.amazonaws.com/uploads.hipchat.com/20493/94971/eVkgsEDXM8Kfzs1/upload.png
ng serve -- aot error below:
ERROR in Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider rep lacing the function or lambda with a reference to an exported function, resolving symbol Injectable in C:/ANGULAR PROJECTS/testNgCLI/node_modul es/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in C:/ANGULAR PROJECTS/testNgCLI/node_modules/@angular/core/src/di/opaque_t oken.d.ts, resolving symbol OpaqueToken in C:/ANGULAR PROJECTS/testNgCLI/node_modules/@angular/core/src/di/opaque_token.d.ts
CLI version: angular-cli: 1.0.0-beta.24 node: 7.3.0 os: win32 x64
The Angular ahead-of-time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the browser.
When you use the Angular AOT compiler, you can control your app compilation in two ways: By providing template compiler options in the tsconfig. json file. By specifying Angular metadata.
JIT downloads the compiler and compiles code exactly before Displaying in the browser. AOT has already complied with the code while building your application, so it doesn't have to compile at runtime. Loading in JIT is slower than the AOT because it needs to compile your application at runtime.
Just-in-Time (JIT) is a type of compilation that compiles your app in the browser at runtime. ng build ng serve. AOT (Ahead-of-Time Compilation) Ahead-of-Time (AOT) is a type of compilation that compiles your app at build time.
I think the problem is with the code that is inside the service. This happened to me too, and the error was the same:
Calling function 'makeDecorator', function calls are not supported. Consider rep lacing the function or lambda with a reference to an exported function
You are using some anonymous function called makeDecorator
. For the code to be ready for AoT, you need to move that to separate function and export it (also it needs to be classic function
, not =>
lamda).
You need to have something like this:
export function makeDecorator() {
// implementation...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With