I have created a library that has modules that have components in them.
My library public_api.ts has this:
export * from './src/app/modules/my-mod-1/my-mod-1.module';
Now this module has components that are exported and declared in the module.ts file
@NgModule({
imports: [
...
],
declarations: [
MyOneComponent
],
exports: [
MyOneComponent
]
})
Now I create the package using ng-packagr and import it in another project using npm install from the .tgz file.
The component works fine with all lifecycle hooks when I run it in development mode.
But when I create a build using ng build, it does not call the lifecycle hooks. Although it does print everything in the html file of the component, but the component class code seems to be missing.
I checked in vendor.js file when running the development mode, and there I can easily find the component class code (actually I searched for a console.log code that I printed in the component class code and it was showing up there)
But same code is missing from main.xxxxxx.js that is built by the build command. And the build command does not create a vendor.js file at all because vendor.js is included in main.js
So the problem is that library classes code is not included in the project build, why would that happen?
There is so much code in the projects that I cannot think of what parts of code should I paste here to help you understand the issue. So please do let me know what else I should copy here.
Thanks
ng buildwithout--prodoption and it created the the js files with vendor.js and main.js separate. Using that deployment, I was able to run the project fine. Which again proves that there is something wrong inng build --prod... any idea...?