Preserve Symlinks in Angular Libraries

andersonbalves picture andersonbalves · Oct 6, 2019 · Viewed 8.1k times · Source

I have a problem.

I'm trying to make a Angular 8 Library using ng-cli, but i can't preserve symlinks from my external application using npm link.

I've tried to add this on my angular.json:

    "build": {
      "builder": "@angular-devkit/build-ng-packagr:build",
      "options": {
        "preserveSymlinks": true,
        "tsConfig": "projects/button/tsconfig.lib.json",
        "project": "projects/button/ng-package.json"
      }
    }, 

but got:

"Schema validation failed with the following errors: Data path ""
should NOT have additional properties(preserveSymlinks)."

I found that it doesn't work for libraries.

Then I tried to add this to my tsconfig.lib.json:

 "angularCompilerOptions": {
    "annotateForClosureCompiler": true,
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    "enableResourceInlining": true,
    "preserveSymlinks": true
  }

And nothing happend.

I searched here for a solution, but couldn't find anything like it.

How can I make it?

Thank you!

Answer

Armando Perez picture Armando Perez · Nov 27, 2019

I believe you need to add the preserveSymlinks option in the angular.json located at the project that will consume your library. For instance, I was testing locally, and I added it in my architect -> build -> options.

You will able to find more info here: https://dev.to/nieds/getting-started-building-component-libraries-with-angular-cli-4ncj

Hope this helps!