Create a lazy-loaded virtual module that can be imported or required from other modules
PluginBuilder.module method | Bun module | Bun BuildDocsReferenceGuidesBlogDiscord/Bun/PluginBuilder/moduleMmodule BuildDocsReferenceGuidesBlogDiscord /Bun/PluginBuilder/moduleMmodule PluginBuilder.modulemodule(specifier: string,callback: () => OnLoadResult | PromiseOnLoadResult>): this; @param specifier @param callback @returns
Search the reference...
/
method
The module specifier to register the callback for
The function to run when the module is imported or required
this for method chaining
Bun.plugin({
setup(builder) {
builder.module("hello:world", () => {
return { exports: { foo: "bar" }, loader: "object" };
});
},
});
// sometime later
const { foo } = await import("hello:world");
console.log(foo); // "bar"
// or
const { foo } = require("hello:world");
console.log(foo); // "bar"
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →PluginBuilder.module method | Bun module | Bun,AI智能索引,全网链接索引,智能导航,网页索引
- API documentation for method bun.PluginBuilder.module | Bun