MOBILE-4272 workshop: Decouple component modules
parent
0d6eb5cb23
commit
cd66097a8f
|
@ -21,8 +21,7 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu
|
||||||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||||
import { CoreCronDelegate } from '@services/cron';
|
import { CoreCronDelegate } from '@services/cron';
|
||||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||||
import { AddonModWorkshopAssessmentStrategyModule } from './assessment/assessment.module';
|
import { AddonModWorkshopAssessmentStrategyModule } from '@addons/mod/workshop/assessment/assessment.module';
|
||||||
import { AddonModWorkshopComponentsModule } from './components/components.module';
|
|
||||||
import { ADDON_MOD_WORKSHOP_OFFLINE_SITE_SCHEMA } from './services/database/workshop';
|
import { ADDON_MOD_WORKSHOP_OFFLINE_SITE_SCHEMA } from './services/database/workshop';
|
||||||
import { AddonModWorkshopIndexLinkHandler } from './services/handlers/index-link';
|
import { AddonModWorkshopIndexLinkHandler } from './services/handlers/index-link';
|
||||||
import { AddonModWorkshopListLinkHandler } from './services/handlers/list-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 = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: ADDON_MOD_WORKSHOP_PAGE_NAME,
|
path: ADDON_MOD_WORKSHOP_PAGE_NAME,
|
||||||
|
@ -63,7 +73,6 @@ const routes: Routes = [
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CoreMainMenuTabRoutingModule.forChild(routes),
|
CoreMainMenuTabRoutingModule.forChild(routes),
|
||||||
AddonModWorkshopComponentsModule,
|
|
||||||
AddonModWorkshopAssessmentStrategyModule,
|
AddonModWorkshopAssessmentStrategyModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -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_SURVEY_SERVICES } from '@addons/mod/survey/survey.module';
|
||||||
import { ADDON_MOD_URL_SERVICES } from '@addons/mod/url/url.module';
|
import { ADDON_MOD_URL_SERVICES } from '@addons/mod/url/url.module';
|
||||||
import { ADDON_MOD_WIKI_SERVICES } from '@addons/mod/wiki/wiki.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_NOTES_SERVICES } from '@addons/notes/notes.module';
|
||||||
import { ADDON_NOTIFICATIONS_SERVICES } from '@addons/notifications/notifications.module';
|
import { ADDON_NOTIFICATIONS_SERVICES } from '@addons/notifications/notifications.module';
|
||||||
import { ADDON_PRIVATEFILES_SERVICES } from '@addons/privatefiles/privatefiles.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 some addon modules that define components, directives and pipes. Only import the important ones.
|
||||||
import { AddonModAssignComponentsModule } from '@addons/mod/assign/components/components.module';
|
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 { CorePromisedValue } from '@classes/promised-value';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
|
|
||||||
|
@ -180,7 +179,10 @@ export class CoreCompileProvider {
|
||||||
CoreSharedModule, CoreCourseComponentsModule, CoreCoursesComponentsModule, CoreUserComponentsModule,
|
CoreSharedModule, CoreCourseComponentsModule, CoreCoursesComponentsModule, CoreUserComponentsModule,
|
||||||
CoreCourseDirectivesModule, CoreQuestionComponentsModule, AddonModAssignComponentsModule,
|
CoreCourseDirectivesModule, CoreQuestionComponentsModule, AddonModAssignComponentsModule,
|
||||||
CoreBlockComponentsModule, CoreEditorComponentsModule, CoreSearchComponentsModule, CoreSitePluginsDirectivesModule,
|
CoreBlockComponentsModule, CoreEditorComponentsModule, CoreSearchComponentsModule, CoreSitePluginsDirectivesModule,
|
||||||
AddonModWorkshopComponentsModule,
|
];
|
||||||
|
|
||||||
|
protected readonly LAZY_IMPORTS = [
|
||||||
|
getWorkshopComponentModules,
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(protected injector: Injector, compilerFactory: JitCompilerFactory) {
|
constructor(protected injector: Injector, compilerFactory: JitCompilerFactory) {
|
||||||
|
@ -205,7 +207,9 @@ export class CoreCompileProvider {
|
||||||
// Create the component using the template and the class.
|
// Create the component using the template and the class.
|
||||||
const component = Component({ template })(componentClass);
|
const component = Component({ template })(componentClass);
|
||||||
|
|
||||||
|
const lazyImports = await Promise.all(this.LAZY_IMPORTS.map(getModules => getModules()));
|
||||||
const imports = [
|
const imports = [
|
||||||
|
...CoreArray.flatten(lazyImports),
|
||||||
...this.IMPORTS,
|
...this.IMPORTS,
|
||||||
...extraImports,
|
...extraImports,
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue