RE: Liferay Angular Portlet - .jar size

Bernd S, modified 5 Years ago. Junior Member Posts: 59 Join Date: 3/31/15 Recent Posts
While developing an Angular portlet I noticed that the build takes 2-6 minutes and results in a ~40MB .jar.

The only changes I made to the original template were in package.json. There I updated the dependencies to match a current Angular CLI project.
{
    "dependencies": {
        "@angular/animations": "~8.2.14",
        "@angular/cdk": "^8.2.3",
        "@angular/common": "~8.2.14",
        "@angular/compiler": "~8.2.14",
        "@angular/core": "~8.2.14",
        "@angular/forms": "~8.2.14",
        "@angular/material": "^8.2.3",
        "@angular/platform-browser": "~8.2.14",
        "@angular/platform-browser-dynamic": "~8.2.14",
        "@angular/router": "~8.2.14",
        "@ngx-translate/core": "^11.0.1",
        "core-js": "^2.5.1",
        "hammerjs": "^2.0.8",
        "rxjs": "~6.4.0",
        "tslib": "^1.10.0",
        "zone.js": "~0.9.1",
        "webpack": "4.41.2"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "~0.803.19",
        "@angular/cli": "~8.3.19",
        "@angular/compiler-cli": "~8.2.14",
        "@angular/language-service": "~8.2.14",
        "@types/node": "~8.9.4",
        "ts-node": "~7.0.0",
        "tslint": "~5.15.0",
        "typescript": "~3.5.3",
        "liferay-npm-bundler": "2.15.0"
    },
    "main": "lib/angular-loader.js",
    "name": "liferay-angular8",
    "scripts": {
        "build": "tsc && liferay-npm-bundler"
    },
    "version": "1.0.0"
}
I already know that things got better after Liferay 7.0 (which I am using) but unfortunately I am stuck with it for now.

Are my build duration and size normal? Is there a way to optimize it?
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
I wouldn't declare 40mb as a problem.

You have the jar, open it with a zip tool and see what's in it. That way you'll know where the space is.

Often times you get all kinds of NPM dependencies to deal with. It wouldn't surprise me if you see a lot of stuff in there that maybe you do or don't need.
thumbnail
Ivan Zaera, modified 5 Years ago. Regular Member Posts: 119 Join Date: 10/1/13 Recent Posts
I really doubt that you need so many dependencies for runtime. For example, I don't think webpack is needed out of the scope of development, therefore it should be moved to devDependencies. I guess this may happen with others...

Once you decide which are dev and which runtime deps, you can also use exclusions (https://github.com/liferay/liferay-js-toolkit/wiki/.npmbundlerrc-file-reference#exclude) to get rid of unneeded files inside needed packages.