5

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?

erikvimz
  • 5,256
  • 6
  • 44
  • 60
  • Have a look at https://github.com/dherges/ng-packagr/issues/698 - that looks like your error and ist just some hours old – Nico Haase Mar 21 '18 at 13:58
  • @NicoHaase That has nothing to do with my situation. The person there added a package to `peerDependencies`. I didn't add anything. I've got a basic `ng new` project. – erikvimz Mar 22 '18 at 16:50

1 Answers1

4
  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.

Jie
  • 427
  • 5
  • 12