@considonet/babel-preset-typescript
v1.1.1
Published
Configurable TypeScript preset for Babel 7.x supporting Vue.js TS SFC, React, JS and TypeScript
Downloads
7
Maintainers
Readme
@considonet/babel-preset-typescript
Configurable TypeScript preset for Babel 7.x supporting Vue.js TS SFC, React, JS and TypeScript
What is this?
This preset was created as a part of G-Build evolution. Starting from version 4.0, there are no longer configuration files for Babel and these have to be provided manually (as they are project-specific). Because all our existing legacy projects have exactly the same config, this package makes the transition to G-Build 4 and Babel TypeScript transpilation easy. Also it provides a setup which was proven to work for us.
This preset loads the following presets and plugins:
- @babel/preset-env - pre-configured but ready to be customized depending on configuration
- @babel/preset-react optionally, depending on configuration
- @babel/preset-typescript or our babel-preset-typescript-vue depending on configuration
- @babel/plugin-proposal-object-rest-spread
- @babel/plugin-syntax-dynamic-import
- @babel/plugin-proposal-decorators - with
legacy: true
to support TypeScript decorators - @babel/plugin-proposal-class-properties - with
loose: true
to support TypeScript decorators
Options
vue
(boolean, default: false) - enables TS Vue SFCs transpilation. Because the check is a potentially expensive operation, it is disabled by default. Once enabled, it replaces @babel/preset-typescript with our own babel-preset-typescript-vuereact
(boolean, default: true) - enables@babel/preset-react
presetEnvSettings
(object, default: see below) - configures@babel/preset-env
.
Parameter is optional. The default setup is as follows:
{
"modules": "auto",
"useBuiltIns": "usage",
"corejs": 3
}
Please refer to @babel/preset-env docs for more details.
presetReactSettings
(object, default: see below) - configures@babel/preset-react
ifreact
set to true.
Parameter is optional. The default setup is the preset's default setup.
Please refer to @babel/preset-react docs for more details. It's a good place to set runtime
to automatic
if you're already using React 17.
Install
Using npm:
npm install --save-dev @considonet/babel-preset-typescript
or using yarn:
yarn add @considonet/babel-preset-typescript --dev