Skip to content

chore: update django-webpack-loader constraint to allow newer versions #36676

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

wgu-ram-chandra
Copy link
Contributor

@wgu-ram-chandra wgu-ram-chandra commented May 7, 2025

Fixes: #35276

Description

This PR updates the django-webpack-loader package from version v0.7.0 to the latest compatible release, v3.1.1. The update is made to enable better Webpack integration and to allow for future improvements.

Supporting Information

Observed Changes Between v0.7.0 and v3.1.1

  • Removed type="text/javascript" and type="text/css" attributes from <script> and <link> tags (v1.3.0), as modern browsers no longer require them -> Not a breaking change
  • Introduced support for IGNORE, POLL_INTERVAL, TIMEOUT, and INTEGRITY settings in WEBPACK_LOADER, giving more control over asset handling and subresource integrity checks -> Not a breaking change
  • Dropped references to Bower starting with v1.0.0 -> Not a breaking change
  • No breaking changes with webpack-bundle-tracker integration -> Not a breaking change
  • Enhanced the render_bundle template tag to accept an optional file extension filter for finer asset control -> Not a breaking change
  • Stricter requirement for webpack-stats.json file, causing tests to fail due to the absence in the expected directory -> is a breaking change

Issue Summary

  • The webpack-stats.json file, which is required by django-webpack-loader v3.1.1, was not being generated in the test_data directory as expected.
  • Tests were failing due to this missing file.
  • Attempts to build Webpack with npm run webpack were not successful.

Temporary Fix

  • Debugging revealed that the environment variables STATIC_ROOT_LMS and STATIC_ROOT_CMS were set incorrectly, causing Webpack to fail to generate the required webpack-stats.json file.
  • By unsetting these environment variables and running npm run webpack again, the webpack-stats.json file was successfully generated in the ./test_root/staticfiles folder and letting all tests to pass.

Permanent Fix

  • After exploring django-webpack-loader v3.1.1, I found the FakeWebpackLoader class, which allows us to mock the get_bundle method of WebpackLoader. This method is typically used in the template tag.
  • The FakeWebpackLoader provides fake bundle data without requiring a real webpack-stats.json file, which effectively bypasses the Webpack build step in tests.
  • The existing monkeypatch(no_webpack_loader) was removed, as it is no longer required in version v3.1.1. A new monkeypatch was added in conftest.py to override the render_bundle function, which prevents a TypeError when tests are executed without a real webpack-stats.json file.
  • This solution ensures that no tests attempt to read the webpack-stats.json file, eliminating the need to build Webpack during test runs.
Screenshot 2025-05-07 at 9 09 08 PM

Screenshot of the FakeWebpackLoader class from django-webpack-loader module

Codebase Impact

  • The WEBPACK_LOADER settings remain compatible with the new version of the package, with no changes required for existing settings.
  • The FakeWebpackLoader integration prevents the need for a real Webpack build during tests.

Steps Executed

  1. Ran:

    make upgrade-package package=django-webpack-loader

    to upgrade the package.

  2. Ran tests on the following sample files, which render HTML pages:

    pytest -s lms/djangoapps/course_wiki/tests/test_middleware.py
    pytest -s lms/djangoapps/course_wiki/tests/tests.py

References:

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label May 7, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @wgu-ram-chandra!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@wgu-ram-chandra wgu-ram-chandra requested review from feanil and ormsbee May 8, 2025 03:34
@wgu-ram-chandra wgu-ram-chandra force-pushed the issue-35276-unpin-django-webpack-loader branch from afa81f7 to e9487fa Compare May 8, 2025 17:09
@feanil feanil added the create-sandbox open-craft-grove should create a sandbox environment from this PR label May 9, 2025
@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label May 12, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions May 12, 2025
@wgu-ram-chandra wgu-ram-chandra requested a review from e0d May 12, 2025 22:46
@open-craft-grove
Copy link

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-sandbox open-craft-grove should create a sandbox environment from this PR mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

5 participants