-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
PLIP: Meta bundles generation #1277
Comments
👍 That is indeed the missing piece needed to reduce headache with js/css resources and addons. Just two things:
I am not sure if this file is needed at all. Its a bit redundant: Why don't we look at |
@jensens, I chose Regarding the use of |
Name ideas: merge-in, merge-to, combine, combined-bundle, master-bundle, full-bundle, main-bundle. join. For clarity: If I am logged in I get both the default and the logged-in bundle, right? Having two packages that read a single GS file, would be a first I think. There is no technical reason that this would not work, but it could be confusing. Do we need any file at all? Can't the metabundle step simply generate the new bundles always, compare them with what is currently stored in the registry and only save them when there is a difference? This would avoid the need to tell add-on authors to add yet another file. If checking the config and concatenating the bundles and comparing them takes say five seconds, then this does increase the time needed for activating an add-on. If that is the case, we could indeed check for existence of registry.xml. For speed, the step might want to check if a Plone Site is being created, and skip execution then: somewhere in the plone-final step we could call the needed code explicitly once. But we can revisit this if we see that install time is a problem. |
Yes
Good point. Actually, I think we don't. |
I like the terms |
I vote Nah. |
:-D |
What about this:
|
On Plone 4, in production mode the bundles were preserved between restarts. I guess if no compiled/merged bundle yet existed, one would get created when the first page was requested. When Zope restarts, I would not mind if the bundles get recalculated, as new versions of packages may have been added. But I think the consensus, or at least the current behavior, is to not regenerate them, as it may really just have been a restart, without any changes. A needless regeneration would add seconds to the restart time, so possibly a few extra seconds of down time, which we want to avoid. Concatenating once after a registry.xml change is roughly what I am suggesting too, although I would simply put it in an import step. Note that if you write an upgrade step in your add-on to apply the plone.app.registry import step, you will not get any reconcatenation: you should then apply the new metabundle step too. |
Ok let's go with |
Sorry I missed the last messages in the discussion before I answered: so yes ok |
+1 for concatenation after GS step changes values for resource registry related keys. Zope startup must be fast (zcml/zca is probably biggest culprit but we should aim for quick automatic restarts/reloads, as Django's). |
Doing this on Zope startup will propably not work, because the process of merging/compiling needs a browser. If we want to do this without a browser we need probably a new dependency in Plone like the JS stack of npm/gulp whatever. And this is proably not what we want. |
Actually it does not need a browser, because here we are not building bundles but just aggregating existing bundles together. That's what I explained in the disclaimer: we do not want to involve the bundling mechanism here, just use existing bundles. |
at the mockup (aka resource registry) training in bucharest i - and i think it's safe to say that for most of the other attendees too - had a hard time figuring out how the resource registry is supposed to work. we proposed something similar as this plip does (being able to combine bundles easily) in a different way that can't be realized (easily, or at all) #1163 for what it's worth - i tried to summarize the steps currently necessary for an integrator to combine the resources of different bundles into a new mysite-plone and mysite-plone-logged-in bundle in the section Optimized Bundles in plone/documentation#482 @ebrehault: if i understand this proposal correctly we're still including jquery (and possibly other resources required by and therefore integrated in multiple bundles) multiple times. |
@frisi no we are not including jquery (or other resources) multiple time. @vangheem made a change recently, we now have a new attribute named Consequently, if the |
Great work ! |
Please, don't add the default and logged-in. Usually logged-in are few things we can load anyway. |
@yurj I am not sure I understand what you mean: do you mean we do not need the logged-in meta bundle, the default will be just enough ? |
default and logged in makes perfect sense: But one can reconfigure all this anyways and offer only one bundle for anonymous and logged in users. |
@plone/framework-team please vote for the proposal of this PLIP: https://docs.google.com/spreadsheets/d/15Cut73TS5l_x8djkxNre5k8fd7haGC5OOSGigtL2drQ/edit?pli=1#gid=3 |
Proposer : Eric Bréhault
Seconder :
Abstract
In Plone 5, resources bundles are loaded separately in all the portal pages. This PLIP proposes to be able to merge them in meta bundles.
Motivation
When a Plone site uses 10 add-ons, all the pages will contain 10 extras SCRIPT tags and 10 extra LINK tags (plus the default ones provided by Plone). This is very bad for performances, we need to be able to aggregate them.
Assumptions
Proposal & Implementation
Disclaimer
Plone integrators and Plone add-on developers need a simple story:
Consequently, we do not want to interact with the existing bundling mechanism as it requires all the front-end dev tooling.
The objective here is just to concatenate existing JS or CSS bundles together, which should be a basic string processing operation we can trigger easily from a GenericSetup step.
Proposal
Products.CMFPlone
will define 2 meta bundles:default
(loaded everytime)logged-in
(loaded if the user is logged in)Each meta bundle will produces 2 outputs (one JS and one CSS).
Note: I do not think we need to be able to declare other meta bundles. If we need to provide some specific resources in a given page or in a given condition, regular bundles should be satisfying, using the
expression
property, or usingadd_bundle_on_request
http://docs.plone.org/adapt-and-extend/theming/resourceregistry.html#adding-or-removing-bundles-from-a-request .Bundles will have a new property named
merge_with
which possible values will bedefault
,logged-in
or nothing:merge_with
is defined, the bundle is aggregated in the corresponding meta bundle, and itsexpression
property will be ignored.merge_with
is nothing, the bundle is published directly in the site pages (just like it does at the moment) and theexpression
property is applied.The meta bundle generation is done by a GenericSetup step.
As bundles can be defined or modified TTW, we will also provide a "Merge bundles for production" button in the Resource registry that will re-generate the meta bundles.
Implementation
Meta bundles are stored in the "persistent" IResourceDirectory, just like as the current bundle cooking does at the moment.
They are produced by aggregating together all the bundle contents in a single string.
Deliverables
Risks
N/A
Participants
Eric Bréhault
The text was updated successfully, but these errors were encountered: