温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/TranspilerOptions
点击访问原文链接

Bun.TranspilerOptions TypeScript interface | API Reference | Bun

Bun.TranspilerOptions TypeScript interface | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/Bun/TranspilerOptionsPallowBunRuntimePautoImportJSXPdeadCodeEliminationPdefinePexportsPinlinePjsxOptimizationInlinePloaderPlogLevelPmacroPminifyWhitespacePreplModePtargetPtreeShakingPtrimUnusedImportsPtsconfig

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/TranspilerOptionsPallowBunRuntimePautoImportJSXPdeadCodeEliminationPdefinePexportsPinlinePjsxOptimizationInlinePloaderPlogLevelPmacroPminifyWhitespacePreplModePtargetPtreeShakingPtrimUnusedImportsPtsconfig

interface

TranspilerOptionsinterface TranspilerOptionsallowBunRuntime?: booleanautoImportJSX?: booleandeadCodeElimination?: boolean

Experimental

Enabled by default, use this to disable dead code elimination.

Some other transpiler options may still do some specific dead code elimination.

define?: Recordstring, string>

Replace key with value. Value must be a JSON string.

 { "process.env.NODE_ENV": "\"production\"" }
exports?: { eliminate: string[]; replace: Recordstring, string> }inline?: boolean

This does two things (and possibly more in the future):

const declarations to primitive types (excluding Object/Array) at the top of a scope before any let or var declarations will be inlined into their usages.let and const declarations only used once are inlined into their usages.

JavaScript engines typically do these optimizations internally, however it might only happen much later in the compilation pipeline, after code has been executed many many times.

This will typically shrink the output size of code, but it might increase it in some cases. Do your own benchmarks!

jsxOptimizationInline?: booleanloader?: JavaScriptLoader

What is the default loader used for this transpiler?

logLevel?: 'error' | 'verbose' | 'debug' | 'info' | 'warn'
macro?: MacroMap

Replace an import statement with a macro.

This will remove the import statement from the final output and replace any function calls or template strings with the result returned by the macro

 {
"react-relay": {
"graphql": "bun-macro-relay"
}
}

Code that calls graphql will be replaced with the result of the macro.

import {graphql} from "react-relay";

// Input:
const query = graphql`
query {
... on User {
id
}
}
}`;

Will be replaced with:

import UserQuery from "./UserQuery.graphql";
const query = UserQuery;
minifyWhitespace?: boolean

Experimental

Minify whitespace and comments from the output.

replMode?: boolean

Enable REPL mode transforms:

Wraps top-level inputs that appear to be object literals (inputs starting with '{' without trailing ';') in parenthesesHoists all declarations as var for REPL persistence across vm.runInContext callsWraps last expression in { proto: null, value: expr } for result captureWraps code in sync/async IIFE to avoid parentheses around object literals
target?: Target
"browser"
treeShaking?: booleantrimUnusedImports?: booleantsconfig?: string | TSConfig

TSConfig.json file as stringified JSON or an object Use this to set a custom JSX factory, fragment, or import source For example, if you want to use Preact instead of React. Or if you want to use Emotion.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Bun.TranspilerOptions TypeScript interface | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for interface bun.TranspilerOptions | Bun