{"action":"created","issue":{"url":"https://api.github.com/repos/plone/Products.CMFPlone/issues/1277","labels_url":"https://api.github.com/repos/plone/Products.CMFPlone/issues/1277/labels{/name}","comments_url":"https://api.github.com/repos/plone/Products.CMFPlone/issues/1277/comments","events_url":"https://api.github.com/repos/plone/Products.CMFPlone/issues/1277/events","html_url":"https://github.com/plone/Products.CMFPlone/issues/1277","id":120145847,"number":1277,"title":"PLIP: Meta bundles generation","user":{"login":"ebrehault","id":460966,"avatar_url":"https://avatars.githubusercontent.com/u/460966?v=3","gravatar_id":"","url":"https://api.github.com/users/ebrehault","html_url":"https://github.com/ebrehault","followers_url":"https://api.github.com/users/ebrehault/followers","following_url":"https://api.github.com/users/ebrehault/following{/other_user}","gists_url":"https://api.github.com/users/ebrehault/gists{/gist_id}","starred_url":"https://api.github.com/users/ebrehault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebrehault/subscriptions","organizations_url":"https://api.github.com/users/ebrehault/orgs","repos_url":"https://api.github.com/users/ebrehault/repos","events_url":"https://api.github.com/users/ebrehault/events{/privacy}","received_events_url":"https://api.github.com/users/ebrehault/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/plone/Products.CMFPlone/labels/03%20type:%20feature","name":"03 type: feature","color":"0000fa"},{"url":"https://api.github.com/repos/plone/Products.CMFPlone/labels/12%20prio:%20high","name":"12 prio: high","color":"cc0000"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/plone/Products.CMFPlone/milestones/4","html_url":"https://github.com/plone/Products.CMFPlone/milestones/Future","labels_url":"https://api.github.com/repos/plone/Products.CMFPlone/milestones/4/labels","id":1198783,"number":4,"title":"Future","description":null,"creator":{"login":"jaroel","id":70700,"avatar_url":"https://avatars.githubusercontent.com/u/70700?v=3","gravatar_id":"","url":"https://api.github.com/users/jaroel","html_url":"https://github.com/jaroel","followers_url":"https://api.github.com/users/jaroel/followers","following_url":"https://api.github.com/users/jaroel/following{/other_user}","gists_url":"https://api.github.com/users/jaroel/gists{/gist_id}","starred_url":"https://api.github.com/users/jaroel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaroel/subscriptions","organizations_url":"https://api.github.com/users/jaroel/orgs","repos_url":"https://api.github.com/users/jaroel/repos","events_url":"https://api.github.com/users/jaroel/events{/privacy}","received_events_url":"https://api.github.com/users/jaroel/received_events","type":"User","site_admin":false},"open_issues":30,"closed_issues":2,"state":"open","created_at":"2015-07-08T13:44:46Z","updated_at":"2015-12-03T11:03:31Z","due_on":null,"closed_at":null},"comments":9,"created_at":"2015-12-03T11:03:31Z","updated_at":"2015-12-04T00:20:12Z","closed_at":null,"body":"### Proposer : Eric Bréhault\r\n\r\n### Seconder : \r\n\r\n## Abstract\r\nIn Plone 5, resources bundles are loaded separately in all the portal pages. This PLIP proposes to be able to merge them in meta bundles.\r\n\r\n## Motivation\r\nWhen 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.\r\n\r\n## Assumptions\r\n\r\n\r\n\r\n## Proposal & Implementation\r\n### Disclaimer\r\nPlone integrators and Plone add-on developers need a simple story:\r\n\r\n- When we develop an add-on, it should be easy to declare our specific bundles so they are automatically included in such or such meta bundle.\r\n- When we install an add-on in our site, it should not require to compile bundles or other stuffs.\r\n\r\nConsequently, we do not want to interact with the existing bundling mechanism as it requires all the front-end dev tooling.\r\n\r\nThe 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.\r\n\r\n### Proposal\r\n`Products.CMFPlone` will define 2 meta bundles:\r\n\r\n- `default` (loaded everytime)\r\n- `logged-in` (loaded if the user is logged in)\r\n\r\nEach meta bundle will produces 2 outputs (one JS and one CSS).\r\n\r\nNote: 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 using `add_bundle_on_request` http://docs.plone.org/adapt-and-extend/theming/resourceregistry.html#adding-or-removing-bundles-from-a-request .\r\n\r\nBundles will have a new property named `merged-in` which possible values will be `default`, `logged-in` or nothing:\r\n\r\n- If `merged-in` is defined, the bundle is aggregated in the corresponding meta bundle, and its `expression` property will be ignored.\r\n- If `merged-in` is nothing, the bundle is published directly in the site pages (just like it does at the moment) and the `expression` property is applied.\r\n- in Development mode, meta bundles are not published, all bundles are published directly.\r\n\r\nThe meta bundle generation is done by a GenericSetup step if a file named `merge_bundles.txt` is present in the imported profile.\r\nAs 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.\r\n\r\n### Implementation\r\nMeta bundles are stored in the \"persistent\" IResourceDirectory, just like as the current bundle cooking does at the moment.\r\nThey are produced by aggregating together all the bundle contents in a single string.\r\n\r\n## Deliverables\r\n- a new version of Products.CMFPlone,\r\n- documentation.\r\n\r\n## Risks\r\nN/A\r\n\r\n## Participants\r\nEric Bréhault\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/plone/Products.CMFPlone/issues/comments/161832010","html_url":"https://github.com/plone/Products.CMFPlone/issues/1277#issuecomment-161832010","issue_url":"https://api.github.com/repos/plone/Products.CMFPlone/issues/1277","id":161832010,"user":{"login":"mauritsvanrees","id":210587,"avatar_url":"https://avatars.githubusercontent.com/u/210587?v=3","gravatar_id":"","url":"https://api.github.com/users/mauritsvanrees","html_url":"https://github.com/mauritsvanrees","followers_url":"https://api.github.com/users/mauritsvanrees/followers","following_url":"https://api.github.com/users/mauritsvanrees/following{/other_user}","gists_url":"https://api.github.com/users/mauritsvanrees/gists{/gist_id}","starred_url":"https://api.github.com/users/mauritsvanrees/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mauritsvanrees/subscriptions","organizations_url":"https://api.github.com/users/mauritsvanrees/orgs","repos_url":"https://api.github.com/users/mauritsvanrees/repos","events_url":"https://api.github.com/users/mauritsvanrees/events{/privacy}","received_events_url":"https://api.github.com/users/mauritsvanrees/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T00:20:12Z","updated_at":"2015-12-04T00:20:12Z","body":"`merge_with`: fine with me.\r\n\r\nOn 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.\r\n\r\nWhen 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.\r\n\r\nConcatenating once after a registry.xml change is roughly what I am suggesting too, although I would simply put it in an import step.\r\n\r\nNote 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."}}