Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register bootstrap+jquery globally #1177

Closed
wants to merge 3 commits into from
Closed

Register bootstrap+jquery globally #1177

wants to merge 3 commits into from

Conversation

thet
Copy link
Member

@thet thet commented Jun 21, 2022

No description provided.

@thet thet requested a review from petschki June 21, 2022 12:42
@mister-roboto
Copy link

@thet thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@petschki
Copy link
Member

petschki commented Jul 7, 2022

I've experimented with "eager sharing" option for the global modules...

The main change here is, that there are no more "remote" modules jquery and bootstrap but they are marked as eager in the mockup shared library list. So they are available in the first chunk and can be globally initialized in index.js ... see 1a6f349#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R21

my addons wich use (function($) { ... })(jQuery) and are registered after the plone bundle work now.

Somehow window.bootstrap is always undefined but that might be something else ...

/cc @maethu are you able to test this change here?

@petschki
Copy link
Member

petschki commented Jul 7, 2022

NOTE: you have to disable bootstrap-js and jquery bundle in the resourceregistry when using this ...

@petschki
Copy link
Member

petschki commented Jul 7, 2022

UPDATE: when importing bootstrap with async/await, it's defined as expected:

mockup/src/globals.js

Lines 7 to 13 in a6b2dea

// Register Bootstrap globally
window.bootstrap = "__deferred__";
document.addEventListener("DOMContentLoaded", async (e) => {
const bootstrap = await import("bootstrap");
window.bootstrap = bootstrap;
});

@petschki
Copy link
Member

petschki commented Jul 8, 2022

Closed in favor of #1185

@petschki petschki closed this Jul 8, 2022
@thet thet deleted the register-globally branch July 8, 2022 16:29
@maethu
Copy link

maethu commented Jul 8, 2022

/cc @maethu are you able to test this change here?

Awesome! I just tried it with #1185 - Seems to work really well.
I also do think a big advantage if this solution is, that I can use a different packaging tool, like vite. I still think the webpack module federation approach is valid and good way for dependency injection. But it might no be really compatible with bootstrap and other 3rd party libraries.

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