lib.syntax
type EcmaScriptVersion =
| 'es5'
| 'es6'
| 'es2015'
| 'es2016'
| 'es2017'
| 'es2018'
| 'es2019'
| 'es2020'
| 'es2021'
| 'es2022'
| 'es2023'
| 'es2024'
| 'esnext';
type Syntax = EcmaScriptVersion | string[];
Configure the syntax to which JavaScript and CSS will be downgraded.
See Output Compatibility - Syntax Downgrade for more details.
Set ECMAScript Version
You can set the ECMAScript version directly, such as es2015
, es2022
, etc.
rslib.config.ts
export default {
lib: [
// ...
],
syntax: 'es2015',
};
Set Browserslist Query
You can also set the Browserslist query, such as last 2 versions
, > 1%
, node >= 16
, chrome >= 80
, etc.
rslib.config.ts
export default {
lib: [
{
syntax: ['last 2 versions', '> 1%'],
},
],
};
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.
rslib.config.ts
export default {
lib: [
{
syntax: ['es2015', 'node 20'],
},
],
};