fix: intermittent "utils attribute not found" issue in webpack_loader (#37109)
This commit is contained in:
@@ -5,7 +5,6 @@ These should not be used to support any XBlocks outside of edx-platform.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
import webpack_loader
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
@@ -44,6 +43,11 @@ def add_webpack_js_to_fragment(fragment, bundle_name):
|
||||
"""
|
||||
Add all JS webpack chunks to the supplied fragment.
|
||||
"""
|
||||
for chunk in webpack_loader.utils.get_files(bundle_name, None, 'DEFAULT'):
|
||||
# Importing webpack_loader.utils at the top of the module causes an exception:
|
||||
# OSError: Error reading webpack-stats.json.
|
||||
# Are you sure webpack has generated the file and the path is correct?
|
||||
# We are not quite sure why.
|
||||
from webpack_loader.utils import get_files
|
||||
for chunk in get_files(bundle_name, None, 'DEFAULT'):
|
||||
if chunk['name'].endswith(('.js', '.js.gz')):
|
||||
fragment.add_javascript_url(chunk['url'])
|
||||
|
||||
Reference in New Issue
Block a user