Currently in the process of updating my Angular project from version 2.something to the latest release. Initially, I had a custom angular.config file set up so that I could build two separate apps utilizing the same component 'library'. However, with the introduction of real Angular libraries in the epic Angular 6 release, I find myself stuck once again trying to refactor my project to adapt to this new version.
I have managed to build a component library (referred to as 'core') into a DIST folder successfully. Even TypeScript recognizes this library without any issues. But when attempting to build my web-app, Angular CLI starts throwing errors stating it cannot locate the module 'core'.
The public_api.d.ts code snippet located in the dist/core folder looks like this:
export { WdCoreModule } from './lib/wd-core.module';
export { wdApi } from './lib/core/wd.service';
export { ProcessTokenComponent } from './lib/core/process-token.component';
// More exports listed
In order to address this issue, I added the path to the library in my tsconfig.json file:
"paths": {
"core": [
"dist/core"
],
"core/*": [
"dist/core/*"
]
}
Next step is to import Modules and components from the 'core' library into the app named 'cms':
import { WdCoreModule } from 'core';
No errors at this point!
I proceed to build my project using: ng serve cms
This results in the following error:
projects/cms/src/app/app.module.ts(52,30): error TS2307: Cannot find module 'core'.
Despite extensive searching for a solution, I remain stuck. Any coding heroes willing to lend a hand?
Edit: Additional information regarding a potential solution
Referenced the following post for guidance on packaging and installing the build library:
Executing the following two commands proved helpful:
//package.json
"npm_pack": "cd dist/core && npm pack",
//then
npm install dist/core/core-0.0.1.tgz --save