Skip to content

MWPW-199014: Dynamic imports in studio.js#998

Open
mirafedas wants to merge 13 commits into
mainfrom
mwpw-444444
Open

MWPW-199014: Dynamic imports in studio.js#998
mirafedas wants to merge 13 commits into
mainfrom
mwpw-444444

Conversation

@mirafedas

@mirafedas mirafedas commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Resolves https://jira.corp.adobe.com/browse/MWPW-199014 .

In studio/src/studio.js — added lazy-load page components
Replaced 14 eager static imports (one per page component) with a #lazyLoad(elementName, importPath) helper called from each page getter. Each getter now fires import() on first render for its page, waits for customElements.whenDefined() to schedule a re-render, then returns the template on the second pass.

Additionally:
In studio/src/translation/translation-utils.js —fixed the import source
getFragmentPartsToUse was imported from editor-panel.js. Because editor-panel.js is now lazy-loaded (only on PAGE_NAMES.CONTENT), keeping that import would pull editor-panel.js into the bundle eagerly, defeating the lazy-load entirely. The import was redirected to utils.js, which already exported the same function. The call signature changed accordingly: utils.js takes (fragment, path) while editor-panel.js took (store, fragment).

In studio/src/editor-panel.js — aligned promotion field with utils.js
This change is needed because redirecting translation-utils.js to utils.js created a silent inconsistency: utils.js used fragment?.getCurrentTagTitle?.(TAG_PROMOTION_PREFIX) for the promotion field, while editor-panel.js (still used by the editor panel itself and mas-fragment-editor.js) used the older fragment?.getTagTitle(TAG_PROMOTION_PREFIX).

The two methods differ: getTagTitle reads from the fragment's original tags array (initial state), while getCurrentTagTitle reads from the tags field values, which reflect in-flight edits the user has made but not yet saved. After the translation-utils.js redirect, the translation table and the editor panel could show different promotion labels for the same fragment — getCurrentTagTitle on one surface, getTagTitle on the other. Aligning editor-panel.js to getCurrentTagTitle?.() makes all three surfaces consistent.

QA Checklist: https://wiki.corp.adobe.com/display/adobedotcom/M@S+Engineering+QA+Use+Cases

Please do the steps below before submitting your PR for a code review or QA

  • C1. Cover code with Unit Tests
  • C2. Add a Nala test (double check with #fishbags if nala test is needed)
  • C3. Verify all Checks are green (unit tests, nala tests)
  • C4. PR description contains working Test Page link where the feature can be tested
  • C5: you are ready to do a demo from Test Page in PR (bonus: write a working demo script that you'll use on Thursday, you can eventually put in your PR)
  • C.6 read your Jira one more time to validate that you've addressed all AC's and nothing is missing

🧪 Nala E2E Tests

Nala tests run automatically when you open this PR.

To run Nala tests again:

  1. Add the run nala label to this PR (in the right sidebar)
  2. Tests will run automatically on the current commit
  3. Any future commits will also trigger tests as long as the label remains

To stop automatic Nala tests:

  • Remove the run nala label

Note: Tests only run on commits if the run nala label is present. Add the label whenever you need tests to run on new changes.

Test URLs:

@aem-code-sync

aem-code-sync Bot commented Jun 22, 2026

Copy link
Copy Markdown

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

  • Re-sync branch
Commits

@github-actions

Copy link
Copy Markdown

SNOW Change Request Transaction ID [STUDIO]: 0000019c1ef37582-14975439

@mirafedas mirafedas changed the title MWPW-444444: Dynamic imports in studio.js MWPW-199014: Dynamic imports in studio.js Jun 22, 2026
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.55556% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.46%. Comparing base (b23b2c2) to head (9c53f6d).

Files with missing lines Patch % Lines
studio/src/mas-toolbar.js 30.76% 9 Missing ⚠️
studio/src/mas-fragment-editor.js 81.81% 8 Missing ⚠️
studio/src/editors/merch-card-editor.js 14.28% 6 Missing ⚠️
studio/src/editor-panel.js 78.26% 5 Missing ⚠️
studio/src/studio.js 88.57% 4 Missing ⚠️
studio/src/promotions/mas-promotions-editor.js 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #998      +/-   ##
==========================================
- Coverage   90.00%   89.46%   -0.55%     
==========================================
  Files         283      292       +9     
  Lines       90410    91844    +1434     
==========================================
+ Hits        81374    82164     +790     
- Misses       9036     9680     +644     
Files with missing lines Coverage Δ
...io/src/common/components/mas-select-items-table.js 96.72% <100.00%> (+<0.01%) ⬆️
studio/src/mas-icon-picker-modal.js 99.76% <100.00%> (+<0.01%) ⬆️
studio/src/mas-mnemonic-modal.js 93.76% <100.00%> (+0.01%) ⬆️
...rc/placeholders/mas-placeholders-creation-modal.js 71.25% <100.00%> (+0.18%) ⬆️
studio/src/placeholders/mas-placeholders-item.js 24.60% <100.00%> (+0.23%) ⬆️
studio/src/reactivity/editor-context-store.js 78.78% <100.00%> (ø)
studio/src/reactivity/preview-fragment-store.js 77.81% <100.00%> (ø)
studio/src/rte/rte-field.js 82.32% <100.00%> (+0.34%) ⬆️
studio/src/translation/translation-utils.js 100.00% <100.00%> (ø)
studio/src/promotions/mas-promotions-editor.js 91.63% <50.00%> (+0.46%) ⬆️
... and 5 more

... and 12 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b23b2c2...9c53f6d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread studio/src/mas-fragment-editor.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be refactored to use the getFragmentPartsToUse function from utils.js. Otherwise statically importing editor-panel.js would eagerly load it including its tree of dependencies which would defeat the purpose of reducing the resource fetches via lazy loading.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, mas-promotions-editor:14 should also be refactored accordingly to avoid the eager loading of editor-panel.js.

Comment thread studio/src/mas-toolbar.js Outdated
openCreateDialog() {
async openCreateDialog() {
if (!customElements.get('mas-create-dialog')) {
import('./mas-create-dialog.js')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this await the import? Otherwise this.createDialogOpen = true is set before the element is defined.

@mirafedas mirafedas requested review from honstar and yesil June 25, 2026 10:58

@honstar honstar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why the ./rte/rte-field.js imports are needed?

Comment thread studio/src/placeholders/mas-placeholders-creation-modal.js
Comment thread studio/src/placeholders/mas-placeholders-item.js
@mirafedas mirafedas requested a review from honstar June 25, 2026 13:06
Comment thread studio/src/mas-toolbar.js Outdated
Comment thread studio/test/mas-toolbar.test.js Outdated
Comment thread studio/src/rte/rte-mnemonic-editor.js Outdated
Comment thread studio/test/mas-toolbar.test.js Outdated
@aem-code-sync aem-code-sync Bot temporarily deployed to mwpw-444444 June 30, 2026 11:40 Inactive
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.

4 participants