@10up/babel-preset-default 中文文档教程
10up babel preset
用于在 10up 转换 JavaScript 的 Babel 预设。
Instalation
npm install --save-dev @10up/babel-preset-default
Usage
只需添加 < code>@10up/babel-preset-default 到你的 .babelrc
文件
// .babelrc
{
"presets": [ "@10up/babel-preset-default"]
}
Options
这个 babel preset 暴露了一些选项。 下面列出了默认选项。
// .babelrc
{
"presets": [
["@10up/babel-preset-default", {
"modules": "auto",
// defaults to true if modules is false and false otherwise.
"runtimeESModules": false,
"wordpress": false,
"debug": false,
"removePropTypes": {},
"targets": [
"> 1%",
"ie >= 11",
"last 2 versions",
"Firefox ESR"
]
}]
]
}
options.modules
这是 @babel/preset-env
modules 设置。 默认为 auto
,它将检测“调用者”(例如 webpack)是否支持 ES6 模块,如果支持,将禁用模块转译(例如,这是 tree-shaking 所需的行为);
options.wordpress
启用后将加载 @wordpress/babel-preset-default
。 构建 WordPress Gutenberg 块时需要。
options.debug
启用调试消息。 有助于查看 babel 使用的预设和插件。
options.removePropTypes
默认情况下,此 babel 预设将在构建生产时删除所有 prop-types 声明。
你很少需要更改此设置,但如果你这样做,此选项让你指定任何 babel-plugin-transform-react-remove-prop-types 选项。
options.targets
让我们指定支持哪些浏览器。 如果您想利用浏览器列表配置源 (.browserslistrc
),请将此选项设置为 {}
。 默认情况下,将支持以下浏览器。
[
"> 1%",
"ie >= 11",
"last 2 versions",
"Firefox ESR"
]
将自动为这些浏览器添加适当的 core-js
polyfill。
options.development
您可以设置此标志以启用或禁用开发模式,但是,此预设将根据调用者加载它的方式(例如 webpack)自动检测它。
Support Level
活跃:10up 正在为此积极努力,我们希望在可预见的未来继续努力。 欢迎错误报告、功能请求、问题和请求请求。
Like what you see?
10up babel preset
Babel preset for transforming JavaScript at 10up.
Instalation
npm install --save-dev @10up/babel-preset-default
Usage
Simply add @10up/babel-preset-default
to your .babelrc
file
// .babelrc
{
"presets": [ "@10up/babel-preset-default"]
}
Options
This babel preset exposes a few options. The default options are listed below.
// .babelrc
{
"presets": [
["@10up/babel-preset-default", {
"modules": "auto",
// defaults to true if modules is false and false otherwise.
"runtimeESModules": false,
"wordpress": false,
"debug": false,
"removePropTypes": {},
"targets": [
"> 1%",
"ie >= 11",
"last 2 versions",
"Firefox ESR"
]
}]
]
}
options.modules
It's the @babel/preset-env
modules setting. Default's to auto
which will detect whether the "caller" (e.g webpack) has ES6 modules support and if so, will disable module transpilation (this is the desired behavior for tree-shaking for example);
options.wordpress
When enabled will load @wordpress/babel-preset-default
. Required when building WordPress Gutenberg blocks.
options.debug
Enables debug messages. Usefull to review which presets and plugins babel is using.
options.removePropTypes
By default this babel preset will remove any prop-types declarations when building for production.
You rarelly will need to change this setting, but in case you do, this option let's you specify any of the babel-plugin-transform-react-remove-prop-types options.
options.targets
Let's you specify which browser's are support. Set this option to {}
if you want to leverage browserlist config sources (.browserslistrc
). By default, the following browsers will be supported.
[
"> 1%",
"ie >= 11",
"last 2 versions",
"Firefox ESR"
]
The appropriate core-js
polyfills will be added automatically for those browsers.
options.development
You can set this flag to enable or disable development mode, however, this preset will automatically detect that based on how it was loaded by the caller (e.g webpack).
Support Level
Active: 10up is actively working on this, and we expect to continue work for the foreseeable future. Bug reports, feature requests, questions, and pull requests are welcome.
Like what you see?
你可能也喜欢
- @01ht/ht-image-slider 中文文档教程
- @0x-klaytn/base-contract 中文文档教程
- @10yun/cv-pc-editor-markdown 中文文档教程
- @33cn/chain33errori18n 中文文档教程
- @4geit/rct-landing-page-layout-component 中文文档教程
- @a2h1t4k4/sayhello 中文文档教程
- @aabuhijleh/windows-notification-state 中文文档教程
- @abdelmageed/nodejs-tutorial 中文文档教程
- @abdul589/lotide 中文文档教程
- @abext/integrations 中文文档教程