babel-preset-atomic v5.0.0
babel-preset-atomic
This includes the babel configuration used for JavaScript packages in atom-ide-community.
Installation
npm install --save-dev babel-preset-atomicIf using npm, the bundled babel is hoisted automatically.
If using pnpm, either add the following to your .npmrc to hoist the prettier bundled with the config
public-hoist-pattern[]=*Or install these yourself in your devDependencies.
pnpm install -save-dev "@babel/core"
pnpm install -save-dev "@babel/cli"Usage
Create a babel.config.json file at the root of the project with the following content:
{
"presets": ["babel-preset-atomic"],
"plugins": [],
"exclude": "node_modules/**",
"sourceMap": "inline"
}Use babel.config.js if you need more control over the config.
let presets = ["babel-preset-atomic"]
let plugins = []
module.exports = {
presets: presets,
plugins: plugins,
exclude: "node_modules/**",
sourceMap: "inline",
}Options
keepModules
If you want to keep the ES modules as they are (not transforming import to require), set BABEL_KEEP_MODULES environment variable to true. This is useful with bundlers which need you to keep ES6 modules intact. By default the ES6 modules are transformed to ES5 (the value is false)
cross-env BABEL_KEEP_MODULES=trueTo permanently set this option, you can add it to your babel config (which disables environment variable effectiveness):
{
"presets": [
[
"babel-preset-atomic",
{
"keepModules": true,
},
],
]
}let presets = [
[
"babel-preset-atomic",
{
keepModules: true,
},
],
]targets
To change the target of preset-env plugin. By default this is configured for Electron.
{
"presets": [
[
"babel-preset-atomic",
{
"targets": {
"electron": 9
}
}
]
]
}let presets = [
[
"babel-preset-atomic",
{
targets: {
electron: 9,
},
},
],
]addModuleExports:
Allows to require a ES6 module that has exported a single thing as default, in a ES5 fashion without require().default. This is true by default for backward compatibility with Atom packages.
{
"presets": [
[
"babel-preset-atomic",
{
"addModuleExports": false
}
]
]
}let presets = [
[
"babel-preset-atomic",
{
addModuleExports: false,
},
],
]addModuleExportsDefaultProperty:
{
"presets": [
[
"babel-preset-atomic",
{
"addModuleExports": true,
"addModuleExportsDefaultProperty": true
}
]
]
}let presets = [
[
"babel-preset-atomic",
{
addModuleExports: true,
addModuleExportsDefaultProperty: true,
},
],
]Adds default property to module.exports so the ES6 module can be required in the ES6 fashion as well (by require().default). This is false by default.
react
Enable "@babel/preset-react". true by default. You can also pass an object to provide more options for this plugin.
flow
Enable "@babel/preset-flow". true by default. You can also pass an object to provide more options for this plugin.
typescript
Enable "@babel/preset-typescript". true by default. You can also pass an object to provide more options for this plugin.
removeAllUseStrict
Remove all 'use strict' from all files. Passed to babel-plugin-transform-not-strict. This is false by default.
notStrictDirectiveTriggersandnotStrictCommentTriggers
These specify "not strict" triggers. Passed to babel-plugin-transform-not-strict.
Behind the scenes
It includes the following presets:
"@babel/preset-env"(configured forelectron)"@babel/preset-react""@babel/preset-flow""@babel/preset-typescript"
It also includes all the proposal plugins such as:
"@babel/plugin-proposal-optional-chaining""@babel/plugin-proposal-nullish-coalescing-operator""@babel/plugin-proposal-export-default-from""@babel/plugin-proposal-export-namespace-from"- ...
It includes the plugins for compile time code generation:
"babel-plugin-codegen""babel-plugin-preval"
It has the preset that automatically adds default export for older Node versions (so no require().default is needed).
"babel-plugin-add-module-exports"
It has the plugin for removing 'use strict':
"babel-plugin-transform-not-strict"
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago