Skip to content

Syntax Lowering

Oxc transformer supports lowering ESNext to ES2015 syntax.

Target

Oxc transformer receives a target option to specify the target runtime. This will determine which syntaxes are lowered and which warnings are emitted.

Each target environment is an environment name followed by a version number. The following environment names are currently supported:

  • chrome
  • deno
  • edge
  • firefox
  • hermes
  • ie
  • ios
  • node
  • opera
  • rhino
  • safari
  • samsung
  • es

The values that are supported by esbuild's target option are supported, excluding ES5.

You can pass a single string or an array of strings:

js
import { transform } from "oxc-transform";

const result = await transform("lib.js", "const foo = a ?? b;", {
  target: "es2020",
  // or multiple targets:
  // target: ["chrome87", "es2022"],
});
``````js
import { transform } from "oxc-transform";

const result = await transform("lib.js", "const foo = a ?? b;", {
  target: ["chrome87", "es2022"],
  assumptions: {
    noDocumentAll: true,
  },
});