Search code examples
requirejsopenedx

OpenEDX RequireJS error when overriding factory with AWS setting


I'm having an issue with OpenEDX when deploying to a server as opposed to devstack. On devstack the override works perfectly, although on dev it fails to load.

I am overriding the student_account/account_settings.html as well as student_account/views/account_settings_factory.js and student_account/views/account_settings_view.js.

When loading the account section of the LMS, the following error is produced on production, but not on dev:

Mismatched anonymous define() module: function(gettext, $, _, Backbone, Logger, UserAccountModel, UserPreferencesModel,
                 AccountSettingsFieldViews, AccountSettingsView, StringUtils) {
        return function(
            fieldsData,
            ordersHistoryData,
            authData,
            passwordResetSupportUrl,
            userAccountsApiUrl,
            userPreferencesApiUrl,
            accountUserId,
            platformName,
            contactEmail,
            allowEmailChange
        ) {
            var accountSettingsElement, userAccountModel, userPreferencesModel, aboutSectionsData,
                accountsSectionData, ordersSectionData, accountSettingsView, showAccountSettingsPage,
                showLoadingError, orderNumber, getUserField, userFields, countryDropdownField, emailFieldView;

            accountSettingsElement = $('.wrapper-account-settings');

            userAccountModel = new UserAccountModel();
            userAccountModel.…

The define in my factory looks like the following:

(function(define, undefined) {
'use strict';
define([
    'gettext', 'jquery', 'underscore', 'backbone', 'logger',
    'js/student_account/models/user_account_model',
    'js/student_account/models/user_preferences_model',
    'js/student_account/views/account_settings_fields',
    'academy/js/student_account/views/account_settings_view',
    'edx-ui-toolkit/js/utils/string-utils'
], function(gettext, $, _, Backbone, Logger, UserAccountModel, UserPreferencesModel,
             AccountSettingsFieldViews, AccountSettingsView, StringUtils) {

As stated, works flawlessly in development, but production throws the error. Hopefully someone knows a solution to this issue.


Solution

  • The issue was because in the AWS paver settings for some reason the custom factory is expected to be optimized, which can be done by overriding the build.js file for the lms. This issue isn't really clear anywhere in the docs and was therefore a bit difficult to reach this conclusion.