From 569066edf51dbf24e46c02845002780569136d25 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 22 Dec 2017 11:09:15 -0500 Subject: [PATCH 1/4] Convert cms/static/js/factories/asset_index.js to be bundled using webpack --- cms/static/cms/js/build.js | 1 - cms/static/js/pages/asset_index.js | 7 +++++++ cms/templates/asset_index.html | 18 ++++++++-------- webpack.common.config.js | 33 ++++++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 cms/static/js/pages/asset_index.js diff --git a/cms/static/cms/js/build.js b/cms/static/cms/js/build.js index 3f86a8c891..a92365aaec 100644 --- a/cms/static/cms/js/build.js +++ b/cms/static/cms/js/build.js @@ -17,7 +17,6 @@ * done. */ modules: getModulesList([ - 'js/factories/asset_index', 'js/factories/base', 'js/factories/container', 'js/factories/course_create_rerun', diff --git a/cms/static/js/pages/asset_index.js b/cms/static/js/pages/asset_index.js new file mode 100644 index 0000000000..f1daafff4d --- /dev/null +++ b/cms/static/js/pages/asset_index.js @@ -0,0 +1,7 @@ +define( + ['js/factories/asset_index', 'common/js/utils/page_factory'], + function(AssetIndexFactory, invokePageFactory) { + 'use strict'; + invokePageFactory('AssetIndexFactory', AssetIndexFactory); + } +); diff --git a/cms/templates/asset_index.html b/cms/templates/asset_index.html index c00ee46579..d4ada8d55c 100644 --- a/cms/templates/asset_index.html +++ b/cms/templates/asset_index.html @@ -27,16 +27,16 @@ % endif -<%block name="requirejs"> +<%block name="page_bundle"> % if not waffle_flag_enabled: - require(["js/factories/asset_index"], function (AssetIndexFactory) { - AssetIndexFactory({ - assetCallbackUrl: "${asset_callback_url|n, js_escaped_string}", - uploadChunkSizeInMBs: ${chunk_size_in_mbs|n, dump_js_escaped_json}, - maxFileSizeInMBs: ${max_file_size_in_mbs|n, dump_js_escaped_json}, - maxFileSizeRedirectUrl: "${max_file_size_redirect_url|n, js_escaped_string}" - }); - }); + <%static:invoke_page_bundle page_name="js/pages/asset_index" class_name="AssetIndexFactory"> + { + assetCallbackUrl: "${asset_callback_url|n, js_escaped_string}", + uploadChunkSizeInMBs: ${ chunk_size_in_mbs| n, dump_js_escaped_json }, + maxFileSizeInMBs: ${ max_file_size_in_mbs| n, dump_js_escaped_json }, + maxFileSizeRedirectUrl: "${max_file_size_redirect_url|n, js_escaped_string}" + } + % endif diff --git a/webpack.common.config.js b/webpack.common.config.js index bc5693410b..9655245d04 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -11,9 +11,21 @@ var namespacedRequireFiles = [ path.resolve(__dirname, 'common/static/common/js/components/views/feedback_notification.js'), path.resolve(__dirname, 'common/static/common/js/components/views/feedback_prompt.js'), path.resolve(__dirname, 'common/static/common/js/components/views/feedback.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js'), + path.resolve(__dirname, 'cms/static/js/views/paging.js'), path.resolve(__dirname, 'common/static/common/js/components/utils/view_utils.js') ]; +// These files are used by RequireJS as well, so we can't remove +// the instances of "text!some/file.underscore" (which webpack currently +// processes twice). So instead we have webpack dynamically remove the `text!` prefix +// until we can remove RequireJS from the system. +var filesWithTextBangUnderscore = [ + path.resolve(__dirname, 'cms/static/js/views/assets.js'), + path.resolve(__dirname, 'cms/static/js/views/paging_header.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js') +] + var defineHeader = /\(function ?\(define(, require)?\) ?\{/; var defineFooter = /\}\)\.call\(this, define \|\| RequireJS\.define(, require \|\| RequireJS\.require)?\);/; @@ -25,6 +37,7 @@ module.exports = { Import: './cms/static/js/features/import/factories/import.js', CourseOrLibraryListing: './cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx', 'js/pages/login': './cms/static/js/pages/login.js', + 'js/pages/asset_index': './cms/static/js/pages/asset_index.js', // LMS SingleSupportForm: './lms/static/support/jsx/single_support_form.jsx', @@ -114,11 +127,26 @@ module.exports = { } ) }, + { + test: filesWithTextBangUnderscore, + loader: StringReplace.replace( + ['babel-loader'], + { + replacements: [ + { + pattern: /text!(.*\.underscore)/, + replacement: function(match, p1) { return p1; } + } + ] + } + ) + }, { test: /\.(js|jsx)$/, exclude: [ /node_modules/, - namespacedRequireFiles + namespacedRequireFiles, + filesWithTextBangUnderscore ], use: 'babel-loader' }, @@ -174,7 +202,8 @@ module.exports = { 'node_modules', 'common/static/js/vendor/', 'cms/static', - 'common/static/js/src' + 'common/static/js/src', + 'common/static/js/vendor/jQuery-File-Upload/js/' ] }, From c906c186cea2af0e56e0cacc904fe3fc591aa59f Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 24 Jan 2018 16:31:20 -0500 Subject: [PATCH 2/4] Move the context course and sock into require_page compatible forms --- cms/static/js/factories/base.js | 6 +- cms/static/js/pages/asset_index.js | 2 +- cms/static/js/pages/course.js | 11 ++++ cms/static/js/pages/login.js | 2 +- cms/static/js/sock.js | 7 ++- cms/templates/base.html | 56 ++++++++++------- .../templates/static_content.html | 24 +++---- common/djangoapps/terrain/ui_helpers.py | 6 -- webpack.common.config.js | 63 +++++++++++++++---- 9 files changed, 119 insertions(+), 58 deletions(-) create mode 100644 cms/static/js/pages/course.js diff --git a/cms/static/js/factories/base.js b/cms/static/js/factories/base.js index abaeb89d17..7f61b473c9 100644 --- a/cms/static/js/factories/base.js +++ b/cms/static/js/factories/base.js @@ -1,2 +1,6 @@ define(['js/base', 'cms/js/main', 'js/src/logger', 'datepair', 'accessibility', - 'ieshim', 'tooltip_manager', 'lang_edx', 'js/models/course']); + 'ieshim', 'tooltip_manager', 'lang_edx', 'js/models/course'], + function() { + 'use strict'; + } +); diff --git a/cms/static/js/pages/asset_index.js b/cms/static/js/pages/asset_index.js index f1daafff4d..4644fac60e 100644 --- a/cms/static/js/pages/asset_index.js +++ b/cms/static/js/pages/asset_index.js @@ -1,5 +1,5 @@ define( - ['js/factories/asset_index', 'common/js/utils/page_factory'], + ['js/factories/asset_index', 'common/js/utils/page_factory', 'js/factories/base'], function(AssetIndexFactory, invokePageFactory) { 'use strict'; invokePageFactory('AssetIndexFactory', AssetIndexFactory); diff --git a/cms/static/js/pages/course.js b/cms/static/js/pages/course.js new file mode 100644 index 0000000000..892f6c6acb --- /dev/null +++ b/cms/static/js/pages/course.js @@ -0,0 +1,11 @@ +(function(define) { + 'use strict'; + + define( + ['js/models/course'], + function(ContextCourse) { + window.course = new ContextCourse(window.pageFactoryArguments.ContextCourse[0]); + } + ); +}).call(this, define || RequireJS.define); + diff --git a/cms/static/js/pages/login.js b/cms/static/js/pages/login.js index 8caff6a833..449a1190f6 100644 --- a/cms/static/js/pages/login.js +++ b/cms/static/js/pages/login.js @@ -1,5 +1,5 @@ define( - ['js/factories/login', 'common/js/utils/page_factory'], + ['js/factories/login', 'common/js/utils/page_factory', 'js/factories/base'], function(LoginFactory, invokePageFactory) { 'use strict'; invokePageFactory('LoginFactory', LoginFactory); diff --git a/cms/static/js/sock.js b/cms/static/js/sock.js index 9a536a3c78..44653981ff 100644 --- a/cms/static/js/sock.js +++ b/cms/static/js/sock.js @@ -1,5 +1,7 @@ -require(['domReady', 'jquery', 'jquery.smoothScroll'], +define(['domReady', 'jquery', 'jquery.smoothScroll'], function(domReady, $) { + 'use strict'; + var toggleSock = function(e) { e.preventDefault(); @@ -33,4 +35,5 @@ require(['domReady', 'jquery', 'jquery.smoothScroll'], // toggling footer additional support $('.cta-show-sock').bind('click', toggleSock); }); - }); + } +); diff --git a/cms/templates/base.html b/cms/templates/base.html index 631db5a72a..f4e7907954 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -121,29 +121,39 @@ from openedx.core.djangolib.markup import HTML <%block name="modal_placeholder"> <%block name="jsextra"> - <%block name="page_bundle"> - + + % if context_course: + + % endif + % if user.is_authenticated(): + <%static:invoke_page_bundle page_name='js/sock'/> + % endif + <%block name='page_bundle'> + <%include file="widgets/segment-io-footer.html" /> diff --git a/common/djangoapps/pipeline_mako/templates/static_content.html b/common/djangoapps/pipeline_mako/templates/static_content.html index 3e48b16cf5..bc5e374483 100644 --- a/common/djangoapps/pipeline_mako/templates/static_content.html +++ b/common/djangoapps/pipeline_mako/templates/static_content.html @@ -158,7 +158,7 @@ source, template_path = Loader(engine).load_template_source(path) -<%def name="invoke_page_bundle(page_name, class_name)"> +<%def name="invoke_page_bundle(page_name, class_name=None)"> <%doc> Loads Javascript onto your page synchronously. Uses RequireJS in development and a plain script tag in production. @@ -168,16 +168,18 @@ source, template_path = Loader(engine).load_template_source(path) <% body = capture(caller.body) %> - + % if class_name: + + % endif <%self:webpack entry="${page_name}"/> diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index 86aa39ca4b..a5ed62268f 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -51,12 +51,6 @@ REQUIREJS_WAIT = { "js/sock", "gettext", "js/base", "jquery.ui", "cms/js/main", "underscore"], - # Upload - re.compile(r'^\s*Files & Uploads'): [ - 'js/base', 'jquery.ui', 'cms/js/main', 'underscore', - 'js/views/assets', 'js/views/asset' - ], - # Pages re.compile(r'^Pages \|'): [ 'js/models/explicit_url', 'js/views/tabs', diff --git a/webpack.common.config.js b/webpack.common.config.js index 9655245d04..f7e491417f 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -38,6 +38,7 @@ module.exports = { CourseOrLibraryListing: './cms/static/js/features_jsx/studio/CourseOrLibraryListing.jsx', 'js/pages/login': './cms/static/js/pages/login.js', 'js/pages/asset_index': './cms/static/js/pages/asset_index.js', + 'js/sock': './cms/static/js/sock.js', // LMS SingleSupportForm: './lms/static/support/jsx/single_support_form.jsx', @@ -158,9 +159,16 @@ module.exports = { use: 'babel-loader' }, { - test: /\.coffee$/, - exclude: /node_modules/, - use: 'coffee-loader' + test: path.resolve(__dirname, 'common/static/coffee/src/ajax_prefix.js'), + use: [ + 'babel-loader', + { + loader: 'exports-loader', + options: { + 'this.AjaxPrefix': true + } + } + ] }, { test: /\.underscore$/, @@ -170,13 +178,34 @@ module.exports = { // This file is used by both RequireJS and Webpack and depends on window globals // This is a dirty hack and shouldn't be replicated for other files. test: path.resolve(__dirname, 'cms/static/cms/js/main.js'), - use: { - loader: 'imports-loader', - options: { - AjaxPrefix: - 'exports-loader?this.AjaxPrefix!../../../../common/static/coffee/src/ajax_prefix.coffee' + loader: StringReplace.replace( + ['babel-loader'], + { + replacements: [ + { + pattern: /\(function\(AjaxPrefix\) {/, + replacement: function() { return ''; } + }, + { + pattern: /], function\(domReady, \$, str, Backbone, gettext, NotificationView\) {/, + replacement: function() { + // eslint-disable-next-line + return '], function(domReady, $, str, Backbone, gettext, NotificationView, AjaxPrefix) {'; + } + }, + { + pattern: /'..\/..\/common\/js\/components\/views\/feedback_notification',/, + replacement: function() { + return "'../../common/js/components/views/feedback_notification', 'AjaxPrefix',"; + } + }, + { + pattern: /}\).call\(this, AjaxPrefix\);/, + replacement: function() { return ''; } + } + ] } - } + ) }, { test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/, @@ -186,8 +215,9 @@ module.exports = { }, resolve: { - extensions: ['.js', '.jsx', '.json', '.coffee'], + extensions: ['.js', '.jsx', '.json'], alias: { + AjaxPrefix: 'ajax_prefix', 'edx-ui-toolkit': 'edx-ui-toolkit/src/', // @TODO: some paths in toolkit are not valid relative paths 'jquery.ui': 'jQuery-File-Upload/js/vendor/jquery.ui.widget.js', jquery: 'jquery/src/jquery', // Use the non-dist form of jQuery for better debugging + optimization @@ -196,14 +226,21 @@ module.exports = { // https://github.com/webpack/webpack/issues/304#issuecomment-272150177 // (I've tried every other suggestion solution on that page, this // was the only one that worked.) - sinon: __dirname + '/node_modules/sinon/pkg/sinon.js' + sinon: __dirname + '/node_modules/sinon/pkg/sinon.js', + 'jquery.smoothScroll': 'jquery.smooth-scroll.min', + 'jquery.timepicker': 'timepicker/jquery.timepicker', + datepair: 'timepicker/datepair', + accessibility: 'accessibility_tools', + ieshim: 'ie_shim' }, modules: [ 'node_modules', - 'common/static/js/vendor/', 'cms/static', + 'common/static', 'common/static/js/src', - 'common/static/js/vendor/jQuery-File-Upload/js/' + 'common/static/js/vendor/', + 'common/static/js/vendor/jQuery-File-Upload/js/', + 'common/static/coffee/src' ] }, From a352fc47e3a4b7ce53bb387e6581646a4a0dec56 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 30 Jan 2018 15:27:39 -0500 Subject: [PATCH 3/4] Fix all text!*.underscore import issues in webpack --- webpack.common.config.js | 90 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/webpack.common.config.js b/webpack.common.config.js index f7e491417f..44e4d3ff61 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -21,10 +21,96 @@ var namespacedRequireFiles = [ // processes twice). So instead we have webpack dynamically remove the `text!` prefix // until we can remove RequireJS from the system. var filesWithTextBangUnderscore = [ + path.resolve(__dirname, 'cms/static/js/certificates/views/certificate_details.js'), + path.resolve(__dirname, 'cms/static/js/certificates/views/certificate_editor.js'), + path.resolve(__dirname, 'cms/static/js/certificates/views/certificate_preview.js'), + path.resolve(__dirname, 'cms/static/js/certificates/views/signatory_details.js'), + path.resolve(__dirname, 'cms/static/js/certificates/views/signatory_editor.js'), + path.resolve(__dirname, 'cms/static/js/views/active_video_upload_list.js'), path.resolve(__dirname, 'cms/static/js/views/assets.js'), + path.resolve(__dirname, 'cms/static/js/views/course_video_settings.js'), + path.resolve(__dirname, 'cms/static/js/views/edit_chapter.js'), + path.resolve(__dirname, 'cms/static/js/views/experiment_group_edit.js'), + path.resolve(__dirname, 'cms/static/js/views/license.js'), + path.resolve(__dirname, 'cms/static/js/views/modals/move_xblock_modal.js'), + path.resolve(__dirname, 'cms/static/js/views/move_xblock_breadcrumb.js'), + path.resolve(__dirname, 'cms/static/js/views/move_xblock_list.js'), path.resolve(__dirname, 'cms/static/js/views/paging_header.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js') -] + path.resolve(__dirname, 'cms/static/js/views/previous_video_upload_list.js'), + path.resolve(__dirname, 'cms/static/js/views/previous_video_upload.js'), + path.resolve(__dirname, 'cms/static/js/views/video_thumbnail.js'), + path.resolve(__dirname, 'cms/static/js/views/video_transcripts.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/feedback.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/paginated_view.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/paging_header.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/progress_circle_view.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/search_field.js'), + path.resolve(__dirname, 'common/static/common/js/components/views/tabbed_view.js'), + path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_board_view.js'), + path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_fake_breadcrumbs.js'), + path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_search_view.js'), + path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js'), + path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/certificates.js'), + path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/enrollment_modal.js'), + path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/enrollment.js'), + path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/manage_user.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/edit_team_members.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/edit_team.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/instructor_tools.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/team_card.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/team_profile_header_actions.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/team_profile.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/teams_tab.js'), + path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/topic_teams.js'), + path.resolve(__dirname, 'lms/static/js/api_admin/views/catalog_preview.js'), + path.resolve(__dirname, 'lms/static/js/components/card/views/card.js'), + path.resolve(__dirname, 'lms/static/js/components/header/views/header.js'), + path.resolve(__dirname, 'lms/static/js/financial-assistance/views/financial_assistance_form_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/certificate_list_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/certificate_status_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/collection_list_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/course_card_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/course_enroll_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/course_entitlement_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/expired_notification_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/explore_new_programs_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_card_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_details_sidebar_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_details_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_header_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/sidebar_view.js'), + path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/upgrade_message_view.js'), + path.resolve(__dirname, 'lms/static/js/student_account/views/account_section_view.js'), + path.resolve(__dirname, 'lms/static/js/student_account/views/account_settings_fields.js'), + path.resolve(__dirname, 'lms/static/js/student_account/views/account_settings_view.js'), + path.resolve(__dirname, 'lms/static/js/student_account/views/FormView.js'), + path.resolve(__dirname, 'lms/static/js/student_account/views/LoginView.js'), + path.resolve(__dirname, 'lms/static/js/student_account/views/RegisterView.js'), + path.resolve(__dirname, 'lms/static/js/views/fields.js'), + path.resolve(__dirname, 'lms/static/js/views/image_field.js'), + path.resolve(__dirname, 'lms/static/js/views/message_banner.js'), + path.resolve(__dirname, 'openedx/features/course_bookmarks/static/course_bookmarks/js/views/bookmarks_list.js'), + path.resolve(__dirname, 'openedx/features/course_search/static/course_search/js/spec/course_search_spec.js'), + path.resolve( + __dirname, + 'openedx/features/course_search/static/course_search/js/views/course_search_results_view.js' + ), + path.resolve( + __dirname, + 'openedx/features/course_search/static/course_search/js/views/dashboard_search_results_view.js' + ), + path.resolve(__dirname, 'openedx/features/course_search/static/course_search/js/views/search_results_view.js'), + path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/badge_list_container.js'), + path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/badge_list_view.js'), + path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/badge_view.js'), + path.resolve( + __dirname, + 'openedx/features/learner_profile/static/learner_profile/js/views/learner_profile_fields.js' + ), + path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/section_two_tab.js'), + path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/share_modal_view.js') +]; var defineHeader = /\(function ?\(define(, require)?\) ?\{/; var defineFooter = /\}\)\.call\(this, define \|\| RequireJS\.define(, require \|\| RequireJS\.require)?\);/; From cb5ae11b136cc7d76e2578a981a500d8fb711f51 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 20 Feb 2018 16:34:56 -0500 Subject: [PATCH 4/4] Move pattern-replacement file lists into a separate file --- webpack-config/file-lists.js | 108 +++++++++++++++++++++++++++++++++ webpack.common.config.js | 113 ++--------------------------------- 2 files changed, 113 insertions(+), 108 deletions(-) create mode 100644 webpack-config/file-lists.js diff --git a/webpack-config/file-lists.js b/webpack-config/file-lists.js new file mode 100644 index 0000000000..fde698a0ab --- /dev/null +++ b/webpack-config/file-lists.js @@ -0,0 +1,108 @@ +var path = require('path'); + +module.exports = { + namespacedRequire: [ + path.resolve(__dirname, '../common/static/common/js/components/views/feedback_notification.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/feedback_prompt.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/feedback.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/paging_footer.js'), + path.resolve(__dirname, '../cms/static/js/views/paging.js'), + path.resolve(__dirname, '../common/static/common/js/components/utils/view_utils.js') + ], + + // These files are used by RequireJS as well, so we can't remove + // the instances of "text!some/file.underscore" (which webpack currently + // processes twice). So instead we have webpack dynamically remove the `text!` prefix + // until we can remove RequireJS from the system. + textBangUnderscore: [ + path.resolve(__dirname, '../cms/static/js/certificates/views/certificate_details.js'), + path.resolve(__dirname, '../cms/static/js/certificates/views/certificate_editor.js'), + path.resolve(__dirname, '../cms/static/js/certificates/views/certificate_preview.js'), + path.resolve(__dirname, '../cms/static/js/certificates/views/signatory_details.js'), + path.resolve(__dirname, '../cms/static/js/certificates/views/signatory_editor.js'), + path.resolve(__dirname, '../cms/static/js/views/active_video_upload_list.js'), + path.resolve(__dirname, '../cms/static/js/views/assets.js'), + path.resolve(__dirname, '../cms/static/js/views/course_video_settings.js'), + path.resolve(__dirname, '../cms/static/js/views/edit_chapter.js'), + path.resolve(__dirname, '../cms/static/js/views/experiment_group_edit.js'), + path.resolve(__dirname, '../cms/static/js/views/license.js'), + path.resolve(__dirname, '../cms/static/js/views/modals/move_xblock_modal.js'), + path.resolve(__dirname, '../cms/static/js/views/move_xblock_breadcrumb.js'), + path.resolve(__dirname, '../cms/static/js/views/move_xblock_list.js'), + path.resolve(__dirname, '../cms/static/js/views/paging_header.js'), + path.resolve(__dirname, '../cms/static/js/views/previous_video_upload_list.js'), + path.resolve(__dirname, '../cms/static/js/views/previous_video_upload.js'), + path.resolve(__dirname, '../cms/static/js/views/video_thumbnail.js'), + path.resolve(__dirname, '../cms/static/js/views/video_transcripts.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/feedback.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/paginated_view.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/paging_footer.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/paging_header.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/progress_circle_view.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/search_field.js'), + path.resolve(__dirname, '../common/static/common/js/components/views/tabbed_view.js'), + path.resolve(__dirname, '../lms/djangoapps/discussion/static/discussion/js/views/discussion_board_view.js'), + path.resolve(__dirname, '../lms/djangoapps/discussion/static/discussion/js/views/discussion_fake_breadcrumbs.js'), + path.resolve(__dirname, '../lms/djangoapps/discussion/static/discussion/js/views/discussion_search_view.js'), + path.resolve(__dirname, '../lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js'), + path.resolve(__dirname, '../lms/djangoapps/support/static/support/js/views/certificates.js'), + path.resolve(__dirname, '../lms/djangoapps/support/static/support/js/views/enrollment_modal.js'), + path.resolve(__dirname, '../lms/djangoapps/support/static/support/js/views/enrollment.js'), + path.resolve(__dirname, '../lms/djangoapps/support/static/support/js/views/manage_user.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/edit_team_members.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/edit_team.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/instructor_tools.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/team_card.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/team_profile_header_actions.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/team_profile.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/teams_tab.js'), + path.resolve(__dirname, '../lms/djangoapps/teams/static/teams/js/views/topic_teams.js'), + path.resolve(__dirname, '../lms/static/js/api_admin/views/catalog_preview.js'), + path.resolve(__dirname, '../lms/static/js/components/card/views/card.js'), + path.resolve(__dirname, '../lms/static/js/components/header/views/header.js'), + path.resolve(__dirname, '../lms/static/js/financial-assistance/views/financial_assistance_form_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/certificate_list_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/certificate_status_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/collection_list_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/course_card_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/course_enroll_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/course_entitlement_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/expired_notification_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/explore_new_programs_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/program_card_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/program_details_sidebar_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/program_details_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/program_header_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/sidebar_view.js'), + path.resolve(__dirname, '../lms/static/js/learner_dashboard/views/upgrade_message_view.js'), + path.resolve(__dirname, '../lms/static/js/student_account/views/account_section_view.js'), + path.resolve(__dirname, '../lms/static/js/student_account/views/account_settings_fields.js'), + path.resolve(__dirname, '../lms/static/js/student_account/views/account_settings_view.js'), + path.resolve(__dirname, '../lms/static/js/student_account/views/FormView.js'), + path.resolve(__dirname, '../lms/static/js/student_account/views/LoginView.js'), + path.resolve(__dirname, '../lms/static/js/student_account/views/RegisterView.js'), + path.resolve(__dirname, '../lms/static/js/views/fields.js'), + path.resolve(__dirname, '../lms/static/js/views/image_field.js'), + path.resolve(__dirname, '../lms/static/js/views/message_banner.js'), + path.resolve(__dirname, '../openedx/features/course_bookmarks/static/course_bookmarks/js/views/bookmarks_list.js'), + path.resolve(__dirname, '../openedx/features/course_search/static/course_search/js/spec/course_search_spec.js'), + path.resolve( + __dirname, + 'openedx/features/course_search/static/course_search/js/views/course_search_results_view.js' + ), + path.resolve( + __dirname, + 'openedx/features/course_search/static/course_search/js/views/dashboard_search_results_view.js' + ), + path.resolve(__dirname, '../openedx/features/course_search/static/course_search/js/views/search_results_view.js'), + path.resolve(__dirname, '../openedx/features/learner_profile/static/learner_profile/js/views/badge_list_container.js'), + path.resolve(__dirname, '../openedx/features/learner_profile/static/learner_profile/js/views/badge_list_view.js'), + path.resolve(__dirname, '../openedx/features/learner_profile/static/learner_profile/js/views/badge_view.js'), + path.resolve( + __dirname, + 'openedx/features/learner_profile/static/learner_profile/js/views/learner_profile_fields.js' + ), + path.resolve(__dirname, '../openedx/features/learner_profile/static/learner_profile/js/views/section_two_tab.js'), + path.resolve(__dirname, '../openedx/features/learner_profile/static/learner_profile/js/views/share_modal_view.js') + ] +} diff --git a/webpack.common.config.js b/webpack.common.config.js index 44e4d3ff61..728169d47f 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -7,110 +7,7 @@ var webpack = require('webpack'); var BundleTracker = require('webpack-bundle-tracker'); var StringReplace = require('string-replace-webpack-plugin'); -var namespacedRequireFiles = [ - path.resolve(__dirname, 'common/static/common/js/components/views/feedback_notification.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/feedback_prompt.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/feedback.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js'), - path.resolve(__dirname, 'cms/static/js/views/paging.js'), - path.resolve(__dirname, 'common/static/common/js/components/utils/view_utils.js') -]; - -// These files are used by RequireJS as well, so we can't remove -// the instances of "text!some/file.underscore" (which webpack currently -// processes twice). So instead we have webpack dynamically remove the `text!` prefix -// until we can remove RequireJS from the system. -var filesWithTextBangUnderscore = [ - path.resolve(__dirname, 'cms/static/js/certificates/views/certificate_details.js'), - path.resolve(__dirname, 'cms/static/js/certificates/views/certificate_editor.js'), - path.resolve(__dirname, 'cms/static/js/certificates/views/certificate_preview.js'), - path.resolve(__dirname, 'cms/static/js/certificates/views/signatory_details.js'), - path.resolve(__dirname, 'cms/static/js/certificates/views/signatory_editor.js'), - path.resolve(__dirname, 'cms/static/js/views/active_video_upload_list.js'), - path.resolve(__dirname, 'cms/static/js/views/assets.js'), - path.resolve(__dirname, 'cms/static/js/views/course_video_settings.js'), - path.resolve(__dirname, 'cms/static/js/views/edit_chapter.js'), - path.resolve(__dirname, 'cms/static/js/views/experiment_group_edit.js'), - path.resolve(__dirname, 'cms/static/js/views/license.js'), - path.resolve(__dirname, 'cms/static/js/views/modals/move_xblock_modal.js'), - path.resolve(__dirname, 'cms/static/js/views/move_xblock_breadcrumb.js'), - path.resolve(__dirname, 'cms/static/js/views/move_xblock_list.js'), - path.resolve(__dirname, 'cms/static/js/views/paging_header.js'), - path.resolve(__dirname, 'cms/static/js/views/previous_video_upload_list.js'), - path.resolve(__dirname, 'cms/static/js/views/previous_video_upload.js'), - path.resolve(__dirname, 'cms/static/js/views/video_thumbnail.js'), - path.resolve(__dirname, 'cms/static/js/views/video_transcripts.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/feedback.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/paginated_view.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/paging_footer.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/paging_header.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/progress_circle_view.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/search_field.js'), - path.resolve(__dirname, 'common/static/common/js/components/views/tabbed_view.js'), - path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_board_view.js'), - path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_fake_breadcrumbs.js'), - path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_search_view.js'), - path.resolve(__dirname, 'lms/djangoapps/discussion/static/discussion/js/views/discussion_user_profile_view.js'), - path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/certificates.js'), - path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/enrollment_modal.js'), - path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/enrollment.js'), - path.resolve(__dirname, 'lms/djangoapps/support/static/support/js/views/manage_user.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/edit_team_members.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/edit_team.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/instructor_tools.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/team_card.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/team_profile_header_actions.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/team_profile.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/teams_tab.js'), - path.resolve(__dirname, 'lms/djangoapps/teams/static/teams/js/views/topic_teams.js'), - path.resolve(__dirname, 'lms/static/js/api_admin/views/catalog_preview.js'), - path.resolve(__dirname, 'lms/static/js/components/card/views/card.js'), - path.resolve(__dirname, 'lms/static/js/components/header/views/header.js'), - path.resolve(__dirname, 'lms/static/js/financial-assistance/views/financial_assistance_form_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/certificate_list_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/certificate_status_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/collection_list_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/course_card_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/course_enroll_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/course_entitlement_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/expired_notification_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/explore_new_programs_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_card_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_details_sidebar_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_details_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/program_header_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/sidebar_view.js'), - path.resolve(__dirname, 'lms/static/js/learner_dashboard/views/upgrade_message_view.js'), - path.resolve(__dirname, 'lms/static/js/student_account/views/account_section_view.js'), - path.resolve(__dirname, 'lms/static/js/student_account/views/account_settings_fields.js'), - path.resolve(__dirname, 'lms/static/js/student_account/views/account_settings_view.js'), - path.resolve(__dirname, 'lms/static/js/student_account/views/FormView.js'), - path.resolve(__dirname, 'lms/static/js/student_account/views/LoginView.js'), - path.resolve(__dirname, 'lms/static/js/student_account/views/RegisterView.js'), - path.resolve(__dirname, 'lms/static/js/views/fields.js'), - path.resolve(__dirname, 'lms/static/js/views/image_field.js'), - path.resolve(__dirname, 'lms/static/js/views/message_banner.js'), - path.resolve(__dirname, 'openedx/features/course_bookmarks/static/course_bookmarks/js/views/bookmarks_list.js'), - path.resolve(__dirname, 'openedx/features/course_search/static/course_search/js/spec/course_search_spec.js'), - path.resolve( - __dirname, - 'openedx/features/course_search/static/course_search/js/views/course_search_results_view.js' - ), - path.resolve( - __dirname, - 'openedx/features/course_search/static/course_search/js/views/dashboard_search_results_view.js' - ), - path.resolve(__dirname, 'openedx/features/course_search/static/course_search/js/views/search_results_view.js'), - path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/badge_list_container.js'), - path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/badge_list_view.js'), - path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/badge_view.js'), - path.resolve( - __dirname, - 'openedx/features/learner_profile/static/learner_profile/js/views/learner_profile_fields.js' - ), - path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/section_two_tab.js'), - path.resolve(__dirname, 'openedx/features/learner_profile/static/learner_profile/js/views/share_modal_view.js') -]; +var files = require('./webpack-config/file-lists.js'); var defineHeader = /\(function ?\(define(, require)?\) ?\{/; var defineFooter = /\}\)\.call\(this, define \|\| RequireJS\.define(, require \|\| RequireJS\.require)?\);/; @@ -197,7 +94,7 @@ module.exports = { ], rules: [ { - test: namespacedRequireFiles, + test: files.namespacedRequire, loader: StringReplace.replace( ['babel-loader'], { @@ -215,7 +112,7 @@ module.exports = { ) }, { - test: filesWithTextBangUnderscore, + test: files.textBangUnderscore, loader: StringReplace.replace( ['babel-loader'], { @@ -232,8 +129,8 @@ module.exports = { test: /\.(js|jsx)$/, exclude: [ /node_modules/, - namespacedRequireFiles, - filesWithTextBangUnderscore + files.namespacedRequire, + files.textBangUnderscore ], use: 'babel-loader' },