Skip to content

Commit ee6a5b5

Browse files
MrTangopetschki
authored andcommitted
tech(pat-modal): lazify pattern, split registration from implementation
Split the ~1000-line pat-modal implementation out of the every-page eager patterns chunk. modal.js becomes a thin registration module that loads modal--implementation.js on first .pat-plone-modal match; the implementation grafts onto the instance from the prototype, since imperative callers still do `new Modal()`. jquery-form ($.fn.ajaxSubmit) moves from a top-level import to a lazy `await import("jquery-form")` at its single call site in handleFormAction, so it no longer loads on every page. Imperative importers are repointed at modal--implementation: controlpanels (registry / dexterity-types-listing / contentrule-elements) and recurrence load it as part of their own lazy implementation chunks; manageportlets is registered eagerly, so it loads the impl on demand inside showEditPortlet. Side-effect registration imports (patterns.js, tinymce links, structure actionmenu) keep pointing at the thin module. Depends on the pat-recurrence lazification: recurrence is eagerly registered, so its Modal import must live in recurrence--implementation (a lazy chunk) for the modal body to actually leave the eager bundle. Merge after the pat-recurrence PR.
1 parent 3fe5eb5 commit ee6a5b5

7 files changed

Lines changed: 1067 additions & 1033 deletions

File tree

src/pat/controlpanels/contentrule-elements--implementation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import $ from "jquery";
2-
import Modal from "../modal/modal";
2+
import Modal from "../modal/modal--implementation";
33

44
export default class Contentrules {
55
constructor(el) {

src/pat/controlpanels/dexterity-types-listing--implementation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import $ from "jquery";
2-
import Modal from "../modal/modal";
2+
import Modal from "../modal/modal--implementation";
33

44
export default class DexterityTypesListing {
55
constructor(el) {

src/pat/controlpanels/registry--implementation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import $ from "jquery";
22
import utils from "../../core/utils";
3-
import Modal from "../modal/modal";
3+
import Modal from "../modal/modal--implementation";
44

55
export default class ConfigRegistry {
66
constructor(el) {

src/pat/manageportlets/manageportlets.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import $ from "jquery";
2-
import Modal from "../modal/modal";
32
import Base from "@patternslib/patternslib/src/core/base";
43
import logger from "@patternslib/patternslib/src/core/logging";
54
import utils from "../../core/utils";
@@ -109,8 +108,11 @@ export default Base.extend({
109108
$message.fadeTo(500, 0.6);
110109
}, 3000);
111110
},
112-
showEditPortlet: function (url) {
111+
showEditPortlet: async function (url) {
113112
log.info("show edit portlet in modal");
113+
// manageportlets is registered eagerly, so it loads the modal
114+
// implementation on demand to keep it out of the eager bundle.
115+
const Modal = (await import("../modal/modal--implementation")).default;
114116
var that = this;
115117
var $a = $("<a/>");
116118
$("body").append($a);

0 commit comments

Comments
 (0)