2

I have the following project structure

Library2 ---> Library1 (Library2 is install using npm to Library1)

Library1 ---> clientApp1 (angular application) (then Library1 is install using npm to clientApp1)

Now I want to allow clientApp1 to have access to Library2 functionality. Is it possible to do it with Library1 exposing Library2 to clientApp1, instead of independently install library2 to clientApp1

NOTE: Want to access Library2 functionalities that do not override into Library1

1
  • What do you mean by NOTE: Want to access Library2 functionalities that do not override into Library1 Commented Mar 17, 2021 at 21:18

1 Answer 1

2

If I understand correctly your question.

You can add the third party library as dependencies of your custom library into the package.json file

// projects/myCustomLibrary/package.json
  "dependencies": {
    "@angular/google-maps": "^11.2.4", // <-- third library
  }

Then add it as a white listed dependencies into the ng-package.json

// projects/myCustomLibrary/ng-package.json
{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/website",
  "assets": ["./assets"],
  "lib": {
    "entryFile": "src/public-api.ts",
    "umdModuleIds": {
      "moment": "moment"
    }
  },
  "whitelistedNonPeerDependencies": [
    "@angular/google-maps" // <-- here
  ]
}

then, we you do your npm i myCustomlibrary it will directly install de dependency and you'll be able to access it directly with your module like the following

import { GoogleMapsModule } from '@angular/google-maps'

Be aware, vscode doesn't then find the auto import of those module, I've already opened a question for it here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.