Convert FormBuilder.js to module#8
Open
ViolanteCodes wants to merge 2 commits into
Open
Conversation
matteius
approved these changes
Jul 24, 2026
There was a problem hiding this comment.
⚠️ Not ready to approve
The template currently uses deferred module scripts to define FormBuilder but then references it from a classic script that executes before the module runs, causing a runtime FormBuilder is undefined error.
Pull request overview
This PR converts the Form Builder frontend script into an ES module so it can be imported directly (including by Vitest), removing the previous “evaluate source to extract class” helper.
Changes:
- Export
FormBuilderfromform-builder.jsas an ES module. - Update Vitest tests to import
FormBuilderdirectly and delete the old loader helper. - Update the admin template to load
form-builder.jsas a module (but the current script ordering introduces a runtime error; see comment).
File summaries
| File | Description |
|---|---|
| tests_js/form-builder/setupCanvas.test.js | Switches tests from helper-based class loading to direct ES module import. |
| tests_js/form-builder/initializePropertyFormTabs.test.js | Switches tests from helper-based class loading to direct ES module import. |
| tests_js/form-builder/addFieldAtPosition.test.js | Switches tests from helper-based class loading to direct ES module import. |
| tests_js/form-builder/helpers/loadFormBuilderClass.js | Removes the no-longer-needed helper that evaluated the source to extract the class. |
| django_forms_workflows/templates/admin/django_forms_workflows/form_builder.html | Updates script tags to load the Form Builder JS as a module (currently with a timing/ordering issue). |
| django_forms_workflows/static/django_forms_workflows/js/form-builder.js | Exports FormBuilder as a named ES module export. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Low
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Converts FormBuilder.js to module that is then imported by the necessary templates, in preparation for splitting the file later. Removes the now unnecessary helper class from the FE test runner.