articodeltd / angular-cesium

JavaScript library for creating map based web apps using Cesium and Angular
https://github.com/articodeltd/angular-cesium/settings/pages
MIT License
178 stars 92 forks source link

Remove warning from angular 10 compilation #359

Open Crocsx opened 3 years ago

Crocsx commented 3 years ago

In Angular 10, when compiling the project those warning appears :

WARNING in C:\Users\****\Documents\Repository\****\node_modules\angular-cesium\__ivy_ngcc__\fesm2015\angular-cesium.js depends on 'geodesy'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

WARNING in C:\Users\****\Documents\Repository\****\node_modules\angular-cesium\__ivy_ngcc__\fesm2015\angular-cesium.js depends on 'util'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

I believe this could be avoided by changing library/way of import

AshitakaLax commented 3 years ago

I agree, the link in the warnings shows you how to hide the warnings(https://angular.io/guide/build#configuring-commonjs-dependencies).

It recommends using a "ECMAScript modules" instead of the commonjs not sure what complications are with updating the following https://github.com/articodeltd/angular-cesium/blob/master/projects/angular-cesium/tsconfig.schematics.json#L9

 "module": "commonjs",

to

  "module": "es2020",

It would be nice to optimize this section of the code.

AshitakaLax commented 3 years ago

actually looking at it a little more it looks like there are dependencies on 'geodesy' and 'util'. Which I was slow to realize was the cause of it.

here is the snippet to add if you want to disable the build warnings in the angular.json options

      "options": {
        "allowedCommonJsDependencies":[
          "geodesy",
          "util"
        ]
      }