Load custom library when form contains special field type
I addedsome values in the render array of the formElement method in my customWidget class.

'#attached' =&gt; array(
    'library' =&gt; array(
      'core/jquery',
      'rate_field/admin-star-field',
    ),