enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Duplicate pageContributions due to app unique assetUrl #6579

Closed ComLock closed 5 years ago

ComLock commented 6 years ago

When you have two apps that for instane adds react, react-dom and babel-standalone as assets via pagecontribtions in a filter. The will all be duplicated because the asseturl is app specific. It both contains the app name and a number which is also different.

This is another instance where https://github.com/enonic/xp/issues/6122 could be the solution...

sigdestad commented 6 years ago

Indeed, I think this sounds like "abuse" of pageContributions"..

ComLock commented 6 years ago

Due to https://github.com/enonic/xp/issues/6611 I'm unable to implement a workaround.

Another option would be serving the assets via services, but again the service url contains the app.name in the path, so pageContributions wont be uniqe, and thus duplicated.

I guess I could have a smart response filter that searches pageContribution before adding or not its own. But then the pageContribution is moved from the part into a filter.

ComLock commented 6 years ago

Perhaps what I could do is make an Assets Application which provides all the assets, sorta like CDN.

Then all the apps would simply request assets from a static CDN url, rather than providing all the assets it needs.

ComLock commented 6 years ago

Perhaps there could some parameter to assetUrl to say give me an url without the hash number. That would make it easier to host assets that already contain versioning in the filename. Like jquery-x.x.x

And perhaps there could be a parameter to drop the app name too, and simply run through the order of the apps in the site looking for the first app to provide the asset?

ComLock commented 6 years ago

According to @alansemenov the backend will already provide the asset on this url <appName>/<path to asset> in addition to <appName>/<assetUrl generated by Enonic>

It would be nice if such a thing was documented anywhere? And even better was available via a parameter to assetUrl, or a new function resourceUrl. Better check though that you cannot download non-assets. Like controllers containing password or other security risks.

sigdestad commented 5 years ago

If you want a common set of "assets" across apps, you sould make a separate app like you suggest above. Alternatively use CDN deployments outside of your control