Skip to content

perf: form-bundle rollup pipeline — collapse serial ES module hops (FORMS-24968)#193

Open
dmaurya929 wants to merge 1 commit into
mainfrom
forms-24968-form-bundle-rollup
Open

perf: form-bundle rollup pipeline — collapse serial ES module hops (FORMS-24968)#193
dmaurya929 wants to merge 1 commit into
mainfrom
forms-24968-form-bundle-rollup

Conversation

@dmaurya929

Copy link
Copy Markdown
Collaborator

Summary

Ports the FORMS-24968 performance enhancement from the HDFC forms-engine project to aem-boilerplate-forms so all downstream EDS Forms projects inherit the gains.

What this does: bundles form.js + rules/index.js and their static deps into a single form-bundle.min.js via Rollup, eliminating 5+ serial ES module fetches that currently block form startup. Adds <link rel="modulepreload"> hints in head.html so the browser fetches all critical modules in parallel during HTML parse.

Performance impact (measured on HDFC staging)

Metric Before After Delta
JS request count 12 fetches 1 bundle + 2 shims −11 requests
Serial import hop depth ~5 levels 2 hops −3 levels
Bundled payload 29,709 B raw 25,788 B minified −13%
Worker startup size 39,178 B 26,850 B −31%
modulepreload hints in head 0 5 +5

Changes

  • rollup/form.rollup.config.js — new Rollup config; dual output (unminified dev + terser prod); redirectRulesIndex plugin handles boilerplate's repeat.js importing subscribe from rules/index.js
  • blocks/form/form.source.js — full form logic as Rollup input (never served at runtime)
  • blocks/form/rules/index.source.js — full rules logic as Rollup input
  • blocks/form/form.js — replaced with 1-line shim re-exporting from form-bundle.min.js
  • blocks/form/rules/index.js — replaced with 1-line shim re-exporting subscribe from form-bundle.min.js (preserves singleton formSubscriptions Map for custom components)
  • blocks/form/rules/RuleEngineWorker.js + functionRegistration.js — switched to afb-runtime.min.js (−31% worker startup)
  • scripts/swap-shims.js — dev↔prod toggle; npm run build (prod) / npm run build:dev (dev + sourcemaps)
  • package.json — adds build, build:dev, build:form-bundle scripts
  • head.html — 5 <link rel="modulepreload"> hints for form.js, form-bundle.min.js, constant.js, afb-runtime.min.js, afb-formatters.min.js
  • .husky/pre-commit.mjs — shim guard blocks commits that reference unminified bundles (dev-mode left on)
  • blocks/form/form-bundle.js + form-bundle.min.js — generated bundles committed to repo

Test plan

  • npm run build completes without errors; form-bundle.js (110 KB) and form-bundle.min.js (56 KB) are generated
  • npm run build:dev flips all shims to .js; npm run build flips them back to .min.js
  • Pre-commit guard: stage blocks/form/form.js after build:dev → commit should fail with ERROR: ... points at an unminified bundle
  • Load a form page locally; verify form renders, rules fire, and custom component subscriptions work
  • Network tab: only form.js (shim) + form-bundle.min.js fetched for form logic — no separate rules/index.js, util.js, etc.
  • DevTools Network: all 5 modulepreload resources show (preload) initiator

Related

JIRA: https://jira.corp.adobe.com/browse/FORMS-24968

🤖 Generated with Claude Code

…module hops

Port the HDFC-validated bundle optimization to the boilerplate so all downstream
EDS Forms projects inherit the performance gains:
- 12 JS fetches → 1 bundle + 2 shims (−11 requests)
- 5 serial import hops → 2 hops (parallel preload)
- Worker startup: −31% (afb-runtime.min.js instead of full source)

New files: rollup/form.rollup.config.js, blocks/form/form.source.js,
blocks/form/rules/index.source.js, scripts/swap-shims.js
Modified: form.js and rules/index.js → 1-line shims; head.html adds 5 modulepreloads;
package.json adds build/build:dev/build:form-bundle scripts; pre-commit shim guard added

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aem-code-sync

aem-code-sync Bot commented May 15, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant