Skip to content

Commit

Permalink
build: commit xmodule Webpack config and delete xmodule_assets script
Browse files Browse the repository at this point in the history
TODO: will copy in commit message from PR when squash-merging

Part of: #32481
  • Loading branch information
kdmccormick committed Jul 8, 2023
1 parent 5391623 commit ff3ab4d
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 504 deletions.
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_discussion_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_has_permission(self):
"""
permission_canary = object()
with mock.patch(
'lms.djangoapps.discussion.django_comment_client.permissions.has_permission',
'xmodule.discussion_block.has_permission',
return_value=permission_canary,
) as has_perm:
actual_permission = self.block.has_permission("test_permission")
Expand Down
59 changes: 1 addition & 58 deletions pavelib/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ class SassWatcher(PatternMatchingEventHandler):
"""
ignore_directories = True
patterns = ['*.scss']
ignore_patterns = ['common/static/xmodule/*']

def register(self, observer, directories):
"""
Expand Down Expand Up @@ -385,47 +384,6 @@ def on_any_event(self, event):
traceback.print_exc()


class XModuleSassWatcher(SassWatcher):
"""
Watches for sass file changes
"""
ignore_directories = True
ignore_patterns = []

@debounce()
def on_any_event(self, event):
print('\tCHANGED:', event.src_path)
try:
process_xmodule_assets()
except Exception: # pylint: disable=broad-except
traceback.print_exc()


class XModuleAssetsWatcher(PatternMatchingEventHandler):
"""
Watches for css and js file changes
"""
ignore_directories = True
patterns = ['*.css', '*.js']

def register(self, observer):
"""
Register files with observer
"""
observer.schedule(self, 'xmodule/', recursive=True)

@debounce()
def on_any_event(self, event):
print('\tCHANGED:', event.src_path)
try:
process_xmodule_assets()
except Exception: # pylint: disable=broad-except
traceback.print_exc()

# To refresh the hash values of static xmodule content
restart_django_servers()


@task
@no_help
@cmdopts([
Expand Down Expand Up @@ -700,19 +658,6 @@ def copy_vendor_library_dir(library_dir, skip_if_missing=False):
copy_vendor_library(library, skip_if_missing=True)


@task
@needs(
'pavelib.prereqs.install_python_prereqs',
)
@no_help
def process_xmodule_assets():
"""
Process XModule static assets.
"""
sh('xmodule_assets common/static/xmodule')
print("\t\tFinished processing xmodule assets.")


def restart_django_servers():
"""
Restart the django server.
Expand Down Expand Up @@ -908,8 +853,6 @@ def watch_assets(options):
observer = Observer(timeout=wait)

SassWatcher().register(observer, sass_directories)
XModuleSassWatcher().register(observer, ['xmodule/'])
XModuleAssetsWatcher().register(observer)

print("Starting asset watcher...")
observer.start()
Expand All @@ -931,6 +874,7 @@ def watch_assets(options):
@task
@needs(
'pavelib.prereqs.install_node_prereqs',
'pavelib.prereqs.install_python_prereqs',
)
@consume_args
@timed
Expand Down Expand Up @@ -982,7 +926,6 @@ def update_assets(args):
args = parser.parse_args(args)
collect_log_args = {}

process_xmodule_assets()
process_npm_assets()

# Build Webpack
Expand Down
1 change: 0 additions & 1 deletion pavelib/js_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
@needs(
'pavelib.prereqs.install_node_prereqs',
'pavelib.utils.test.utils.clean_reports_dir',
'pavelib.assets.process_xmodule_assets',
)
@cmdopts([
("suite=", "s", "Test suite to run"),
Expand Down
2 changes: 0 additions & 2 deletions pavelib/paver_tests/test_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def verify_server_task(self, task_name, options):
expected_asset_settings = "test_static_optimized"
expected_collect_static = not is_fast and expected_settings != Env.DEVSTACK_SETTINGS
if not is_fast:
expected_messages.append("xmodule_assets common/static/xmodule")
expected_messages.append("install npm_assets")
expected_messages.extend(
[c.format(settings=expected_asset_settings,
Expand Down Expand Up @@ -275,7 +274,6 @@ def verify_run_all_servers_task(self, options):
expected_collect_static = not is_fast and expected_settings != Env.DEVSTACK_SETTINGS
expected_messages = []
if not is_fast:
expected_messages.append("xmodule_assets common/static/xmodule")
expected_messages.append("install npm_assets")
expected_messages.extend(
[c.format(settings=expected_asset_settings,
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,5 @@
],
'xblock.v1': XBLOCKS,
'xblock_asides.v1': XBLOCKS_ASIDES,
'console_scripts': [
'xmodule_assets = xmodule.static_content:main',
],
}
)
2 changes: 1 addition & 1 deletion webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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');
var xmoduleJS = require('./webpack.xmodule.config.js');

var filesWithRequireJSBlocks = [
path.resolve(__dirname, 'common/static/common/js/components/utils/view_utils.js'),
Expand Down
136 changes: 136 additions & 0 deletions webpack.xmodule.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
module.exports = {
"entry": {
"AboutBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/display.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/collapsible.js",
"./xmodule/js/src/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"AboutBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/edit.js"
],
"AnnotatableBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/display.js",
"./xmodule/js/src/annotatable/display.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/collapsible.js"
],
"AnnotatableBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/raw/edit/xml.js"
],
"ConditionalBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/conditional/display.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/collapsible.js"
],
"ConditionalBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/sequence/edit.js"
],
"CourseInfoBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/display.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/collapsible.js",
"./xmodule/js/src/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"CourseInfoBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/edit.js"
],
"CustomTagBlockDisplay": "./xmodule/js/src/xmodule.js",
"CustomTagBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/raw/edit/xml.js"
],
"HtmlBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/display.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/collapsible.js",
"./xmodule/js/src/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"HtmlBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/edit.js"
],
"LTIBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/lti/lti.js"
],
"LTIBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/raw/edit/metadata-only.js"
],
"LibraryContentBlockDisplay": "./xmodule/js/src/xmodule.js",
"LibraryContentBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/vertical/edit.js"
],
"PollBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/poll/poll.js",
"./xmodule/js/src/poll/poll_main.js"
],
"PollBlockEditor": "./xmodule/js/src/xmodule.js",
"ProblemBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/capa/display.js",
"./xmodule/js/src/collapsible.js",
"./xmodule/js/src/capa/imageinput.js",
"./xmodule/js/src/capa/schematic.js"
],
"ProblemBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/problem/edit.js"
],
"SequenceBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/sequence/display.js"
],
"SequenceBlockEditor": "./xmodule/js/src/xmodule.js",
"SplitTestBlockDisplay": "./xmodule/js/src/xmodule.js",
"SplitTestBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/sequence/edit.js"
],
"StaticTabBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/display.js",
"./xmodule/js/src/javascript_loader.js",
"./xmodule/js/src/collapsible.js",
"./xmodule/js/src/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"StaticTabBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/html/edit.js"
],
"VideoBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/video/10_main.js"
],
"VideoBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/tabs/tabs-aggregator.js"
],
"WordCloudBlockDisplay": [
"./xmodule/js/src/xmodule.js",
"./xmodule/assets/word_cloud/src/js/word_cloud.js"
],
"WordCloudBlockEditor": [
"./xmodule/js/src/xmodule.js",
"./xmodule/js/src/raw/edit/metadata-only.js"
]
}
};
19 changes: 0 additions & 19 deletions xmodule/annotatable_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import textwrap

from lxml import etree
from pkg_resources import resource_filename
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Scope, String
Expand All @@ -15,7 +14,6 @@
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment
from xmodule.xml_block import XmlMixin
from xmodule.x_module import (
HTMLSnippet,
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
Expand All @@ -35,7 +33,6 @@ class AnnotatableBlock(
XmlMixin,
EditingMixin,
XModuleToXBlockMixin,
HTMLSnippet,
ResourceTemplates,
XModuleMixin,
):
Expand Down Expand Up @@ -73,22 +70,6 @@ class AnnotatableBlock(

uses_xmodule_styles_setup = True

preview_view_js = {
'js': [
resource_filename(__name__, 'js/src/html/display.js'),
resource_filename(__name__, 'js/src/annotatable/display.js'),
resource_filename(__name__, 'js/src/javascript_loader.js'),
resource_filename(__name__, 'js/src/collapsible.js'),
],
'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'),
}

studio_view_js = {
'js': [
resource_filename(__name__, 'js/src/raw/edit/xml.js'),
],
'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'),
}
studio_js_module_name = "XMLEditingDescriptor"
mako_template = "widgets/raw-edit.html"

Expand Down
9 changes: 3 additions & 6 deletions xmodule/assets/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Currently, edx-platform XBlock JS is defined both here in `xmodule/assets`_ and

* For many older blocks, their JS is:

* bundled using a generated Webpack config at ``common/static/xmodule/webpack.xmodule.config.js``,
* bundled using a `webpack.xmodule.config.js`_,
* which is included into `webpack.common.config.js`_,
* allowing it to be included into XBlock fragments using ``add_webpack_js_to_fragment`` from `builtin_assets.py`_.

Expand All @@ -74,11 +74,7 @@ Currently, edx-platform XBlock JS is defined both here in `xmodule/assets`_ and
* `VerticalBlock`_
* `LibrarySourcedBlock`_

As part of an `active build refactoring`_:

* We will move ``webpack.xmodule.config.js`` here instead of generating it.
* We will consolidate all edx-platform XBlock JS here in `xmodule/assets`_.
* We will delete the ``xmodule_assets`` script.
As part of an `active build refactoring`_, we will soon consolidate all edx-platform XBlock JS here in `xmodule/assets`_.

.. _xmodule/assets: https://github.com/openedx/edx-platform/tree/master/xmodule/assets
.. _xmodule/js: https://github.com/openedx/edx-platform/tree/master/xmodule/js
Expand All @@ -91,4 +87,5 @@ As part of an `active build refactoring`_:
.. _builtin_assets.py: https://github.com/openedx/edx-platform/tree/master/xmodule/util/builtin_assets.py
.. _static_content.py: https://github.com/openedx/edx-platform/blob/master/xmodule/static_content.py
.. _library_source_block/style.css: https://github.com/openedx/edx-platform/blob/master/xmodule/assets/library_source_block/style.css
.. _webpack.xmodule.config.js: https://github.com/openedx/edx-platform/blob/master/webpack.xmodule.config.js
.. _webpack.common.config.js: https://github.com/openedx/edx-platform/blob/master/webpack.common.config.js
Loading

0 comments on commit ff3ab4d

Please sign in to comment.