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

Enable ivy in angular 8 - production build got failed #30818

Closed
kumaresan-subramani opened this issue Jun 1, 2019 · 40 comments
Closed

Enable ivy in angular 8 - production build got failed #30818

kumaresan-subramani opened this issue Jun 1, 2019 · 40 comments

Comments

@kumaresan-subramani
Copy link

🐞 Bug report

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes

Description

I have created an angular project with enabling ivy mode using below commands

ng new hello-ivy --enable-ivy

When I try to serve my application using below command

ng serve

it does not throw any compilation error but when I try to load this in browser [chrome] it throws below error:

Screenshot (259)

When i try to take prod build using below command

ng build --prod

it throws below compilation error :

Screenshot (260)

I don't know why this issue occurs

🔬 Minimal Reproduction

  1. Download below sample -
    ivySample.zip

  2. Give below command to install our third-party package

npm i @syncfusion/ej2-angular grids

Or Download this and place it inside node_modules folder

🌍 Your Environment







     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.0.1
Node: 10.16.0
OS: win32 x64
Angular: 8.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.1
@angular-devkit/build-angular     0.800.1
@angular-devkit/build-optimizer   0.800.1
@angular-devkit/build-webpack     0.800.1
@angular-devkit/core              8.0.1
@angular-devkit/schematics        8.0.1
@angular/cli                      8.0.1
@ngtools/webpack                  8.0.1
@schematics/angular               8.0.1
@schematics/update                0.800.1
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

Working fine angular 8 production build without ivy mode

@kumaresan-subramani
Copy link
Author

kumaresan-subramani commented Jun 1, 2019

HI @alan-agius4 ,

Can you check this out?

@alan-agius4
Copy link
Contributor

This seems to be related to ngtsc, @petebacondarwin / @JoostK can you chime in?

I am seeing a different error though

ERROR in node_modules/@syncfusion/ej2-angular-grids/src/grid/grid-all.module.d.ts(27,22): error TS-996002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class

which typically means that ngcc was not run properly.

@alan-agius4 alan-agius4 transferred this issue from angular/angular-cli Jun 3, 2019
@alan-agius4 alan-agius4 changed the title Enable ivy in anguuar 8 - production build got faled Enable ivy in angular 8 - production build got failed Jun 3, 2019
@petebacondarwin
Copy link
Member

I notice that you are running Angular v8.0.1. This is not the correct version for trying out IVY. You should install the next version. E.g.

yarn add @angular/compiler-cli@next
...

@kara kara added the comp: ivy label Jun 3, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jun 3, 2019
@alexzuza
Copy link
Contributor

alexzuza commented Jun 3, 2019

@petebacondarwin

Just tried it with "@angular/compiler-cli": "next", which is 8.1.0-beta.0

Seems Esm5ReflectionHost looks for "decorators" static property of function declaration inside IIFE and will never find.

ej2-angular-grids.es5.js


var GridAllModule = /** @class */ (function () {
    function GridAllModule() { <========== at this level
    }
    return GridAllModule;
}());
GridAllModule.decorators = [ 
    { type: NgModule, args: [{...

From source code

protected getDecoratorsOfSymbol(symbol: ClassSymbol): Decorator[]|null {
// The necessary info is on the inner function declaration (inside the ES5 class IIFE).
const innerFunctionSymbol =
this.getInnerFunctionSymbolFromClassDeclaration(symbol.valueDeclaration);
if (!innerFunctionSymbol) return null;
return super.getDecoratorsOfSymbol(innerFunctionSymbol);

@JoostK
Copy link
Member

JoostK commented Jun 3, 2019

@alexzuza It's known, see #30795

@vgb1993
Copy link

vgb1993 commented Jun 6, 2019

What's the status of this? I get the same error:

ERROR in Unexpected value 'PostService in C:/myAngularApp/src/app/service/posts.
component.ts' declared by the module 'AppModule in C:/myAngularApp/src/app/app.m
odule.ts'. Please add a @Pipe/@Directive/@component annotation.

@kumaresan-subramani
Copy link
Author

HI @JoostK ,

Can we get any update regarding this?

@petebacondarwin
Copy link
Member

This should be fixed in v8.1.0-rc.0 - @kumaresan-subramani can you check?

@kumaresan-subramani
Copy link
Author

HI @petebacondarwin , When should i expect this release?

@JoostK
Copy link
Member

JoostK commented Jul 1, 2019

@kumaresan-subramani it's already on NPM

@JoostK
Copy link
Member

JoostK commented Jul 1, 2019

@kumaresan-subramani Please update everything Angular related: all @angular packages together with @angular/angular-cli and also @angular-devkit

@kumaresan-subramani
Copy link
Author

HI @JoostK ,

Still application not working in Angular IVY mode but working fine in normal mode.

Repo steps

  1. sample -

sample.zip

  1. Give below commands

npm i

npm i @syncfusion/ej2-angular-grids

  1. Then give - "ng serve"

You will see below error:

Screenshot (5)
Screenshot (4)

@petebacondarwin
Copy link
Member

The error is in the IVY compiler template type checker... It looks, from first glance, like the compiler is not recognizing the <esj-grid> tag as a component that has an input called dataSource.

I think this is because the ej2 components use a dynamic mixin approach to creating their components and this component doesn't statically declare dataSource as a property on the GridComponent class. See https://github.com/syncfusion/ej2-angular-ui-components/blob/2b12b0202728b6e634cb1c8adb9650b2843fdbd0/components/grids/src/grid/grid.component.ts

@petebacondarwin
Copy link
Member

It would be interesting to see if this project can be compiled using the ngtsc compiler from source which could show that the problem is in the ngcc compiler.

@kumaresan-subramani
Copy link
Author

HI @petebacondarwin ,

We haven't use dynamic mixin approach to create our component.

@petebacondarwin
Copy link
Member

We haven't use dynamic mixin approach to create our component.

By dynamic mixin approach I am referring to this line of code:

@ComponentMixins([ComponentBase])

I accept that this might be a red herring in this case as the problem is more likely caused by the component not having the relevant input declared as a typed property on the class.

But it is likely to have an impact in the compiler knowing whether relevant lifecycle methods are available on the component.

@kumaresan-subramani
Copy link
Author

kumaresan-subramani commented Jul 30, 2019

HI @alxhub ,

Any update on this query?

Is this workaround for this since you fix this issue

#30114 (comment)

@kumaresan-subramani
Copy link
Author

@alxhub ,

I am facing reported issue since angular-cli version 8.1.0-next. can I get any update regarding this issue?

@kumaresan-subramani
Copy link
Author

Hi @alan-agius4 ,

Can you update on this? still, i am facing this error

@JoostK
Copy link
Member

JoostK commented Oct 9, 2019

@kumaresan-subramani the issue with the type checker has not been resolved yet, as it's quite tricky to deal with properly. We are working on implementing additional "strict*" flags so that the type checking can be less strict for the time being, which we hope to land within the coming two weeks.

@kumaresan-subramani
Copy link
Author

kumaresan-subramani commented Oct 9, 2019

@JoostK , thanks

@kumaresan-subramani
Copy link
Author

kumaresan-subramani commented Oct 18, 2019

@JoostK ,

I am facing the same issue in latest version 8.3.12 while using command ng serve in IVY mode.

Working fine in normal mode

I thought issue occurs due to Ivy compilation. please refer below image:

While it goes refreshChildComponets ,ethod there is ejs-grid component but datasource property has not been included.

Screenshot (5)

In detail - >

First it takes component property from app.compnent.ts file

Screenshot (8)_LI

After that, it goes ɵɵproperty() to update component property:

Screenshot (9)

Here, the property [datasource] has not been updated correctly so that when it goes to elementPropertyInternal() method, it throws an error.

Screenshot (11)

So that it throws error, due to validateAgainstUnknownProperties() method:

Screenshot (13)

Error screenshot

Screenshot (4)

HERE I HAVE ATTACHED SAMPLE FOR YOU REFERENCE:

ivy-8.3.12.zip

@kumaresan-subramani
Copy link
Author

@JoostK || @alan-agius4 ,

at least, please provide a workaround for this.

@JoostK
Copy link
Member

JoostK commented Oct 18, 2019

@kumaresan-subramani I have a feeling there's an issue with compiling the library that has ejs-grid using ngcc, which results in the ejs-grid element not representing a component. You are using Ivy in v8.x, which has not received relevant Ivy fixes for a very long time, so I would request you try Ivy with the latest 9.x next release.

@kumaresan-subramani
Copy link
Author

@JoostK ,

In the latest v9.0.0-next.12 angular/CLI version, it won't throw any console and compilation error while using below command

ng serve

And control also not get rendered, refer below image:

Screenshot (15)

@kumaresan-subramani
Copy link
Author

Hi @JoostK ,

Is below relate to this issue:

#33131

And I am facing same issue in latest version which got released 23rd

@JoostK
Copy link
Member

JoostK commented Nov 17, 2019

@syncfusion/ej2-ng-grids is not bootstrapping as its lifecycle methods are provided by a mixin mechanism that are not visible to the Ivy runtime, as they are bound too late. Related issue: #31495

@kumaresan-subramani
Copy link
Author

kumaresan-subramani commented Nov 17, 2019

@JoostK , This is deprecated package. Try @syncfusion/ej2-angular-grid, which is bootraped properly. And i have used ng-packagr to generate ej2-angular-grid package.

Our latest packages - https://github.com/syncfusion/ej2-angular-ui-components/blob/master/components/grids/src/grid/grid.component.ts#L29

@JoostK
Copy link
Member

JoostK commented Nov 18, 2019

@kumaresan-subramani Ah, I'm super confused by all this, but it appears I did test @syncfusion/ej2-angular-grid and it's basically failing because of the same reason: the @ComponentMixins([ComponentBase]) is applied after the Ivy runtime has captured the component's details, so the overridden lifecycle hooks are never called.

@PritiMaurya
Copy link

ERROR in Failed to find exported name of node (class BsDatepickerDayDecoratorComponent {
})

I am getting this error

@kumaresan-subramani
Copy link
Author

ERROR in Failed to find exported name of node (class BsDatepickerDayDecoratorComponent {
})

I am getting this error

@PritiMaurya , can you explain in detail please

@PritiMaurya
Copy link

my project is in angular 8 i want enable Ivy in my project but after enable that I am getting error in ngx bootstrap

@kumaresan-subramani
Copy link
Author

@JoostK ,

Any update on this issue?

@kolkov
Copy link

kolkov commented Dec 3, 2019

@kumaresan-subramani try 9.0.0-rc.4, maybe this fixed in next versions.

@kumaresan-subramani
Copy link
Author

@kolkov , i have already tried but same issue occurs.

@kolkov
Copy link

kolkov commented Dec 3, 2019

@kumaresan-subramani I use 9.0.0 beats and rcs versions for a long time, it's works as expected.

@kumaresan-subramani
Copy link
Author

@kolkov ,

Refer below issue this is cause of problem #31495

@kolkov
Copy link

kolkov commented Dec 3, 2019

@kumaresan-subramani I think we need to fix all external packages that caused this issue.

@petebacondarwin
Copy link
Member

Moving the discussion to #31495.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

10 participants