Ajax form submission error when using use-ajax-submit I receive the following message when I attempt to submit a form with use-ajax-submit class attached to the submit button:


  An error occurred while attempting to process /my_form?_wrapper_format=drupal_ajax: ajax.$form.ajaxSubmit is not a function


Similar to this question, but for Drupal 8.
The following dependencies need to be added to the library attached to the form in order to use use-ajax-submit.

my_module.libraries.yml

my_module.my_library:
  dependencies:
    - core/drupal.ajax
    - core/jquery.form


The library needs to be attached to the form:

$form['#attached']['library'][] = 'my_module/my_module.my_library';