lib.syntax
- Type:
- Default:
['node >= <minimum-version>']when output.target is'node'andpackage.json#engines.nodedeclares an inferable minimum Node.js version- Otherwise,
'esnext'
- CLI:
--syntax <value>(repeatable, e.g.--syntax es2018or--syntax="node 14" --syntax="Chrome 103") - Top-level config: Supported
Configure the syntax to which JavaScript and CSS will be downgraded.
See Output Compatibility - Syntax Downgrade for more details.
Default behavior
When output.target is set to 'node' and syntax is not configured, Rslib tries to infer the syntax target from package.json#engines.node. If package.json declares an inferable engines.node range, Rslib uses the minimum Node.js version from that range as the syntax target.
The config above is equivalent to:
In other cases, Rslib defaults to 'esnext'. This means the output targets only the latest versions of mainstream browsers (Chrome / Firefox / Edge / macOS Safari / iOS Safari) or the latest Node.js version, depending on output.target.
To override this default behavior, set syntax explicitly.
Set ECMAScript version
You can set the ECMAScript version directly, such as es2015, es2022, etc.
Set browserslist query
You can also set the Browserslist query, such as last 2 versions, > 1%, node >= 16, chrome >= 80, etc.
Mix ECMAScript version and browserslist query
You can also mix ECMAScript version and Browserslist query, such as es2015 and node 20. Rslib will turn ECMAScript Version into Browserslist query, and then merge them together.
