Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: consolidate xmodule/js into xmodule/assets (WIP) #32691

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions cms/djangoapps/pipeline_js/utils.py

This file was deleted.

9 changes: 0 additions & 9 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,15 +1383,6 @@
'source_filenames': base_vendor_js,
'output_filename': 'js/cms-base-vendor.js',
},
'module-js': {
'source_filenames': (
rooted_glob(COMMON_ROOT / 'static/', 'xmodule/descriptors/js/*.js') +
rooted_glob(COMMON_ROOT / 'static/', 'xmodule/modules/js/*.js') +
rooted_glob(COMMON_ROOT / 'static/', 'common/js/discussion/*.js')
),
'output_filename': 'js/cms-modules.js',
'test_order': 1
},
}

STATICFILES_IGNORE_PATTERNS = (
Expand Down
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
8 changes: 0 additions & 8 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2586,14 +2586,6 @@ def _make_locale_paths(settings): # pylint: disable=missing-function-docstring
'source_filenames': main_vendor_js,
'output_filename': 'js/lms-main_vendor.js',
},
'module-descriptor-js': {
'source_filenames': rooted_glob(COMMON_ROOT / 'static/', 'xmodule/descriptors/js/*.js'),
'output_filename': 'js/lms-module-descriptors.js',
},
'module-js': {
'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'),
'output_filename': 'js/lms-modules.js',
},
'discussion': {
'source_filenames': discussion_js,
'output_filename': 'js/discussion.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
<script type="text/javascript" src="${static.url('js/vendor/tinymce/js/tinymce/jquery.tinymce.min.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/jQuery-File-Upload/js/jquery.fileupload.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/jquery.qubit.js')}"></script>
<%static:js group='module-descriptor-js'/>
<%static:webpack entry='HtmlBlockEditor'/>
<link rel="stylesheet" href="${static.url('css/HtmlBlockEditor.css')}">
<%static:js group='instructor_dash'/>
<%static:js group='application'/>

Expand Down
1 change: 0 additions & 1 deletion lms/templates/wiki/preview_inline.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h1 class="page-header">{{ title }}</h1>
</section>

{% javascript 'application' %}
{% javascript 'module-js' %}
{% with mathjax_mode='wiki' %}
{% include "mathjax_include.html" %}
{% endwith %}
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/assets/xmodule.js",
"./xmodule/assets/html/display.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/collapsible.js",
"./xmodule/assets/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"AboutBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/edit.js"
],
"AnnotatableBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/display.js",
"./xmodule/assets/annotatable/display.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/collapsible.js"
],
"AnnotatableBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/raw/edit/xml.js"
],
"ConditionalBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/conditional/display.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/collapsible.js"
],
"ConditionalBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/sequence/edit.js"
],
"CourseInfoBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/display.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/collapsible.js",
"./xmodule/assets/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"CourseInfoBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/edit.js"
],
"CustomTagBlockDisplay": "./xmodule/assets/xmodule.js",
"CustomTagBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/raw/edit/xml.js"
],
"HtmlBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/display.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/collapsible.js",
"./xmodule/assets/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"HtmlBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/edit.js"
],
"LTIBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/lti/lti.js"
],
"LTIBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/raw/edit/metadata-only.js"
],
"LibraryContentBlockDisplay": "./xmodule/assets/xmodule.js",
"LibraryContentBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/vertical/edit.js"
],
"PollBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/poll/poll.js",
"./xmodule/assets/poll/poll_main.js"
],
"PollBlockEditor": "./xmodule/assets/xmodule.js",
"ProblemBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/capa/display.js",
"./xmodule/assets/collapsible.js",
"./xmodule/assets/capa/imageinput.js",
"./xmodule/assets/capa/schematic.js"
],
"ProblemBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/problem/edit.js"
],
"SequenceBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/sequence/display.js"
],
"SequenceBlockEditor": "./xmodule/assets/xmodule.js",
"SplitTestBlockDisplay": "./xmodule/assets/xmodule.js",
"SplitTestBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/sequence/edit.js"
],
"StaticTabBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/display.js",
"./xmodule/assets/javascript_loader.js",
"./xmodule/assets/collapsible.js",
"./xmodule/assets/html/imageModal.js",
"./xmodule/js/common_static/js/vendor/draggabilly.js"
],
"StaticTabBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/html/edit.js"
],
"VideoBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/video/10_main.js"
],
"VideoBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/tabs/tabs-aggregator.js"
],
"WordCloudBlockDisplay": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/word_cloud/src/js/word_cloud.js"
],
"WordCloudBlockEditor": [
"./xmodule/assets/xmodule.js",
"./xmodule/assets/raw/edit/metadata-only.js"
]
}
};
Loading