Skip to content

ng serve is about 5 times slower when compiling with IonicModule (Angular 7) #16979

Closed

Description

@tonyawad88

Bug Report

Ionic version:
[x] 4.x

Current behavior:
A brand new angular project has a compile time < 1 second. When I add @ionic/angular , the compile time becomes on average > 5 seconds when using it with ng serve

Any idea why this happens? Is this an ionic issue?

Expected behavior:
Expected compile time to be as fast as Ionic3 or faster.

Steps to reproduce:
1, Start a new angular project
2. run ng serve, change app.component.htm multiple times and notice how the compile time is < 1seconds after a couple compiles
2. run npm i @ionic/angular
3. Add IonicModule to the angular module
4. run ng serve and notice how the average time is now > 5 seconds.

Related code:

Other information:

Ionic info:

Ionic:
   ionic (Ionic CLI) : 4.6.0
System:
   NodeJS : v10.15.0
   npm    : 6.5.0
   OS     : Windows 10

Activity

  1. hiepxanh commented on Jan 7, 2019

    @hiepxanh
    Contributor

    please provide package.json and try replace angular-devkit to this version "@angular-devkit/build-angular": "~0.10.7",

  2. tonyawad88 commented on Jan 7, 2019

    @tonyawad88
    Author

    I tried it and it's about the same. Here's my package.json after adding your suggestion.
    As soon as I add IonicModule.forRoot(), my compile time becomes > 5 seconds up from under 1 second. It's also worth noting that also if I add IonButton only to the module as part of the declarations, build time goes up to ~4 seconds. Remove it again and back down to under 1second. I do realize Ionic's approach is to leave it all to the framework, but the angular framework seems to be doing fine on this one.

    {
      "name": "test-ionic4-speed",
      "version": "0.0.1",
      "author": "Ionic Framework",
      "homepage": "http://ionicframework.com/",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/common": "~7.1.4",
        "@angular/core": "~7.1.4",
        "@angular/forms": "~7.1.4",
        "@angular/http": "~7.1.4",
        "@angular/platform-browser": "~7.1.4",
        "@angular/platform-browser-dynamic": "~7.1.4",
        "@angular/router": "~7.1.4",
        "@ionic-native/core": "5.0.0-beta.21",
        "@ionic-native/splash-screen": "5.0.0-beta.21",
        "@ionic-native/status-bar": "5.0.0-beta.21",
        "@ionic/angular": "4.0.0-rc.0",
        "core-js": "^2.5.4",
        "rxjs": "~6.3.3",
        "zone.js": "~0.8.26"
      },
      "devDependencies": {
        "@angular-devkit/architect": "~0.10.7",
        "@angular-devkit/build-angular": "^0.10.7",
        "@angular-devkit/core": "~7.1.4",
        "@angular-devkit/schematics": "~7.1.4",
        "@angular/cli": "~7.1.4",
        "@angular/compiler": "~7.1.4",
        "@angular/compiler-cli": "~7.1.4",
        "@angular/language-service": "~7.1.4",
        "@ionic/angular-toolkit": "~1.2.0",
        "@types/jasmine": "~2.8.8",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~10.12.0",
        "codelyzer": "~4.5.0",
        "jasmine-core": "~2.99.1",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~3.1.4",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~1.1.2",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.4.0",
        "ts-node": "~7.0.0",
        "tslint": "~5.12.0",
        "typescript": "~3.1.6"
      },
      "description": "An Ionic project"
    }
    
  3. tonyawad88 commented on Jan 7, 2019

    @tonyawad88
    Author

    Mini demo of the issue: (Note the time on the compiles)
    angularcompiletime-with-ionic-and-without

  4. paulstelzer commented on Jan 7, 2019

    @paulstelzer
    Contributor

    It's because IonicModule imports a lot of components and so every time you make a change it needs a lot of time to compile (we had this discussion here #16937). Angular uses webpack and this is not very fast. Hopefully the Angular team finds something to make faster compiles or the IonicModule has to be changed. If anyone has an idea to make IonicModule faster, please send a comment :)

    But there is already a PR in work, so maybe this already can improve the compile speed -> #16966

  5. manucorporat commented on Jan 8, 2019

    @manucorporat
    Contributor

    Tracking progress here: #17001

    Thanks for the issue report!

  6. ionitron-bot commented on Feb 7, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  7. locked and limited conversation to collaborators on Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: angular

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions