esbuild --define:foo=bar
bun build --define foo=bar--external:--external Small syntax difference; no colon.
esbuild --external:react
bun build --external react--format--formatBun supports "esm" and "cjs" currently, but more module formats are planned. esbuild defaults to "iife".--loader:.ext=loader--loader .ext:loaderBun supports a different set of built-in loaders than esbuild; see Bundler > Loaders for a complete reference. The esbuild loaders dataurl, binary, base64, copy, and empty are not yet implemented.
The syntax for --loader is slightly different.
esbuild app.ts --bundle --loader:.svg=text
bun build app.ts --loader .svg:text--minify--minifyNo differences--outdir--outdirNo differences--outfile--outfileNo differences--packages--packagesNo differences--platform--targetRenamed to --target for consistency with tsconfig. Does not support neutral.--serven/aNot applicable--sourcemap--sourcemapNo differences--splitting--splittingNo differences--targetn/aNot supported. Bun’s bundler performs no syntactic down-leveling at this time.--watch--watchNo differences--allow-overwriten/aOverwriting is never allowed--analyzen/aNot supported--asset-names--asset-namingRenamed for consistency with naming in JS API--banner--bannerOnly applies to js bundles--footer--footerOnly applies to js bundles--certfilen/aNot applicable--charset=utf8n/aNot supported--chunk-names--chunk-namingRenamed for consistency with naming in JS API--colorn/aAlways enabled--drop--dropn/a--featureBun-specific. Enable feature flags for compile-time dead-code elimination via import { feature } from "bun:bundle"--entry-names--entry-namingRenamed for consistency with naming in JS API--global-namen/aNot applicable, Bun does not support iife output at this time--ignore-annotations--ignore-dce-annotations--injectn/aNot supported--jsx--jsx-runtime Supports "automatic" (uses jsx transform) and "classic" (uses React.createElement)--jsx-devn/aBun reads compilerOptions.jsx from tsconfig.json to determine a default. If compilerOptions.jsx is "react-jsx", or if NODE_ENV=production, Bun will use the jsx transform. Otherwise, it uses jsxDEV. The bundler does not support preserve.--jsx-factory--jsx-factory--jsx-fragment--jsx-fragment--jsx-import-source--jsx-import-source--jsx-side-effectsn/aJSX is always assumed to be side-effect-free--keep-namesn/aNot supported--keyfilen/aNot applicable--legal-commentsn/aNot supported--log-leveln/aNot supported. This can be set in bunfig.toml as logLevel.--log-limitn/aNot supported--log-override:X=Yn/aNot supported--main-fieldsn/aNot supported--mangle-cachen/aNot supported--mangle-propsn/aNot supported--mangle-quotedn/aNot supported--metafilen/aNot supported--minify-whitespace--minify-whitespace--minify-identifiers--minify-identifiers--minify-syntax--minify-syntax--out-extensionn/aNot supported--outbase--root--preserve-symlinksn/aNot supported--public-path--public-path--puren/aNot supported--reserve-propsn/aNot supported--resolve-extensionsn/aNot supported--servedirn/aNot applicable--source-rootn/aNot supported--sourcefilen/aNot supported. Bun does not support stdin input yet.--sourcemap--sourcemapNo differences--sources-contentn/aNot supported--supportedn/aNot supported--tree-shakingn/aAlways true--tsconfig--tsconfig-override--versionn/aRun bun --version to see the version of Bun. JavaScript API esbuild.build()Bun.build()NotesabsWorkingDirn/aAlways set to process.cwd()aliasn/aNot supportedallowOverwriten/aAlways falseassetNamesnaming.assetUses same templating syntax as esbuild, but [ext] must be included explicitly.
ts
Bun.build({
entrypoints: ["./index.tsx"],
naming: {
asset: "[name].[ext]",
},
});
bannern/aNot supportedbundlen/aAlways true. Use Bun.Transpiler to transpile without bundling.charsetn/aNot supportedchunkNamesnaming.chunkUses same templating syntax as esbuild, but [ext] must be included explicitly.
ts
Bun.build({
entrypoints: ["./index.tsx"],
naming: {
chunk: "[name].[ext]",
},
});
colorn/aBun returns logs in the logs property of the build result.conditionsn/aNot supported. Export conditions priority is determined by target.definedefinedropn/aNot supportedentryNamesnaming or naming.entryBun supports a naming key that can either be a string or an object. Uses same templating syntax as esbuild, but [ext] must be included explicitly.
ts
Bun.build({
entrypoints: ["./index.tsx"],
// when string, this is equivalent to entryNames
naming: "[name].[ext]",
// granular naming options
naming: {
entry: "[name].[ext]",
asset: "[name].[ext]",
chunk: "[name].[ext]",
},
});
entryPointsentrypointsCapitalization differenceexternalexternalNo differencesfootern/aNot supportedformatformatOnly supports "esm" currently. Support for "cjs" and "iife" is planned.globalNamen/aNot supportedignoreAnnotationsn/aNot supportedinjectn/aNot supportedjsxjsxNot supported in JS API, configure in tsconfig.jsonjsxDevjsxDevNot supported in JS API, configure in tsconfig.jsonjsxFactoryjsxFactoryNot supported in JS API, configure in tsconfig.jsonjsxFragmentjsxFragmentNot supported in JS API, configure in tsconfig.jsonjsxImportSourcejsxImportSourceNot supported in JS API, configure in tsconfig.jsonjsxSideEffectsjsxSideEffectsNot supported in JS API, configure in tsconfig.jsonkeepNamesn/aNot supportedlegalCommentsn/aNot supportedloaderloaderBun supports a different set of built-in loaders than esbuild; see Bundler > Loaders for a complete reference. The esbuild loaders dataurl, binary, base64, copy, and empty are not yet implemented.logLeveln/aNot supportedlogLimitn/aNot supportedlogOverriden/aNot supportedmainFieldsn/aNot supportedmangleCachen/aNot supportedmanglePropsn/aNot supportedmangleQuotedn/aNot supportedmetafilen/aNot supportedminifyminifyIn Bun, minify can be a boolean or an object.
ts
await Bun.build({
entrypoints: ['./index.tsx'],
// enable all minification
minify: true
// granular options
minify: {
identifiers: true,
syntax: true,
whitespace: true
}
})
minifyIdentifiersminify.identifiersSee minifyminifySyntaxminify.syntaxSee minifyminifyWhitespaceminify.whitespaceSee minifynodePathsn/aNot supportedoutExtensionn/aNot supportedoutbaserootDifferent nameoutdiroutdirNo differencesoutfileoutfileNo differencespackagesn/aNot supported, use externalplatformtargetSupports "bun", "node" and "browser" (the default). Does not support "neutral".pluginspluginsBun’s plugin API is a subset of esbuild’s. Some esbuild plugins will work out of the box with Bun.preserveSymlinksn/aNot supportedpublicPathpublicPathNo differencespuren/aNot supportedreservePropsn/aNot supportedresolveExtensionsn/aNot supportedsourceRootn/aNot supportedsourcemapsourcemapSupports "inline", "external", and "none"sourcesContentn/aNot supportedsplittingsplittingNo differencesstdinn/aNot supportedsupportedn/aNot supportedtargetn/aNo support for syntax downlevelingtreeShakingn/aAlways truetsconfign/aNot supportedwriten/aSet to true if outdir/outfile is set, otherwise false Plugin API Bun’s plugin API is designed to be esbuild compatible. Bun doesn’t support esbuild’s entire plugin API surface, but the core functionality is implemented. Many third-party esbuild plugins will work out of the box with Bun. Long term, we aim for feature parity with esbuild’s API, so if something doesn’t work please file an issue to help us prioritize. Plugins in Bun and esbuild are defined with a builder object. myPlugin.tsCopyimport type { BunPlugin } from "bun"; const myPlugin: BunPlugin = { name: "my-plugin", setup(builder) { // define plugin }, }; The builder object provides some methods for hooking into parts of the bundling process. Bun implements onStart, onEnd, onResolve, and onLoad. It does not yet implement the esbuild hooks onDispose and resolve. initialOptions is partially implemented, being read-only and only having a subset of esbuild’s options; use config (same thing but with Bun’s BuildConfig format) instead. myPlugin.tsCopyimport type { BunPlugin } from "bun"; const myPlugin: BunPlugin = { name: "my-plugin", setup(builder) { builder.onStart(() => { /* called when the bundle starts */ }); builder.onResolve( { /* onResolve.options */ }, args => { return { /* onResolve.results */ }; }, ); builder.onLoad( { /* onLoad.options */ }, args => { return { /* onLoad.results */ }; }, ); builder.onEnd(result => { /* called when the bundle is complete */ }); }, }; onResolve options arguments results 🟢 filter 🟢 namespace 🟢 path 🟢 importer 🔴 namespace 🔴 resolveDir 🔴 kind 🔴 pluginData 🟢 namespace 🟢 path 🔴 errors 🔴 external 🔴 pluginData 🔴 pluginName 🔴 sideEffects 🔴 suffix 🔴 warnings 🔴 watchDirs 🔴 watchFiles onLoad options arguments results 🟢 filter 🟢 namespace 🟢 path 🔴 namespace 🔴 suffix 🔴 pluginData 🟢 contents 🟢 loader 🔴 errors 🔴 pluginData 🔴 pluginName 🔴 resolveDir 🔴 warnings 🔴 watchDirs 🔴 watchFiles
Was this page helpful?
YesNoSuggest editsRaise issuePrevious⌘IxgithubdiscordyoutubePowered by智能索引记录
-
2026-02-28 04:25:15
综合导航
成功
标题:Bâtir la confiance par la protection des données PwC Canada
简介:Gérez la protection des données selon une approche collabora
-
2026-03-01 08:53:25
教育培训
成功
标题:【优秀】五年级家乡的作文
简介:在平日的学习、工作和生活里,大家都不可避免地会接触到作文吧,借助作文人们可以实现文化交流的目的。那要怎么写好作文呢?下面
-
2026-02-27 16:46:13
综合导航
成功
标题:Authorized Jabra, Yealink, and Video Products – t3e Company
简介:Authorized Jabra, Yealink and Video Products.
-
2026-03-01 15:43:33
教育培训
成功
标题:公园踏春作文
简介:在平凡的学习、工作、生活中,许多人都有过写作文的经历,对作文都不陌生吧,借助作文可以提高我们的语言组织能力。那么你有了解
-
2026-03-01 03:17:09
图片素材
成功
标题:物理的作文550字 描写物理的作文 关于物理的作文-作文网
简介:作文网精选关于物理的550字作文,包含物理的作文素材,关于物理的作文题目,以物理为话题的550字作文大全,作文网原创名师
-
2026-03-01 15:14:55
教育培训
成功
标题:2023海南大学研究生考点报考要求最新公布-高顿教育
简介:2023海南大学研究生考点报考要求已经正式公布,选择海南大学海甸校区报考点需符合3条要求之一:海南省省内的普通高校的应(
-
2026-03-01 11:10:16
综合导航
成功
标题:Thomas K. Montag Goldman Sachs
简介:A director since July 2023, Thomas Montag is on the Goldman
-
2026-03-01 12:41:56
教育培训
成功
标题:五年级作文:清明节
简介:在平日的学习、工作和生活里,大家最不陌生的就是作文了吧,写作文可以锻炼我们的独处习惯,让自己的心静下来,思考自己未来的方
-
2026-03-01 11:23:21
实用工具
成功
标题:【实用】三年级发明作文七篇
简介:在我们平凡的日常里,大家都跟作文打过交道吧,作文是人们以书面形式表情达意的言语活动。你写作文时总是无从下笔?下面是小编精
-
2026-02-28 04:11:45
综合导航
成功
标题:910 DualTrans Vacuum Transducer
简介:The 910 Transducer combines Piezo and Micro Pirani™ sensor t
-
2026-03-01 12:49:36
教育培训
成功
标题:初中生作文【汇总8篇】
简介:在平凡的学习、工作、生活中,大家都接触过作文吧,通过作文可以把我们那些零零散散的思想,聚集在一块。那么一般作文是怎么写的
-
2026-02-27 17:29:44
综合导航
成功
标题:Reebok® Official Site Life is Not a Spectator Sport
简介:Discover Reebok’s iconic athletic shoes, apparel, and gear d
-
2026-03-01 02:53:24
综合导航
成功
标题:Contract jobs · GQR
简介:Job Search Page 1 - GQR
-
2026-02-28 23:40:01
图片素材
成功
标题:初二演讲稿作文600字 初二600字演讲稿作文大全-作文网
简介:作文网优秀初二演讲稿600字作文大全,包含初二演讲稿600字作文素材,初二演讲稿600字作文题目、美文范文,作文网原创名
-
2026-03-01 15:14:40
教育培训
成功
标题:三年级假期作文300字3篇
简介:在日常的学习、工作、生活中,大家都不可避免地会接触到作文吧,通过作文可以把我们那些零零散散的思想,聚集在一块。那么问题来
-
2026-03-01 03:21:15
图片素材
成功
标题:荣光的作文350字 描写荣光的作文 关于荣光的作文-作文网
简介:作文网精选关于荣光的350字作文,包含荣光的作文素材,关于荣光的作文题目,以荣光为话题的350字作文大全,作文网原创名师
-
2026-03-01 03:36:25
综合导航
成功
标题:Android - Logan Remote
简介:The Logan offers all functionality you expect from an Androi
-
2026-03-01 03:00:46
综合导航
成功
标题:小学六年级叙事作文:有一种记忆叫温暖
简介:在日常学习、工作和生活中,大家都尝试过写作文吧,作文是一种言语活动,具有高度的综合性和创造性。你写作文时总是无从下笔?下
-
2026-03-01 15:43:35
综合导航
成功
标题:【精选】身边的幸福作文合集八篇
简介:无论是在学校还是在社会中,说到作文,大家肯定都不陌生吧,借助作文可以提高我们的语言组织能力。那么一般作文是怎么写的呢?以
-
2026-03-01 02:59:18
教育培训
成功
标题:小学作文300字汇编【3篇】
简介:在学习、工作乃至生活中,许多人都有过写作文的经历,对作文都不陌生吧,写作文是培养人们的观察力、联想力、想象力、思考力和记
-
2026-03-01 18:24:29
综合导航
成功
标题:Ботильоны: купить ботильоны недорого на RIA.com
简介:Купить ботильоны недорого: большой выбор объявлений продам б
-
2026-03-01 11:18:27
图片素材
成功
标题:女巫的作文450字 描写女巫的作文 关于女巫的作文-作文网
简介:作文网精选关于女巫的450字作文,包含女巫的作文素材,关于女巫的作文题目,以女巫为话题的450字作文大全,作文网原创名师
-
2026-03-01 08:43:50
教育培训
成功
标题:小学的作文
简介:在学习、工作乃至生活中,大家都写过作文吧,作文要求篇章结构完整,一定要避免无结尾作文的出现。怎么写作文才能避免踩雷呢?以
-
2026-03-01 11:30:46
教育培训
成功
标题:(通用)特别的礼物的作文400字
简介:在学习、工作乃至生活中,大家都不可避免地要接触到作文吧,写作文是培养人们的观察力、联想力、想象力、思考力和记忆力的重要手
-
2026-03-01 03:07:16
教育培训
成功
标题:关于高中的作文汇编10篇
简介:在日常生活或是工作学习中,大家对作文都不陌生吧,作文是人们以书面形式表情达意的言语活动。相信写作文是一个让许多人都头痛的
-
2026-03-01 12:55:34
综合导航
成功
标题:三年级叙事作文:“梦游”的表哥_400字_作文网
简介:记得我五岁的时候,我家发生一件有趣的事情。那天早上起床发现房间门口有一只拖鞋,那只拖鞋不是我表的吗?怎么会在我房间门口呢
-
2026-03-01 16:18:07
教育培训
成功
标题:语文老师作文
简介:在平平淡淡的学习、工作、生活中,许多人都有过写作文的经历,对作文都不陌生吧,作文根据写作时限的不同可以分为限时作文和非限
-
2026-03-01 03:03:34
图片素材
成功
标题:污染的作文1000字 描写污染的作文 关于污染的作文-作文网
简介:作文网精选关于污染的1000字作文,包含污染的作文素材,关于污染的作文题目,以污染为话题的1000字作文大全,作文网原创
-
2026-03-01 12:19:37
教育培训
成功
标题:精选我的乐趣作文600字3篇
简介:在日常学习、工作或生活中,大家对作文都再熟悉不过了吧,通过作文可以把我们那些零零散散的思想,聚集在一块。怎么写作文才能避
-
2026-03-01 02:46:34
图片素材
成功
标题:语文的作文500字 描写语文的作文 关于语文的作文-作文网
简介:作文网精选关于语文的500字作文,包含语文的作文素材,关于语文的作文题目,以语文为话题的500字作文大全,作文网原创名师