feat: modernize Problem Block JS, enable Babel on capa files#38718
feat: modernize Problem Block JS, enable Babel on capa files#38718irfanuddinahmad wants to merge 4 commits into
Conversation
|
Thanks for the pull request, @irfanuddinahmad! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Removes the broad /xmodule\/js\/src/ regex from the string-replace-loader and babel-loader exclusion lists, replacing it with explicit paths for only the three files that actually contain RequireJS patterns (poll.js, poll_main.js, 08_video_auto_advance_control.js). This allows Babel to process the capa files (display.js, imageinput.js, schematic.js). Also fixes an implicit global variable in schematic.js that would throw under Babel strict mode, and migrates capa Karma tests from the legacy runner to the webpack-based runner. Closes openedx/public-engineering#438 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jasmine-extensions.js registers toImageDiffEqual only if window.imagediff is set. When imported via webpack, jasmine-imagediff.js uses the CommonJS path (module.exports) and never sets window.imagediff. Import it as a named default and assign to window explicitly so the matcher is available for display_spec.js imageinput tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ES module imports are hoisted, so the assignment must live after all imports (alongside other window.* globals). This is safe because jasmine-extensions.js registers the addMatchers call inside a beforeEach callback, so window.imagediff only needs to be set before tests run, not at module load time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Clarifies why the three xmodule/js/src/ files are listed explicitly and signals to future contributors that new files should use ES6+ and must not be added here. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6adfd7a to
7b3214a
Compare
Summary
Closes openedx/public-engineering#438
This PR modernizes the Problem Block JavaScript build pipeline by:
/xmodule\/js\/src/regex from thestring-replace-loaderexclusion andbabel-loaderexclusion lists in bothwebpack-config/file-lists.jsandwebpack.common.config.js. Only the 3 files that actually contain RequireJS patterns are now listed explicitly:poll/poll.js,poll/poll_main.js,video/08_video_auto_advance_control.js.display.js,imageinput.js,schematic.js) — previously they were excluded from Babel by the broad regex despite having no RequireJS patterns.schematic.js(schematic = (function()...→var schematic = (function()...) which would throw aReferenceErrorunder Babel's strict mode.karma_xmodule.conf.jsrunner to the modern webpack-basedkarma_runner_webpack.js, and excluding them from the legacy runner.Test plan
npm run build-devpasses with no build errorsnpm run test-xmodule-webpack— capa tests (display_spec.js,imageinput_spec.js) pass in the webpack runnernpm run test-xmodule-vanilla— remaining legacy xmodule tests (non-video, non-capa) still pass🤖 Generated with Claude Code