Support named canonical exports
This commit is contained in:
parent
be1f615858
commit
cd387af2c6
@ -105,7 +105,7 @@ export abstract class Canonical<T> extends Unit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async initCanonicalItem(definition: CanonicalDefinition): Promise<T> {
|
public async initCanonicalItem(definition: CanonicalDefinition): Promise<T> {
|
||||||
return definition.imported.default
|
return definition.imported.default ?? definition.imported[definition.canonicalName]
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async buildCanonicalDefinition(filePath: string): Promise<CanonicalDefinition> {
|
protected async buildCanonicalDefinition(filePath: string): Promise<CanonicalDefinition> {
|
||||||
|
@ -17,6 +17,10 @@ export class CanonicalInstantiable<T> extends Canonical<Instantiable<T>> {
|
|||||||
return this.app().make(definition.imported.default)
|
return this.app().make(definition.imported.default)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isInstantiable(definition.imported[definition.canonicalName]) ) {
|
||||||
|
return this.app().make(definition.imported[definition.canonicalName])
|
||||||
|
}
|
||||||
|
|
||||||
throw new InvalidCanonicalExportError(definition.originalName)
|
throw new InvalidCanonicalExportError(definition.originalName)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,6 +8,10 @@ export class CanonicalStatic<T, T2> extends Canonical<StaticClass<T, T2>> {
|
|||||||
return definition.imported.default
|
return definition.imported.default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isStaticClass(definition.imported[definition.canonicalName]) ) {
|
||||||
|
return definition.imported[definition.canonicalName]
|
||||||
|
}
|
||||||
|
|
||||||
throw new InvalidCanonicalExportError(definition.originalName)
|
throw new InvalidCanonicalExportError(definition.originalName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user