Bud compiled JS different after updating to 6.14.3

Compiled JS is different after updating Bud from 6.12.3 to 6.14.3. I’ve re-read the Bud documentation, but didn’t find (or missed!) a solution. Perhaps someone here can help.

assets/scripts/test.js

console.log('Working');

Bud 6.12.3 bud build compiles to:

(()=>{"use strict";console.log("Working")})();

Bud 6.14.3 bud build compiles to:

"use strict";
(self.webpackChunk_roots_bud = self.webpackChunk_roots_bud || []).push([[43], {
    "./scripts/test.js": ()=>{
        console.log("Working")
    }
}, s=>{
    var t;
    t = "./scripts/test.js",
    s(s.s = t)
}
]);

The 6.12.3 compiled file runs as expected in the browser; the 6.14.3 compiled file shows no messages in the console.

bud.config.js

export default async app => {
    /**
     * The bud.js instance
     */
    app

    /**
     * Paths
     */
    .setPath({
        '@src': `assets`,
    })

    /**
     * Application entrypoints
     * Paths are expressed relative to the `@src` directory
     */
    .entry({
        test: ['scripts/test'],
    })
}

bud.js creates a runtime chunk by default now. This was flagged in 6.13 as a potentially breaking change.

You can disable the runtime chunk in your bud.config file:

import type {Bud} from '@roots/bud'
export default async (bud: Bud) => {
  bud.runtime(false)
}

You can also use the --no-runtime flag.

Ideally you want to use the generated runtime. Unsure what context you’re using bud.js in, but for WordPress you would want to use something like wp_enqueue_inline_script:

// couple helper functions
$get_path = fn ($endpoint) => join([get_template_directory(), 'dist', $endpoint], '/');
$read = fn ($endpoint) => file_get_contents($dist_path($endpoint));

// entrypoints.json as an object
$entrypoints = json_decode($read('entrypoints.json'));

wp_enqueue_script(
  'bud/js',
  $get_path($entrypoints->editor->js[1]),
  [],
  null,
  true
);

wp_enqueue_inline_script(
  'bud/js',
  $read($entrypoints->editor->js[0]),
  'before',
);

You should be able to rely on the runtime being at index 0 of the array.

Thanks! I’ll disable for now, but will read up on runtime chunks to learn more.