Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-preset-rax

Package Overview
Dependencies
Maintainers
4
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-preset-rax - npm Package Compare versions

Comparing version 0.6.5 to 1.0.0-beta.0

51

lib/index.js
"use strict";
var _resolvePlugins = _interopRequireDefault(require("./resolvePlugins"));
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _babelPresetFlow = _interopRequireDefault(require("babel-preset-flow"));
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _babelPresetEs = _interopRequireDefault(require("babel-preset-es2016"));
var _pluginTransformReactJsx = _interopRequireDefault(require("@babel/plugin-transform-react-jsx"));
var _babelPresetEs2 = _interopRequireDefault(require("babel-preset-es2017"));
var _pluginTransformReactDisplayName = _interopRequireDefault(require("@babel/plugin-transform-react-display-name"));
var _babelPresetStage = _interopRequireDefault(require("babel-preset-stage-0"));
var _pluginTransformReactJsxSource = _interopRequireDefault(require("@babel/plugin-transform-react-jsx-source"));
var _pluginTransformReactJsxSelf = _interopRequireDefault(require("@babel/plugin-transform-react-jsx-self"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = {
presets: [_babelPresetFlow.default, _babelPresetEs.default, _babelPresetEs2.default, _babelPresetStage.default],
plugins: (0, _resolvePlugins.default)(['transform-decorators-legacy', 'syntax-jsx', 'transform-react-display-name', ['transform-react-jsx', {
pragma: 'createElement' // default pragma is React.createElement
var _default = (0, _helperPluginUtils.declare)(function (api, opts) {
api.assertVersion(7);
var pragma = opts.pragma || "createElement";
var pragmaFrag = opts.pragmaFrag || "Fragment";
var throwIfNamespace = opts.throwIfNamespace === undefined ? true : Boolean(opts.throwIfNamespace);
var useBuiltIns = Boolean(opts.useBuiltIns);
var development = opts.development;
}], 'transform-jsx-stylesheet', // webpack 3 may not need this plugin
process.env.BABEL_ADD_MODULE_EXPORTS !== 'false' ? 'add-module-exports' : null]),
env: {
development: {
plugins: (0, _resolvePlugins.default)(['transform-react-jsx-source', 'transform-react-jsx-self'])
},
production: {
plugins: (0, _resolvePlugins.default)(['transform-react-constant-elements', 'minify-dead-code-elimination'])
}
if (typeof development !== "boolean") {
throw new Error("@babel/preset-rax 'development' option must be a boolean.");
}
};
return {
plugins: [[_pluginTransformReactJsx.default, {
pragma: pragma,
pragmaFrag: pragmaFrag,
throwIfNamespace: throwIfNamespace,
useBuiltIns: useBuiltIns
}], _pluginTransformReactDisplayName.default, development && _pluginTransformReactJsxSource.default, development && _pluginTransformReactJsxSelf.default].filter(Boolean)
};
});
exports.default = _default;
module.exports = exports["default"];
{
"name": "babel-preset-rax",
"version": "0.6.5",
"version": "1.0.0-beta.0",
"description": "Babel preset for all Rax plugins.",

@@ -19,17 +19,8 @@ "license": "BSD-3-Clause",

"dependencies": {
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-minify-dead-code-elimination": "^0.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-react-constant-elements": "^6.23.0",
"babel-plugin-transform-react-display-name": "^6.23.0",
"babel-plugin-transform-react-jsx": "^6.23.0",
"babel-plugin-transform-react-jsx-self": "^6.22.0",
"babel-plugin-transform-react-jsx-source": "^6.22.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-es2017": "^6.22.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-stage-0": "^6.22.0"
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/plugin-transform-react-display-name": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/plugin-transform-react-jsx-self": "^7.0.0",
"@babel/plugin-transform-react-jsx-source": "^7.0.0"
}
}

@@ -5,8 +5,28 @@ # babel-preset-rax [![npm](https://img.shields.io/npm/v/babel-preset-rax.svg)](https://www.npmjs.com/package/babel-preset-rax) [![Dependency Status](https://david-dm.org/alibaba/rax.svg?path=packages/babel-preset-rax)](https://david-dm.org/alibaba/rax.svg?path=packages/babel-preset-rax) [![Known Vulnerabilities](https://snyk.io/test/npm/babel-preset-rax/badge.svg)](https://snyk.io/test/npm/babel-preset-rax)

## Install
This preset always includes the following plugins:
- [@babel/plugin-syntax-jsx](plugin-syntax-jsx.md)
- [@babel/plugin-transform-react-jsx](plugin-transform-react-jsx.md)
- [@babel/plugin-transform-react-display-name](plugin-transform-react-display-name.md)
And with the `development` option:
- [@babel/plugin-transform-react-jsx-self](plugin-transform-react-jsx-self.md)
- [@babel/plugin-transform-react-jsx-source](plugin-transform-react-jsx-source.md)
## Installation
Using npm:
```sh
$ npm install --save-dev babel-preset-rax
npm install --save-dev babel-preset-rax
```
or using yarn:
```sh
yarn add babel-preset-rax --dev
```
## Usage

@@ -18,12 +38,31 @@

Without options:
```json
{
"presets": ["rax"]
"presets": ["babel-preset-rax"]
}
```
With options:
```json
{
"presets": [
[
"babel-preset-rax",
{
"pragma": "dom", // default pragma is createElement
"pragmaFrag": "DomFrag", // default is Fragment
"throwIfNamespace": false // defaults to true
}
]
]
}
```
### Via CLI
```sh
$ babel script.js --presets rax
babel --presets babel-preset-rax script.js
```

@@ -34,5 +73,72 @@

```javascript
require('babel-core').transform('code', {
presets: ['rax']
require("@babel/core").transform("code", {
presets: ["babel-preset-rax"],
});
```
## Options
### `pragma`
`string`, defaults to `createElement`.
Replace the function used when compiling JSX expressions.
### `pragmaFrag`
`string`, defaults to `Fragment`.
Replace the component used when compiling JSX fragments.
### `useBuiltIns`
`boolean`, defaults to `false`.
Will use the native built-in instead of trying to polyfill behavior for any plugins that require one.
### `development`
`boolean`, defaults to `false`.
Toggles plugins that aid in development, such as [`@babel/plugin-transform-react-jsx-self`](plugin-transform-react-jsx-self.md) and [`@babel/plugin-transform-react-jsx-source`](plugin-transform-react-jsx-source.md).
This is useful when combined with the [env option](options.md#env) configuration or [js config files](config-files.md#javascript).
### `throwIfNamespace`
`boolean`, defaults to `true`.
Toggles whether or not to throw an error if a XML namespaced tag name is used. For example:
<f:image />
Though the JSX spec allows this, it is disabled by default since React's JSX does not currently have support for it.
#### .babelrc.js
```js
module.exports = {
presets: [
[
"babel-preset-rax",
{
development: process.env.BABEL_ENV === "development",
},
],
],
};
```
#### .babelrc
> Note: the `env` option will likely get deprecated soon
```json
{
"presets": ["babel-preset-rax"],
"env": {
"development": {
"presets": [["babel-preset-rax", { "development": true }]]
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc