diff --git a/common/lib/xmodule/xmodule/assets/word_cloud/src/js/word_cloud.js b/common/lib/xmodule/xmodule/assets/word_cloud/src/js/word_cloud.js index 5384eb56ef..7d31c2d752 100644 --- a/common/lib/xmodule/xmodule/assets/word_cloud/src/js/word_cloud.js +++ b/common/lib/xmodule/xmodule/assets/word_cloud/src/js/word_cloud.js @@ -1,7 +1,3 @@ -import WordCloudMain from './word_cloud_main'; +const WordCloudMain = require('xmodule/assets/word_cloud/src/js/word_cloud_main.js'); -function WordCloud(el) { - return new WordCloudMain(el); -} - -window.WordCloud = WordCloud; +window.WordCloud = WordCloudMain.default; diff --git a/common/lib/xmodule/xmodule/word_cloud_module.py b/common/lib/xmodule/xmodule/word_cloud_module.py index 16383272bc..23eae87c98 100644 --- a/common/lib/xmodule/xmodule/word_cloud_module.py +++ b/common/lib/xmodule/xmodule/word_cloud_module.py @@ -91,6 +91,7 @@ class WordCloudFields(object): class WordCloudModule(WordCloudFields, XModule): """WordCloud Xmodule""" + js = {'js': [resource_string(__name__, 'assets/word_cloud/src/js/word_cloud.js')]} css = {'scss': [resource_string(__name__, 'css/word_cloud/display.scss')]} js_module_name = "WordCloud" @@ -245,11 +246,6 @@ class WordCloudModule(WordCloudFields, XModule): 'submitted': self.submitted, })) - fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/d3.min.js')) - fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/d3.layout.cloud.js')) - fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/word_cloud.js')) - fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/word_cloud_main.js')) - return fragment def author_view(self, context): diff --git a/openedx/features/course_search/static/course_search/js/course_search_factory.js b/openedx/features/course_search/static/course_search/js/course_search_factory.js index 25b23dd771..b64e8d9f8b 100644 --- a/openedx/features/course_search/static/course_search/js/course_search_factory.js +++ b/openedx/features/course_search/static/course_search/js/course_search_factory.js @@ -56,5 +56,6 @@ router.trigger('search', requestedQuery); } }; - }); -}(define || RequireJS.define)); + } + ); +}).call(this, define || RequireJS.define); diff --git a/webpack.common.config.js b/webpack.common.config.js index 0d0428f16c..decae865b7 100644 --- a/webpack.common.config.js +++ b/webpack.common.config.js @@ -6,6 +6,7 @@ var path = require('path'); var webpack = require('webpack'); var BundleTracker = require('webpack-bundle-tracker'); var StringReplace = require('string-replace-webpack-plugin'); +var Merge = require('webpack-merge'); var files = require('./webpack-config/file-lists.js'); var xmoduleJS = require('./common/static/xmodule/webpack.xmodule.config.js'); @@ -25,7 +26,7 @@ var defineFooter = new RegExp('(' + defineCallFooter.source + ')|(' + defineDirectFooter.source + ')|(' + defineFancyFooter.source + ')', 'm'); -module.exports = { +module.exports = Merge.smart({ context: __dirname, entry: { @@ -211,24 +212,30 @@ module.exports = { replacements: [ { pattern: /\(function\(AjaxPrefix\) {/, - replacement: function () { return ''; } + replacement: function() { return ''; } }, { pattern: /], function\(domReady, \$, str, Backbone, gettext, NotificationView\) {/, - replacement: function () { + replacement: function() { // eslint-disable-next-line return '], function(domReady, $, str, Backbone, gettext, NotificationView, AjaxPrefix) {'; } }, { pattern: /'..\/..\/common\/js\/components\/views\/feedback_notification',/, - replacement: function () { + replacement: function() { return "'../../common/js/components/views/feedback_notification', 'AjaxPrefix',"; } }, { pattern: /}\).call\(this, AjaxPrefix\);/, - replacement: function () { return ''; } + replacement: function() { return ''; } + }, + { + pattern: /'..\/..\/common\/js\/components\/views\/feedback_notification',/, + replacement: function() { + return "'../../common/js/components/views/feedback_notification', 'AjaxPrefix',"; + } } ] } @@ -318,7 +325,6 @@ module.exports = { // (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', - WordCloudMain: 'xmodule/assets/word_cloud/public/js/word_cloud_main', hls: 'hls.js/dist/hls.js' }, modules: [ @@ -329,6 +335,7 @@ module.exports = { 'lms/static', 'common/lib/xmodule', 'common/lib/xmodule/xmodule/js/src', + 'common/lib/xmodule/xmodule/assets/word_cloud/src/js', 'common/static', 'common/static/coffee/src', 'common/static/common/js', @@ -349,15 +356,17 @@ module.exports = { }, externals: { + $: 'jQuery', backbone: 'Backbone', + canvas: 'canvas', coursetalk: 'CourseTalk', gettext: 'gettext', jquery: 'jQuery', logger: 'Logger', underscore: '_', URI: 'URI', - XModule: 'XModule', - XBlockToXModuleShim: 'XBlockToXModuleShim' + XBlockToXModuleShim: 'XBlockToXModuleShim', + XModule: 'XModule' }, watchOptions: { @@ -367,4 +376,5 @@ module.exports = { node: { fs: 'empty' } -}; + +}, xmoduleJS); diff --git a/webpack.prod.config.js b/webpack.prod.config.js index adf1ec46cc..97570626b2 100644 --- a/webpack.prod.config.js +++ b/webpack.prod.config.js @@ -63,7 +63,7 @@ var requireCompatConfig = Merge.smart(optimizedConfig, { // overwrite those because it means that we'll be serving assets with shorter // cache times. RequireJS never looks at the webpack-stats.json file. requireCompatConfig.plugins = requireCompatConfig.plugins.filter( - plugin => !plugin.options || (plugin.options && plugin.options.filename != 'webpack-stats.json') + function(plugin) { return !plugin.options || (plugin.options && plugin.options.filename !== 'webpack-stats.json'); } ); module.exports = [optimizedConfig, requireCompatConfig];