-
Improvement
-
Resolution: Fixed
-
Minor
-
3.8
-
MOODLE_38_STABLE
-
MOODLE_38_STABLE
-
MDL-66192-master -
-
Internationals - 3.8 Sprint 3
Similar to MDL-50346, we should remove the restriction of preventing subdirectories in the amd src directory.
As we write more javascript, and we make our javascript more compartmentalised it becomes more and more important to structure our code well.
Take, for example, the messaging code:
message/amd/src/
|
├── message_drawer.js
|
├── message_drawer_events.js
|
├── message_drawer_helper.js
|
├── message_drawer_lazy_load_list.js
|
├── message_drawer_router.js
|
├── message_drawer_routes.js
|
├── message_drawer_view_contact.js
|
├── message_drawer_view_contacts.js
|
├── message_drawer_view_contacts_section_contacts.js
|
├── message_drawer_view_contacts_section_requests.js
|
├── message_drawer_view_conversation.js
|
├── message_drawer_view_conversation_constants.js
|
├── message_drawer_view_conversation_patcher.js
|
├── message_drawer_view_conversation_renderer.js
|
├── message_drawer_view_conversation_state_manager.js
|
├── message_drawer_view_group_info.js
|
├── message_drawer_view_overview.js
|
├── message_drawer_view_overview_section.js
|
├── message_drawer_view_search.js
|
├── message_drawer_view_settings.js
|
├── message_notification_preference.js
|
├── message_popover.js
|
├── message_repository.js
|
├── message_user_button.js
|
├── notification_preference.js
|
├── notification_processor.js
|
├── notification_processor_settings.js
|
├── preferences_notifications_list_controller.js
|
├── preferences_processor_form.js
|
└── toggle_contact_button.js
|
It would be much easier to understand this if the code was structured differently:
.
|
├── drawer
|
│ ├── events.js
|
│ ├── helper.js
|
│ ├── lazy_load_list.js
|
│ ├── router.js
|
│ ├── routes.js
|
│ └── view
|
│ ├── contact.js
|
│ ├── contacts
|
│ │ ├── section_contacts.js
|
│ │ └── section_requests.js
|
│ ├── contacts.js
|
│ ├── conversation
|
│ │ ├── constants.js
|
│ │ ├── patcher.js
|
│ │ ├── renderer.js
|
│ │ └── state_manager.js
|
│ ├── conversation.js
|
│ ├── group_info.js
|
│ ├── overview
|
│ │ └── section.js
|
│ ├── overview.js
|
│ ├── search.js
|
│ └── settings.js
|
├── drawer.js
|
├── message_notification_preference.js
|
├── message_popover.js
|
├── message_repository.js
|
├── message_user_button.js
|
├── notification_preference.js
|
├── notification_processor.js
|
├── notification_processor_settings.js
|
├── preferences_notifications_list_controller.js
|
├── preferences_processor_form.js
|
└── toggle_contact_button.js
|
In ES6 and AMD this is just as easy - it's just a case of adding an extra slash in the import line:
import Constants from 'core_message/drawer/view/conversation/constants';
|
We can also make use of requireJS relative URLs:
import Constants from './conversation/constants';
|
And we can write entrypoints like a single message/amd/src/drawer/view/conversation/index.js:
import Constants from './constants';
|
import Renderer from './renderer';
|
|
export {Constants, Renderer};
|
- caused a regression
-
MDL-66502 Moodle 3.8 does not load javascript files from previous moodle versions
- Closed
- has a non-specific relationship to
-
MDL-50346 Remove the restriction to forbid subdirectories in the templates directory
- Closed
- is blocked by
-
MDL-62497 Add a new transpilation tool for ES6
- Closed