Preferred way to exclude pages from including a script

It’s preferred there should only be one entrypoint according to the docs. However, I need to exclude a few specific pages from including a particular script file.

So, should this be set up in the app.js file instead of what I have specified below?

Originally, I had set up bud:

    .entry('app', ['@scripts/app', '@styles/app'])
    .entry('app-header', ['@scripts/app-header'])

And in my setup.php:

add_action('wp_enqueue_scripts', function () {
  if ( !is_page('form-1') || !is_page('some-other') ) {
}, 100);

add_action('wp_enqueue_scripts', function () {
}, 100);

Use dynamic imports. Take a look at these: