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
@angular/compiler-cli - AOT failing for 'Angulartics2On' #61
Comments
package.json file : "dependencies": { |
Tks for report. I have never played with AoT. Can you provide a repo to have a look at it? |
I'm using i18n and I'm also getting an error when compiling, as the XLF extraction is using ngc under the hood. Error being:
@adave1 It seems you are not importing Angulartics module, but declaring the Angulartics2On directive. Is that true? |
When you install angulartics from npm, it only installs the .js and not the .ts files. If you manually download the .ts files and use those in your project, AOT does not complain. Not sure why the JS isn't working. Something with the decorators not being found by Typescript, perhaps? |
I am also having issues with the AOT compiler. I haven't figured out a workaround yet either. I get the same error as @rolandoldengarm. I simply followed the directions under the 'Include it in your application' section of the readme. Using a JIT build works just fine, however, ngc is not liking the Angulartics2Module.forRoot() import for some reason. |
When exporting the library I believe you have to explicitly export some metadata for the AOT to work properly. This is why it works when just dumping the library into your own code. Here is the PR ng2-translate did to solve the issue. In one of their accompanying issues there is some explanation along with a link to a blog post detailing how to solve this in general. Angular2-moment solved it in this commit: urish/ngx-moment@f100a33 Angular2-google-maps on the other hand is also still struggling with an open issue with AOT. |
Cool @Koslun, thanks for all info. I am too busy atm hope to have some time to fix this during the weekend. I have also been following ng2-translate for these issues. |
With ng2-bingmaps I had the same issue. Just running ngc, and copying the .metadata.json to the dist folder solved the issue. Let me try if this works for angulartics2 as well. |
See my PR. In my other project it has fixed the issue, my project is now ngc compatible when I copy all the .metadata.json files :) Hopefully this can be merged soon :) @JonnyBGod |
Is there a reason the .ts files are not included in npm? Most of the other libraries I'm working with work without this change because they include the typescript. AoT is typescript only, anyway. I realize using the .metadata.json and .js files is the "proper" fix. |
@rolandoldengarm Thanks for the hint. That takes care of that error, however, now my AOT build is complaining about importing the module as an object: I started to try to rework the index.ts file mainly trying to modify the ngModule decorator to see if I can import the module with Angulartics2 as a provider to Angulartics2Module instead of calling forRoot(), but not successful so far. After making that change and running an npm run build I get unexpected value Angulartics2Module in imports. |
@austinheinrichs I can't replicate that. Are you able to post a plunkr that replicates the issue? |
Hey guys,
I created a quick AOT version of the angular2-quickstart project with Angulartics2 included. You can check it out here: https://github.com/austinheinrichs/angular2-quickstart-aot-angulartics2-test. I apologize in advance if it has a lot of extras in it, but I wanted to get this out there. Wanted to clarify: The only reason I am including this rollup issue in this issue is because rollupjs seems to be the preferred bundler for angular2 in regards to AOT. |
Not sure, @austinheinrichs , I don't have experience with rollupjs. I'm using webpack as that's being used by angular-cli and don't have issues with webpack. Does it work if you change it to (in this file) |
@rolandoldengarm I have no idea why I didn't try that. RollupJS is good with that 💯 ! Thanks for your help. |
Hey! |
I am having the same problem as @Perezmarc with AOT |
@Perezmarc @arangelp I am not using AOT in any of my projects atm. Can you provide a repo for me to work with? This would make it faster for me to deal with the problem. |
@JonnyBGod I made a repo for just that here: https://github.com/Koslun/angular-webpack2-starter/tree/minimal. It's a fork of the starter https://github.com/qdouble/angular-webpack2-starter. Using the branch If you step back one commit in the branch you will thus see that As might be obvious, I also am encountering this issue on version 1.5.0 and 1.5.1. And as with the example repo I made I get the following error: 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, resolving symbol APP_IMPORTS in /home/adam/apps/demos/angular-webpack2-starter/src/app/app.imports.ts, resolving symbol AppModule in /home/adam/apps/demos/angular-webpack2-starter/src/app/app.module.ts, resolving symbol AppModule in /home/adam/apps/demos/angular-webpack2-starter/src/app/app.module.ts
at simplifyInContext (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler-cli/src/static_reflector.js:475:23)
at StaticReflector.simplify (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler-cli/src/static_reflector.js:478:22)
at StaticReflector.annotations (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler-cli/src/static_reflector.js:60:36)
at NgModuleResolver.resolve (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:14261:46)
at CompileMetadataResolver._loadNgModuleMetadata (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:14646:45)
at CompileMetadataResolver.getUnloadedNgModuleMetadata (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:14636:23)
at addNgModule (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:12944:43)
at /home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:12957:16
at Array.forEach (native)
at _createNgModules (/home/adam/apps/demos/angular-webpack2-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:12956:28)
Compilation failed This is an error I have run into previously as I've been making my project AoT compatible. As described in the starter repo i forked in the
Meaning it is not enough to export metadata you also need to follow the above and other rules specific for AoT. Here's the rest according to that starter repo:
|
@Koslun Great thanks a lot. Will have a look at it and come up with necessary changes as soon as possible. |
Just release a new version. Please test with your own environments and let me know if you still find any issues. |
@JonnyBGod After running Thanks and great job with the quick fix! 👍 |
Thanks for the fast fix! it works |
version 1.5.2? Not working for me... I'm using it in angular2-seed (https://github.com/mgechev/angular-seed) |
@Perezmarc Just tested and works fine. app.component.ts
app.module.ts
|
My mistake, I updated all the angular2 stack and works now. Thanks again for your help. |
C:\Users\da5\Documents\local repo\UST>"./node_modules/.bin/ngc" -p \src
Error: Unexpected value 'Angulartics2On' declared by the module 'AppModule'
at C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler\bundles\compiler.umd.js:14174:33
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler\bundles\compiler.umd.js:14161:51)
at C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler\bundles\compiler.umd.js:12952:58
at Array.forEach (native)
at OfflineCompiler.analyzeModules (C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler\bundles\compiler.umd.js:12951:21)
at CodeGenerator.codegen (C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler-cli\src\codegen.js:105:47)
at codegen (C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler-cli\src\main.js:7:81)
at Object.main (C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler-cli\node_modules@angular\tsc-wrapped\src\main.js:30:16)
at Object. (C:\Users\da5\Documents\local repo\UST\node_modules@angular\compiler-cli\src\main.js:14:9)
Compilation failed
The text was updated successfully, but these errors were encountered: