Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng-packagr side effects - should I be worried?

Tags:

When running command

ng-packagr -p ng-package.json

I get the following output

Building Angular library
- - - skipped 8 lines - - -
Side effects in initialization of unused variable Cm [0:2339,29]
Side effects in initialization of unused variable Jm [0:2361,29]
Dropping duplicated definition of variable FO [0:11798,34]
Side effects in initialization of unused variable ES [0:13236,33]
- - - skipped 4 lines - - -
Built Angular library from MY_PROJECT_PATH written to MY_PROJECT_PATH/dist

Should I be worried about those Side effects and Dropping duplicated lines? What kind of side effects are we talking about here?

The interesting thing is that they weren't there a few builds ago.

Searching ng-packagr side effects on SO, did not produce any results - am I the only one that's interested in this?

like image 616
erikvimz Avatar asked Mar 21 '18 08:03

erikvimz


1 Answers

  1. For my library, if I look up the error "Side effects in initialization of unused variable ..." just in the JS file, it's the correct warning that the variable is just defined and not used in TS. After I deleted the unused variable, the warning is fixed.
  2. For the second warning "Dropping duplicated definition of variable ..." of my library, it happens if I use "let" to define the variable twice in the same method but different block-scoping, e.g.
testMethod(componentId: string){

 if (componentId) {
      let data = componentId; // Duplicate name but correct for TS
      data = 'test data';
      console.log(data);
    } else {
      let data = '234'; // Duplicate name but correct for TS
      data = '456';
      console.log(data);
    }
}

I guess, something about conversion from TS to JS in "ng-packagr" between "let" and "var" are not 100% correct because of scoping difference. I have no third-package in my project, so "peerDependencies" should not be the reason of my warning.

like image 109
Jie Avatar answered Sep 21 '22 13:09

Jie