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

Using services in providers, Build got failed while using 'ng build ---aot' #15392

Closed
ghost opened this issue Aug 21, 2019 · 9 comments · Fixed by #15451
Closed

Using services in providers, Build got failed while using 'ng build ---aot' #15392

ghost opened this issue Aug 21, 2019 · 9 comments · Fixed by #15451
Labels
freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@ghost
Copy link

ghost commented Aug 21, 2019

🐞 Bug report

Command (mark with an x)

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

Is this a regression?

yes

Description

I have set "target": "es6", when i try to serve my application using below command

ng serve ---aot

It throws below error:

59196047-349ec680-8bab-11e9-9297-72ff078cd2cd

If i change target to "es2015" and try to run using below commands

ng serve --prod

ng serve --aot

it throws a same error.

Working fine

When using "ng serve" with target es2015 and es6

And all commands are working fine with target as es5

🔬 Minimal Reproduction

  1. Download sample- issueSample.zip

  2. Run "npm i"

  3. The give anyone command from below list:

  • ng serve --aot
  • ng build --aot
  • ng serve --prod
  • ng build --prod

🔥 Exception or Error

59196047-349ec680-8bab-11e9-9297-72ff078cd2cd

🌍 Your Environment


"@angular-devkit/build-angular": "^0.800.2",
"@angular-devkit/build-optimizer": "^0.800.2",
"@angular/cli": "~8.0.0",
"@angular/compiler-cli": "~8.0.0",

Anything else relevant?

Reported issue occurs only when i use services in providers like below:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { GridModule } from '@syncfusion/ej2-angular-grids';
// have to below service
import { PageService, SortService, FilterService, GroupService } from '@syncfusion/ej2-angular-grids';
import { AppComponent } from './app.component';
 
@NgModule({
 declarations: [
 AppComponent
 ],
 imports: [
 BrowserModule,
 GridModule
 ],
 providers: [PageService,
 SortService,
 FilterService,
 GroupService],
 bootstrap: [AppComponent]
})
export class AppModule { }

When i add service like below it doesn't throws error even service also not get injected.
#4043 (comment)

i have used above reference like below:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { GridModule } from '@syncfusion/ej2-angular-grids';
import { PageService, SortService, FilterService, GroupService } from '@syncfusion/ej2-angular-grids';
import { AppComponent } from './app.component';
const providers = [];
providers.push({ PageService });
providers.push({ SortService });
providers.push({ FilterService });
providers.push({ GroupService });
@NgModule({
 declarations: [
 AppComponent
 ],
 imports: [
 BrowserModule,
 GridModule
 ],
 providers: [providers],
 bootstrap: [AppComponent]
})
export class AppModule { }

It wont throw error and also my service not injected.

@ghost ghost changed the title Build got failed while using 'ng build ---aot' Using services in providers, Build got failed while using 'ng build ---aot' Aug 21, 2019
@alan-agius4
Copy link
Collaborator

@kumaresan-subramani, can you please provide a link with the most possible code to get that error?

Thanks.

@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Aug 26, 2019
@kumaresan-subramani
Copy link

kumaresan-subramani commented Aug 26, 2019

Hi @alan-agius4 ,

Repo steps

Please find issue reproducing steps here:

Step1: download sample -
issueSample.zip

step2: Run below commands:

npm i

ng serve --prod

You will see an error,When you set"target" to "es5" it works fine.

I think, class expression got tree-shaken away

Old Issue - #14577 (comment)

@kumaresan-subramani
Copy link

kumaresan-subramani commented Aug 27, 2019

HI @alan-agius4 ,

Due to this #14577,

Description

TypeScript ClassExpression are not being treeshaken away.

Example codes:

let ChipList = class ChipList extends Component {
  constructor(options, element) {
        super(options, element);
    }
};
__decorate$4([
    Property([])
], ChipList.prototype, "chips", void 0);
ChipList = __decorate$4([
    NotifyPropertyChanges
], ChipList);

Anything else relevant?

#14263

you have added this fix . i think this causes issue now.

Thanks in advance

@alan-agius4
Copy link
Collaborator

I think I found the problem, I will land a PR soon.

@alan-agius4 alan-agius4 added comp: devkit/build-optimizer freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix and removed needs: repro steps We cannot reproduce the issue with the information given labels Aug 27, 2019
@ngbot ngbot bot modified the milestone: Backlog Aug 27, 2019
@kumaresan-subramani
Copy link

kumaresan-subramani commented Aug 27, 2019

Hi @alan-agius4 ,

Could you please update when the fix will be moved to npm, which will helpful for me to proceed further.

Please add release notes, if you have made any major changes related to tree-shaking which will be helpful for me to work at my end.

@clydin
Copy link
Member

clydin commented Aug 27, 2019

Release notes are located here: https://github.com/angular/angular-cli/releases

@kumaresan-subramani
Copy link

kumaresan-subramani commented Aug 27, 2019

mgechev pushed a commit that referenced this issue Aug 27, 2019
…are suffixed with `$` and a number as pure (#15451)

Closes #15392
mgechev pushed a commit that referenced this issue Aug 27, 2019
…are suffixed with `$` and a number as pure (#15451)

Closes #15392
@kumaresan-subramani
Copy link

@alan-agius4 ,

is this fix got published?. if yes, please tell me @angular-devkit/build-optimizer version.

@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 Sep 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants