3

I have a library that packages up several components and their corresponding modules.

I can import those modules by themselves in an external application and they work fine.

I tried to package them all up in an Uber module within the same library like this (Just a small sample):

import { ArticleMetaModule } from '../components/article-meta/article-meta.module'
import { CategoryModule } from '../components/category/category.module'

import { NgModule } from '@angular/core/'

const dm = [
    ArticleMetaModule,
    CategoryModule
]
@NgModule({
    imports: [...dm],
    exports: [...dm]
})
export class TestModule { }

And if I try to import this module instead of each of the individual modules, I get this error:

Error: node_modules/@fireflysemantics/documentation/lib/modules/test.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (@fireflysemantics/documentation) which declares TestModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

So I'm guessing that if I want to package up modules into an Uber module for import I have to do that in a separate library.

In other words Angular packages, like Angular Material, don't let us package up uber material within the same library?

Thoughts?

Update

I did confirm that packaging the modules up as a separate library does work.

Ole
  • 41,793
  • 59
  • 191
  • 359

0 Answers0