Experimental
Enabled by default, use this to disable dead code elimination.
Some other transpiler options may still do some specific dead code elimination.
Symbol
Experimental
Enabled by default, use this to disable dead code elimination.
Some other transpiler options may still do some specific dead code elimination.
Replace key with value. Value must be a JSON string.
{ "process.env.NODE_ENV": "\"production\"" }
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!
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;