babel-preset-rax
Advanced tools
Comparing version 0.6.5 to 1.0.0-beta.0
"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" | ||
} | ||
} |
118
README.md
@@ -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 }]] | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
5505
5
142
0
3
31
+ Added@ampproject/remapping@2.3.0(transitive)
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/compat-data@7.26.3(transitive)
+ Added@babel/core@7.26.0(transitive)
+ Added@babel/generator@7.26.3(transitive)
+ Added@babel/helper-annotate-as-pure@7.25.9(transitive)
+ Added@babel/helper-compilation-targets@7.25.9(transitive)
+ Added@babel/helper-module-imports@7.25.9(transitive)
+ Added@babel/helper-module-transforms@7.26.0(transitive)
+ Added@babel/helper-plugin-utils@7.25.9(transitive)
+ Added@babel/helper-string-parser@7.25.9(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/helper-validator-option@7.25.9(transitive)
+ Added@babel/helpers@7.26.0(transitive)
+ Added@babel/parser@7.26.3(transitive)
+ Added@babel/plugin-syntax-jsx@7.25.9(transitive)
+ Added@babel/plugin-transform-react-display-name@7.25.9(transitive)
+ Added@babel/plugin-transform-react-jsx@7.25.9(transitive)
+ Added@babel/plugin-transform-react-jsx-self@7.25.9(transitive)
+ Added@babel/plugin-transform-react-jsx-source@7.25.9(transitive)
+ Added@babel/template@7.25.9(transitive)
+ Added@babel/traverse@7.26.4(transitive)
+ Added@babel/types@7.26.3(transitive)
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Addedbrowserslist@4.24.3(transitive)
+ Addedcaniuse-lite@1.0.30001690(transitive)
+ Addedconvert-source-map@2.0.0(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedelectron-to-chromium@1.5.76(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedgensync@1.0.0-beta.2(transitive)
+ Addedglobals@11.12.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjsesc@3.1.0(transitive)
+ Addedjson5@2.2.3(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-releases@2.0.19(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedsemver@6.3.1(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedyallist@3.1.1(transitive)
- Removedbabel-plugin-syntax-jsx@^6.18.0
- Removedbabel-plugin-transform-react-constant-elements@^6.23.0
- Removedbabel-preset-es2016@^6.22.0
- Removedbabel-preset-es2017@^6.22.0
- Removedbabel-preset-flow@^6.23.0
- Removedbabel-preset-stage-0@^6.22.0
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-bindify-decorators@6.24.1(transitive)
- Removedbabel-helper-builder-binary-assignment-operator-visitor@6.24.1(transitive)
- Removedbabel-helper-builder-react-jsx@6.26.0(transitive)
- Removedbabel-helper-explode-assignable-expression@6.24.1(transitive)
- Removedbabel-helper-explode-class@6.24.1(transitive)
- Removedbabel-helper-function-name@6.24.1(transitive)
- Removedbabel-helper-get-function-arity@6.24.1(transitive)
- Removedbabel-helper-mark-eval-scopes@0.1.1(transitive)
- Removedbabel-helper-remap-async-to-generator@6.24.1(transitive)
- Removedbabel-helper-remove-or-void@0.1.1(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-add-module-exports@0.2.1(transitive)
- Removedbabel-plugin-minify-dead-code-elimination@0.1.7(transitive)
- Removedbabel-plugin-syntax-async-functions@6.13.0(transitive)
- Removedbabel-plugin-syntax-async-generators@6.13.0(transitive)
- Removedbabel-plugin-syntax-class-constructor-call@6.18.0(transitive)
- Removedbabel-plugin-syntax-class-properties@6.13.0(transitive)
- Removedbabel-plugin-syntax-decorators@6.13.0(transitive)
- Removedbabel-plugin-syntax-do-expressions@6.13.0(transitive)
- Removedbabel-plugin-syntax-dynamic-import@6.18.0(transitive)
- Removedbabel-plugin-syntax-exponentiation-operator@6.13.0(transitive)
- Removedbabel-plugin-syntax-export-extensions@6.13.0(transitive)
- Removedbabel-plugin-syntax-flow@6.18.0(transitive)
- Removedbabel-plugin-syntax-function-bind@6.13.0(transitive)
- Removedbabel-plugin-syntax-jsx@6.18.0(transitive)
- Removedbabel-plugin-syntax-object-rest-spread@6.13.0(transitive)
- Removedbabel-plugin-syntax-trailing-function-commas@6.22.0(transitive)
- Removedbabel-plugin-transform-async-generator-functions@6.24.1(transitive)
- Removedbabel-plugin-transform-async-to-generator@6.24.1(transitive)
- Removedbabel-plugin-transform-class-constructor-call@6.24.1(transitive)
- Removedbabel-plugin-transform-class-properties@6.24.1(transitive)
- Removedbabel-plugin-transform-decorators@6.24.1(transitive)
- Removedbabel-plugin-transform-decorators-legacy@1.3.5(transitive)
- Removedbabel-plugin-transform-do-expressions@6.22.0(transitive)
- Removedbabel-plugin-transform-exponentiation-operator@6.24.1(transitive)
- Removedbabel-plugin-transform-export-extensions@6.22.0(transitive)
- Removedbabel-plugin-transform-flow-strip-types@6.22.0(transitive)
- Removedbabel-plugin-transform-function-bind@6.22.0(transitive)
- Removedbabel-plugin-transform-jsx-stylesheet@0.6.11(transitive)
- Removedbabel-plugin-transform-object-rest-spread@6.26.0(transitive)
- Removedbabel-plugin-transform-react-constant-elements@6.23.0(transitive)
- Removedbabel-plugin-transform-react-display-name@6.25.0(transitive)
- Removedbabel-plugin-transform-react-jsx@6.24.1(transitive)
- Removedbabel-plugin-transform-react-jsx-self@6.22.0(transitive)
- Removedbabel-plugin-transform-react-jsx-source@6.22.0(transitive)
- Removedbabel-preset-es2016@6.24.1(transitive)
- Removedbabel-preset-es2017@6.24.1(transitive)
- Removedbabel-preset-flow@6.23.0(transitive)
- Removedbabel-preset-stage-0@6.24.1(transitive)
- Removedbabel-preset-stage-1@6.24.1(transitive)
- Removedbabel-preset-stage-2@6.24.1(transitive)
- Removedbabel-preset-stage-3@6.24.1(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedcamelcase@3.0.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesutils@2.0.3(transitive)
- Removedglobals@9.18.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.some@4.6.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedms@2.0.0(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)