Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preserve Symlinks in Angular Libraries

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!

like image 636
andersonbalves Avatar asked Oct 06 '19 18:10

andersonbalves


Video Answer


2 Answers

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!

like image 118
Armando Perez Avatar answered Oct 10 '22 11:10

Armando Perez


In angular 13... this allowed me to use symlinks with ng serve

enter image description here

like image 2
Dariusz Filipiak Avatar answered Oct 10 '22 11:10

Dariusz Filipiak