Skip to main content

BundleExtension

A plugin registers bundling contributions through context.registerBundleExtension before the bundler runs.

Import​

import type { BundleExtension } from '@bedrock-core/builder-plugin';

Properties​

PropertyTypeDefaultDescription
idstring—Required build-wide unique identity
versionstring—Required implementation/settings fingerprint for bundle cache keys
packsreadonly string[]Selected packsPack IDs receiving the extension
inputsreadonly string[][]Source files and resolution candidates affecting reuse
pluginsreadonly Plugin[][]esbuild plugins applied in registration order before the host resolver
jsxImportSourcestring—Package supplying the automatic JSX runtime
resolveFromProjectreadonly string[][]Import prefixes resolved from the authored dependency root first
cachebooleanfalseOpt custom compiler plugins into verified reuse

Usage​

import type { BuildContext, BundleExtension } from '@bedrock-core/builder-plugin';

export function run(context: BuildContext) {
const extension: BundleExtension = {
id: '@example/widgets',
version: '1',
jsxImportSource: '@example/widgets',
resolveFromProject: ['@example/widgets'],
};
context.registerBundleExtension(extension);
}

Notes​

Extensions default to the invocation's selected packs. Pack-scoped invocations contribute to their current pack; packs can select explicit configured pack IDs. Unknown pack IDs, duplicate extension IDs and conflicting JSX runtimes fail.

Custom esbuild plugins rebuild by default. Set cache: true only when version includes implementation/settings changes and every input is declared in inputs or returned through hook watchFiles. Directory watches and virtual inputs without observable files disable reuse conservatively. Watch and cache describes the host cache.