MOBILE-4272 workshop: Decouple component modules

main
Noel De Martin 2023-07-26 11:56:27 +09:00
parent 0d6eb5cb23
commit cd66097a8f
2 changed files with 19 additions and 6 deletions

View File

@ -21,8 +21,7 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
import { CoreCronDelegate } from '@services/cron';
import { CORE_SITE_SCHEMAS } from '@services/sites';
import { AddonModWorkshopAssessmentStrategyModule } from './assessment/assessment.module';
import { AddonModWorkshopComponentsModule } from './components/components.module';
import { AddonModWorkshopAssessmentStrategyModule } from '@addons/mod/workshop/assessment/assessment.module';
import { ADDON_MOD_WORKSHOP_OFFLINE_SITE_SCHEMA } from './services/database/workshop';
import { AddonModWorkshopIndexLinkHandler } from './services/handlers/index-link';
import { AddonModWorkshopListLinkHandler } from './services/handlers/list-link';
@ -53,6 +52,17 @@ export async function getWorkshopServices(): Promise<Type<unknown>[]> {
];
}
/**
* Get workshop component modules.
*
* @returns Workshop component modules.
*/
export async function getWorkshopComponentModules(): Promise<unknown[]> {
const { AddonModWorkshopComponentsModule } = await import('@addons/mod/workshop/components/components.module');
return [AddonModWorkshopComponentsModule];
}
const routes: Routes = [
{
path: ADDON_MOD_WORKSHOP_PAGE_NAME,
@ -63,7 +73,6 @@ const routes: Routes = [
@NgModule({
imports: [
CoreMainMenuTabRoutingModule.forChild(routes),
AddonModWorkshopComponentsModule,
AddonModWorkshopAssessmentStrategyModule,
],
providers: [

View File

@ -149,14 +149,13 @@ import { ADDON_MOD_SCORM_SERVICES } from '@addons/mod/scorm/scorm.module';
import { ADDON_MOD_SURVEY_SERVICES } from '@addons/mod/survey/survey.module';
import { ADDON_MOD_URL_SERVICES } from '@addons/mod/url/url.module';
import { ADDON_MOD_WIKI_SERVICES } from '@addons/mod/wiki/wiki.module';
import { getWorkshopServices } from '@addons/mod/workshop/workshop.module';
import { getWorkshopComponentModules, getWorkshopServices } from '@addons/mod/workshop/workshop.module';
import { ADDON_NOTES_SERVICES } from '@addons/notes/notes.module';
import { ADDON_NOTIFICATIONS_SERVICES } from '@addons/notifications/notifications.module';
import { ADDON_PRIVATEFILES_SERVICES } from '@addons/privatefiles/privatefiles.module';
// Import some addon modules that define components, directives and pipes. Only import the important ones.
import { AddonModAssignComponentsModule } from '@addons/mod/assign/components/components.module';
import { AddonModWorkshopComponentsModule } from '@addons/mod/workshop/components/components.module';
import { CorePromisedValue } from '@classes/promised-value';
import { CorePlatform } from '@services/platform';
@ -180,7 +179,10 @@ export class CoreCompileProvider {
CoreSharedModule, CoreCourseComponentsModule, CoreCoursesComponentsModule, CoreUserComponentsModule,
CoreCourseDirectivesModule, CoreQuestionComponentsModule, AddonModAssignComponentsModule,
CoreBlockComponentsModule, CoreEditorComponentsModule, CoreSearchComponentsModule, CoreSitePluginsDirectivesModule,
AddonModWorkshopComponentsModule,
];
protected readonly LAZY_IMPORTS = [
getWorkshopComponentModules,
];
constructor(protected injector: Injector, compilerFactory: JitCompilerFactory) {
@ -205,7 +207,9 @@ export class CoreCompileProvider {
// Create the component using the template and the class.
const component = Component({ template })(componentClass);
const lazyImports = await Promise.all(this.LAZY_IMPORTS.map(getModules => getModules()));
const imports = [
...CoreArray.flatten(lazyImports),
...this.IMPORTS,
...extraImports,
];