Skip to content
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

AOT compilation fails due to private properties #352

Closed
blagerweij opened this issue Dec 7, 2016 · 6 comments
Closed

AOT compilation fails due to private properties #352

blagerweij opened this issue Dec 7, 2016 · 6 comments

Comments

@blagerweij
Copy link

[x] bug report

Current behavior
When using angular2-data-table with Just in Time (JiT) compilation it works great, however when trying to use Ahead of Time (AOT) compilation, it fails during compilation.

Root cause:
The data-tables components use private properties, however these properties may be accessed from the template. The properties need to be public.

(from https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5):
3. private, protected accessors should be changed to public for any members accessed from template
Error:
Error: Error at /path/to/some.component.ngfactory.ts:134:40: Property 'context' is private and only accessible within class 'SomeComponent'.
Before:
@component({
template: <div> {{ context }} </div>
})
export class SomeComponent {
private context: any;
}

After:
@component({
template: <div> {{ context }} </div>
})
export class SomeComponent {
public context: any;
}

Expected behavior
AOT should be supported

Reproduction of the problem
run 'ngc' on your project with a specific tsconfig.aot.json

What is the motivation / use case for changing the behavior?

Please tell us about your environment:
MacOS, ngc, rollup

  • Table version: 2.1.3

  • Angular version: 2.2.3

  • Browser: all

  • Language: TypeScript 2.0

@amcdnl
Copy link
Contributor

amcdnl commented Dec 7, 2016

Is there a good tool to help do this? @ocombe - u know of anything?

@ocombe
Copy link
Contributor

ocombe commented Dec 7, 2016

A tool to help do what ? He's right, properties used in the template have to be public for AoT

@amcdnl
Copy link
Contributor

amcdnl commented Dec 7, 2016

A tool to do ensure on build AoT is working right.

@ocombe
Copy link
Contributor

ocombe commented Dec 7, 2016

I don't, but there is probably one, if you find out let me know.
Check other projects (like material components ? or ng bootstrap ?), how do they check that AoT went well

@ocombe
Copy link
Contributor

ocombe commented Dec 7, 2016

So apparently the best way to do it is to build the files, then run the tests with the builded files.

@amcdnl
Copy link
Contributor

amcdnl commented Dec 9, 2016

Plz retry on latest :)

@amcdnl amcdnl closed this as completed Dec 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants