Bun provides a universal plugin API that can be used to extend both the _runtime_ and _bundler_. Plugins intercept imports and perform custom loading logic: reading files, transpiling code, etc. They can be used to add support for additional file types, like `.scss` or `.yaml`. In the context of Bun's bundler, plugins can be used to implement framework-level features like CSS extraction, macros, and client-server code co-location. For more complete documentation of the Plugin API, see [Runtime > Plugins](/docs/runtime/plugins). ## Usage A plugin is defined as simple JavaScript object containing a `name` property and a `setup` function. Register a plugin with Bun using the `plugin` function. ```tsx#myPlugin.ts import type { BunPlugin } from "bun"; const myPlugin: BunPlugin = { name: "Custom loader", setup(build) { // implementation }, }; ``` This plugin can be passed into the `plugins` array when calling `Bun.build`. ```ts Bun.build({ entrypoints: ["./app.ts"], outdir: "./out", plugins: [myPlugin], }); ``` h-dump Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/misctools/readlink-realpath.zig (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-09-05Support async `onLoad` callbacks in `Bun.plugin`Gravatar Jarred Sumner 22-717/+1678
2022-09-05Move `generateObjectModuleSourceCode` to separate file to fix build errorGravatar Jarred Sumner 2-24/+31
2022-09-05`inline`Gravatar Jarred Sumner 1-1/+1
2022-09-05Missing #pragma onceGravatar Jarred Sumner 1-0/+2
2022-09-04Rename `is_macro_mode` -> `use_alternate_source_cache`Gravatar Jarred Sumner 2-4/+4
2022-09-04Some testsGravatar Jarred Sumner 1-0/+19
2022-09-04`[node:module]` Implement `_resolveFileName`, stub `_nodeModulePaths` & `_cache`Gravatar Jarred Sumner 7-86/+150
2022-09-04@globalPrivate -> @linkTimeConstantGravatar Jarred Sumner 6-111/+110
2022-09-03[Node API] Fix `napi_module_register`Gravatar Jarred Sumner 6-20/+59
2022-09-03Fix `createRequire()` in `node:module`Gravatar Jarred Sumner 10-161/+302
2022-09-03Fix C++ intellisenseGravatar Jarred Sumner 1-14/+23
2022-09-03Fix build errorGravatar Jarred Sumner 1-6/+5