Attach JavaScript and CSS assets when render entity using Views REST export
We came up with a new module: Ajax Assets Plus.

The module provides a new render which collects all the necessary libraries during rendering. It results in an array:

return [
      'commands' ['An array with ajax commands for settings'],
      'content' =&gt; 'Rendered content(HTML)',
      'libraries' =&gt; 'all the needed assets grouped into libraries',
    ];


We had to to override the AjaxResponseAttachmentsProcessor and AssetResolver classes.

Also we implemented the hook_js_settings_build() to collect all the libraries on the page, as ajaxPageState does not contain all the dependencies.