ランタイム
プラグインのタイプ: バンドルに存在しないアセットをプログラムで挿入
ランタイムAPIは実験的なものであるため、マイナーアップデート間でも変更される可能性があります。
ランタイムはバンドルを受け取り、そのバンドルに挿入するアセットを返します。
import { Runtime } from "@parcel/plugin";
export default new Runtime({
async apply({ bundle, bundleGraph }) {
// ...
return assets;
},
});
関連するAPI
#RuntimeAsset parcel/packages/core/types/index.js:1619
バンドルグラフに挿入される「合成」アセット。
type RuntimeAsset = {|
+filePath: FilePath,
+code: string,
+dependency?: Dependency,
+isEntry?: boolean,
+env?: EnvironmentOptions,
+priority?: RuntimeAssetPriority,
|}
参照
ランタイムRuntime parcel/packages/core/types/index.js:1631
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>>,
|}