Angular 6 / 7 “the result of a dependency is an expression”

前端 未结 4 906
春和景丽
春和景丽 2020-12-08 09:15

I\'m trying to create an Angular 6 library and use it in an Angular 6 app. I\'ve boiled it down to a minimal test case. (Update: since Angular 7 is out, I\'ve tried that as

4条回答
  •  无人及你
    2020-12-08 09:44

    I encountered the same warning about "the result of a dependency is an expression” referencing fesm5.js in a new Angular 7 cli generated project.

    This particular project has a reference to a local npm package with a relative path beginning with file://../ which seemed to cause the warning.

    After some research I found this Github issue which explains how we can fix it in Angular 6+ cli generated apps.

    What worked for me was to open the angular.json file in the client project's root folder (not the shared library's) and find this path:

    projects > (your project name) > architect > build > options

    and add the key:

    "preserveSymlinks": true

    with all the rest of the file omitted here are the relevant parts:

    {
      "projects": {
        "MyAwesomeProject": {
          "architect": {
            "build": {
              "options": {
                "preserveSymlinks": true
              }
            }
          }
        }
      }
    }
    

    After adding this I get normal ng build without warnings. Hope that helps!

提交回复
热议问题