I has been my understanding (maybe wrong) that the legacy bundles continue to use "portal_css" and "portal_javascript". Then, the approach from Plone 4 should still work.
A recent discussion (initiated by Dylan Jay) suggests that the new bundles can also be updated programmatically. Up to this discussion, I had the impression that for the bundling the JS engine in a browser were used for the bundling - likely, the impression was wrong.
once again, this is why the whole thing is broken:
instead of giving a proper deprecation warning and pointing to the right way of doing things, we just keep including the same old (and now broken) code.
I would love to make a PR to fix it, but I have no idea how it works.
After each profile import, the first time the plone-legacy bundle is accessed, it is re-cooked.
After cooking, the last_compilation attribute of the bundle is set and for further requests, the already cooked bundle is delivered.
If it's not already documented, this should go into the plone docs.
A button to manually re-cook would be a nice addition to the resource registry control panel.
after running it, the old resource is still listed in the RequireJS configuration.
BTW, instead adding the code all over my add-ons, I would prefer to patch all methods in Products.ResourceRegistries to behave reasonably well.
UPDATE: can someone point me also to the code used to rename a resource from ++resource++collective.lazysizes/ls.respimg.min.js to resource-collective-lazysizes-ls-respimg-min-js?