Compiling resource bundles questions

Hi,

I'm having some confusion about compiling bundles with the new resource registry.

I'm following https://github.com/plone/Products.CMFPlone/blob/master/DEVELOPING_BUNDLES.rst

I am using ./bin/plone-compile-resources --site-id=Plone --bundle=plomino

Some things I don't understand. It generates a lot of other files I don't want. like src/Products/CMFPlomino/browser/static/js/plominodynamic-compiled.js. Why?
What it's supposed to compile to is src/Products/CMFPlomino/browser/static/js/plomino-compiled.js. It only seems to do that sometimes. I had to reinstall plomino on the "Plone" localhost site just now to get it to compile the plomino-compiled.js.

Now originally @ebrehault was compiling via TTW and copying back to the filesystem. Is that really the best way?
This new way of doing it however seems to create bigger files and also seems to hard code absolute paths of my development environment in them, why is that?
More confusing if I compile using ./bin/plone-compile-resources --site-id=Plone --bundle=plomino --compile-dir=src/Products/CMFPlomino/browser/static/ then I get a static/plomino.min.js file which is smaller and doesn't have the full paths in, but its not in the right place with the right name as defined in https://github.com/plomino/Plomino/blob/master/src/Products/CMFPlomino/profiles/default/registry.xml.

Finally the documentation says that I have update the last compiled date. Why? Can't we use the creation date of the file? It's hard to remember this.
Oh and it seems you also have to remember to reinstall your product because the compilation date needs to go into the configuration registry. Also error prone.

just another proof of how buggy the bundling mechanism is in its current state; and this is happening to someone with way lot more experience than most of us.

do we have to wait until Plone 6 to try to fix this? I don't think so.

@ramon @datakurre @vangheem. It was actually a serious question not a rant. I'd like to update the documentation particularly with design rationale.

I don't know. I've never used that script.

(Before I moved to webpack built themes, I used pure require.js as in https://github.com/plone/plone.app.mosaic/blob/master/build.js)

does anyone know if this script is supported? Does everyone just compile it TTW?

Well, I never compile TTW, so always use the script. But AFAICT it works only in latest Plone 5.1.b2 after I fixed a bunch of issues with it. I recommend to use it for addon development and it works fine i.e. in plone.app.imagecropping.

If your bundle configuration in your registry is set correctly it should compile only what you asked it for.

@jensens So you don't get a lot of extra unneeded files generated?
I'm not using 5.1 however so perhaps that was something that was fixed?

The registry.xml has

  <records prefix="plone.bundles/plomino"
           interface='Products.CMFPlone.interfaces.IBundleRegistry'>
    <value key="resources">
      <element>plominoformula</element>
      <element>plominotable</element>
      <element>plominodesign</element>
      <element>plominodynamic</element>
      <element>plominodatagrid</element>
      <element>plominomultipage</element>
      <element>plominomacros</element>
      <element>plominorefresh</element>
    </value>
    <value key="merge_with">default</value>
    <value key="enabled">True</value>
    <value key="depends">plone</value>
        <value key="stub_js_modules">
      <element>jquery</element>
      <element>mockup-patterns-modal</element>
      <element>mockup-patterns-select2</element>
      <element>mockup-patterns-tree</element>
      <element>mockup-patterns-texteditor</element>
      <element>mockup-patterns-sortable</element>
      <element>mockup-patterns-backdrop</element>
      <element>mockup-utils</element>
      <element>pat-base</element>
      <element>pat-registry</element>
      <element>pat-utils</element>
    </value>
    <value key="compile">True</value>
    <value key="jscompilation">++resource++Products.CMFPlomino/js/plomino-compiled.js</value>
    <value key="csscompilation">++resource++Products.CMFPlomino/css/plomino-compiled.css</value>
    <value key="last_compilation">2017-02-26 10:26:00</value>
  </records>

and it creates files for each resource and also another for the final bundle.

Also, with plugin development, after I run buildout to install a new version, there is no way to have changed JS without reinstalling the profile on every plone site thats on a zope platform?

@djay - looking at https://github.com/plomino/Plomino/blob/advanced_ide/src/Products/CMFPlomino/profiles/default/registry.xml and https://github.com/plomino/Plomino/blob/advanced_ide/src/Products/CMFPlomino/browser/static/js/dynamic.js - this doesn't follow the best practices.

All those concepts - especially the distinction between bundle and bundle resource - are hard to explain. There are many ongoing discussions on how to improve the situation. Independently from your question here I'm preparing a PLIP draft, which I think has the potential to improve and simplify these concepts while even bringing more flexibility.

2 Likes