-
Notifications
You must be signed in to change notification settings - Fork 44
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
Ahead of Time (AoT) compile doesn't work with PolymerElement in declarations #86
Comments
Hello, Same problem here: Error: Error encountered resolving symbol values statically. Calling function 'PolymerElement', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function Any solution? Thanks |
It would be really good to know if there is an alternative that will be provided |
I get the same message like @DanielGarciaMandillo |
I spent the last couple of days playing with this, and the only way that I could come up with was to generate source code for each element ahead of time. For instance, write a base class that looks something like this:
} And then add an implementation for each element, along these lines: @directive({
} I did this for all of the elements in my project, and they all seem to work, but it's definitely a hassle. I don't know of a cleaner way to manage it at this point though. |
@dcoblentz Had a similar thought but didn't want to go down that route. Awesome work on your part. If this is the only way to achieve this for now, what do you think about creating a separate repo and sharing the definitions that you have and we could collaborate to bring all paperElements into it |
I think AoT is essential with Angular 2. |
@istvanszoboszlai
So yes, please continue this. At least until Material 2 will maybe become mature. |
One thing to note about dcoblentz solution, it does enable two way data binding. But, it will require shadow dom fully enabled if you want to use components with content/slot.
Won't work, because of the Polymer.dom dependency on web components with shady dom (As far as I saw, it won't be required on Polymer 2 as it uses dom functions directly). Angular2-Polymer solves this with the classes PolymerShadyDomAdapter: Or, have you find any solution that doesn't require that class or shadow dom fully enabled? |
@rstpv I believe we could still continue to use a combination of both. The solution provided by @dcoblentz makes the directive declarations for each component static(which is required for AOT to work). We could still use the PolymerShadyDomAdapter provided by angular2-polymer as it is not directly linked to the creation of the directives but rather sets the Root DOM Adapter. |
This is pretty rough, but here's a gist with the code I wrote, it's all pretty rough still, but I copied the output from my browser console to a new ts file, but it would of course be better to turn it into a cli tool that can generate each file directly. https://gist.github.com/dcoblentz/b16e97bc5671a8c31ab65add8c88b041 |
We’re going to do a quick round of prototyping (2d timebox) to get a better understanding about this, what would be a viable fix for this issue. |
Best news today so far :) |
@dcoblentz, this is really awesome what you did. I do not get the whole process, however. How do you generate output.ts? Can this be applied to vaadin polymer elements, too? |
We finished our research. Highlights below. Currently #104 is prioritized as the next fix in the future, but after that AoT support will probably be the next one. ETA 2017Q1. ProblemWhen following the Angular’s AoT guide (https://angular.io/docs/ts/latest/cookbook/aot-compiler.html) the development with angular2-polymer will fail when trying to compile the application. Cause of ProblemFeature in Angular: https://github.com/angular/angular/blob/491d5a22a9dc1082e80aa5ca481aa02b49b9bfe8/modules/%40angular/compiler/src/aot/static_reflector.ts#L695 Possible Solutions
|
if some one needs, I used polymer-element.ts to implement a class for directives generation, it is not a CLI-tool, but generates directives for a component, I hope helps you: polymer-directive-generator.ts app.component.ts app.component.html app.component.css app.module.ts (example) |
@axtlotic Could this be used to create a pre-built public package for all elements? |
Any ideas when this will be fixed? |
@mpartipilo thanks, if this is possible, I would have to install all the elements in my project and modify it to generate the directives, I hope to get the complete list of elements and give me some time to do it |
@axtlotic Thanks for the generator. chunk {0} main.bundle.js, main.bundle.map (main) 26.1 kB {2} [initial] [rendered] ERROR in ./src/app/app.component.ts ERROR in ./src/app/app.component.ts what have I missed? import { BrowserModule } from '@angular/platform-browser';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { PolymerElement } from '@vaadin/angular2-polymer';
import { AppComponent } from './app.component';
import { PaperInput } from './paper-input-directives';
import { VaadinComboBox } from './vaadin-combo-box-directives';
@NgModule({
declarations: [
AppComponent,
PaperInput,
VaadinComboBox
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
entryComponents: [AppComponent],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule { } and my **component ** import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
})
export class AppComponent {
title = 'app works!';
myLabel = 'Select a number';
myValue = '4';
myItems = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
} and my template <h1>{{title}}</h1>
<h2>{{title}}</h2>
<vaadin-combo-box [label]="myLabel" [(value)]="myValue" [items]="myItems"></vaadin-combo-box>
<paper-input [(value)]="myValue"></paper-input> |
@axtlotic ok that was a path mistake thank you for your generator , it's good enough for me now. |
How to use this generator? How to implement this solution? |
@tomaszcysewski I created a generator project in Github here: There is still something need to be adjusted in vaadin-date-picker and vaadin-grid while other paper-xxx works well. |
Those are most used elements I think. I want to install this in order to use vaadin-grid. Let's make a request for this adjusting, who develop this generator generally? |
Unfortunately it is not working every time. If I am using a paper-dialog which has a vaadin-date-picker the dialog will not open. And I have some problems with paper-input in the paper-dialog. They do not show their actual value. Do you may have some suggestions? |
AOT is available (but first you should generated static directives). sounds like I have done twice AOT compile, One for Polymer, One for Angular... |
@hydraslay thanks for sharing your solution. Yeah, looks like we can’t avoid some generation step for Polymer in general. My idea on this — to try making a nicer generator using the I would avoid publishing the generated directives, however, because then updating them for all the changes in all the elements is likely to turn into a big maintenance problem. |
When using PolymerElement function inside the @NgModule, the AoT compiles complains with the following message:
Solutions to this error message have been provided in:
angular issue#10789
But almost all use the useFactory attribute as a workaround, but, declarations don't have such a feature.
The text was updated successfully, but these errors were encountered: