babel-preset-moon
v3.0.3
Published
A modern Babel preset for tooling development.
Downloads
3,293
Maintainers
Readme
babel-preset-moon
A modern Babel preset with built-in TypeScript support. Is designed for unit testing, linting, and local development only -- it should not be used for web applications or package building (use Packemon instead).
yarn add --dev babel-preset-moon
Setup
Add the preset to your root babel.config.js
.
module.exports = {
presets: ['moon'],
};
Features
- Configures the
env
preset for the current Node.js version. - Enables the
typescript
preset by default. TypeScript everywhere! - Enables native
async
/await
and avoids Regenerator. - Enables
export
default and namespace from syntax. - Supports the
react
preset and both JSX runtimes. - Supports the
solid
preset with SSR and hydration. - Converts
__DEV__
,__PROD__
, and__TEST__
toprocess.env
checks. - Wraps
invariant()
inprocess.env
conditionals.
Options
The following options can be passed to the preset.
decorators
(boolean
) - Enable TypeScript decorators. If true, will toggle Babel into loose mode. Defaults tofalse
.loose
(boolean
) - Turn on Babel loose mode for all plugins. Defaults tofalse
.modules
(boolean
) - Force transpilation to use ECMA script module syntax. Defaults tofalse
(auto
modules).react
(boolean | classic | automatic
) - Enable the React plugin and the defined JSX runtime. Defaults tofalse
.solid
(boolean | ssr
) - Enable the Solid.js plugin. Hydration is always enabled.targets
(Record<string, string> | string[] | string
) - Override the target environment. Defaults to Node.jscurrent
.
module.exports = {
presets: [['moon', { decorators: true, react: 'automatic' }]],
};