0

I'm creating a custom library in Angular 7 and I would like to somehow export a function in this library that can be used in the main application after the library is installed. I saw some documentation about doing this through a typings.d.ts file, but after trying it out, it seems the typings file can only be installed through npm, which doesn't work for me since this library will not be uploaded to npm. Is there a way to export a function without having to upload the library to npm?

Catherine S.
  • 185
  • 1
  • 4
  • 16
  • You mean, you want to use it as local npm module? – critrange Feb 24 '20 at 03:15
  • I am also using an angular project(repo1) as a dependency in another angular project(repo2). I want to export some common functions from repo1 that can be used in repo2. This is compiling successfully but giving an error on the browser console. Uncaught TypeError: (0 , som_core__WEBPACK_IMPORTED_MODULE_0__.functionName) is not a function. Did you find any solution ? – Akshay Kapoor Dec 05 '21 at 05:54

2 Answers2

0

I ended up doing a different approach. I set up my custom library to take IN a function to be executed after a save function was completed, instead of exporting the library's function. I set it up just like how the chosen answer was done here: Angular 5 Component input function that takes parameters

Catherine S.
  • 185
  • 1
  • 4
  • 16
0

to use local library use relative path in package.json as below:

"@libraryName":"file:../../so_on/lib_workspaceName/dist/my-lib"

then run npm install in main application.