Skip to content

Commit 4bf04d0

Browse files
MrTangopetschki
authored andcommitted
tech(pat-upload): lazify pattern, split registration from implementation
pat-upload contributed ~17KB src to the eager patterns chunk on every page, though the upload UI only appears in folder contents and upload dialogs. Split it into a thin registration module and upload--implementation.js holding the jquery/underscore/i18n wiring and the lazily-loaded Dropzone integration. The thin module keeps registering the .pat-upload trigger and grafts the implementation prototype on first match. Public options and emitted markup are unchanged. pat-structure, pat-relateditems and the contentbrowser app construct upload imperatively (new Upload(...)) and use the instance right away. The implementation therefore stays a constructable Base.extend pattern and those callers import it directly, so new Upload() yields a fully formed instance synchronously. Registry.register is first-wins, so the eagerly imported thin module remains the registered .pat-upload pattern; the implementation is only reached via lazy chunks (the structure app view, the contentbrowser component and the relateditems dynamic import). Add a regression test asserting the implementation is constructable and exposes its methods synchronously. The implementation now loads only where a .pat-upload element exists.
1 parent 175c7bd commit 4bf04d0

6 files changed

Lines changed: 548 additions & 494 deletions

File tree

src/pat/contentbrowser/src/ContentBrowser.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { fly } from "svelte/transition";
66
import _t from "../../../core/i18n-wrapper";
77
import { ensureIntlSupport } from "../../../core/intl-loader";
8-
import Upload from "../../upload/upload";
8+
import Upload from "../../upload/upload--implementation";
99
import contentStore from "./ContentStore";
1010
import {
1111
clickOutside,

src/pat/relateditems/relateditems.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export default Base.extend({
401401
},
402402

403403
async initUploadView(disabled) {
404-
let Upload = await import("../upload/upload");
404+
let Upload = await import("../upload/upload--implementation");
405405
Upload = Upload.default;
406406

407407
const upload_button = this.$toolbar[0].querySelector(".upload button");

src/pat/structure/js/views/upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import $ from "jquery";
22
import _ from "underscore";
33
import PopoverView from "../../../../core/ui/views/popover";
4-
import Upload from "../../../upload/upload";
4+
import Upload from "../../../upload/upload--implementation";
55

66
export default PopoverView.extend({
77
className: "popover upload",

0 commit comments

Comments
 (0)