Runtime

A plugin type: Programmatically insert assets out of thin air into bundles

The Runtime API is experimental and therefore subject to change, even between minor updates.

Runtimes accept a bundle and return assets to be inserted into that bundle.

import { Runtime } from "@parcel/plugin";

export default new Runtime({
async apply({ bundle, bundleGraph }) {
// ...
return assets;
},
});

Relevant API

#

RuntimeAsset parcel/packages/core/types/index.js:1555

A "synthetic" asset that will be inserted into the bundle graph.

type RuntimeAssetΒ = {|
  +filePath: FilePath,
  +code: string,
  +dependency?: Dependency,
  +isEntry?: boolean,
  +env?: EnvironmentOptions,
|}
Referenced by:
Runtime

Runtime parcel/packages/core/types/index.js:1566

type Runtime<ConfigType>Β = {|
  loadConfig?: ({|
    config: Config,
    options: PluginOptions,
    logger: PluginLogger,
  |}) => Promise<ConfigType> | ConfigType,
  apply({|
    bundle: NamedBundle,
    bundleGraph: BundleGraph<NamedBundle>,
    config: ConfigType,
    options: PluginOptions,
    logger: PluginLogger,
  |}): Async<void | RuntimeAsset | Array<RuntimeAsset>>,
|}