中文
← Errors

F_SYSTEM_CIRCULAR_MODULE_IMPORT

Circular Module import

A dependency path in Module.imports leads back to a Module that is already being compiled.

Updated

Reproduction

The Module import graph contains a cycle:

src/app.module.ts
import { Module, createApp } from 'func'
import type { ModuleMetadata } from 'func'

const first: ModuleMetadata = {}
const second: ModuleMetadata = { imports: [first] }
first.imports = [second]

@Module({ imports: [first] })
class AppModule {}

createApp(AppModule)

How to fix it

Follow details.dependencyPath to the import that returns to an earlier Module. Extract shared Providers into a third Module and let the original Modules import it in one direction instead of importing each other. When only a TypeScript type is needed, use a type-only import and do not add it to Module.imports.