@babel/plugin-transform-react-jsx
Advanced tools
Comparing version 7.0.0-beta.46 to 7.0.0-beta.47
@@ -9,3 +9,3 @@ "use strict"; | ||
function _helperPluginUtils() { | ||
var data = require("@babel/helper-plugin-utils"); | ||
const data = require("@babel/helper-plugin-utils"); | ||
@@ -20,3 +20,3 @@ _helperPluginUtils = function _helperPluginUtils() { | ||
function _pluginSyntaxJsx() { | ||
var data = _interopRequireDefault(require("@babel/plugin-syntax-jsx")); | ||
const data = _interopRequireDefault(require("@babel/plugin-syntax-jsx")); | ||
@@ -31,3 +31,3 @@ _pluginSyntaxJsx = function _pluginSyntaxJsx() { | ||
function _helperBuilderReactJsx() { | ||
var data = _interopRequireDefault(require("@babel/helper-builder-react-jsx")); | ||
const data = _interopRequireDefault(require("@babel/helper-builder-react-jsx")); | ||
@@ -42,3 +42,3 @@ _helperBuilderReactJsx = function _helperBuilderReactJsx() { | ||
function _core() { | ||
var data = require("@babel/core"); | ||
const data = require("@babel/core"); | ||
@@ -54,24 +54,18 @@ _core = function _core() { | ||
var _default = (0, _helperPluginUtils().declare)(function (api, options) { | ||
var _default = (0, _helperPluginUtils().declare)((api, options) => { | ||
api.assertVersion(7); | ||
var THROW_IF_NAMESPACE = options.throwIfNamespace === undefined ? true : !!options.throwIfNamespace; | ||
var PRAGMA_DEFAULT = options.pragma || "React.createElement"; | ||
var PRAGMA_FRAG_DEFAULT = options.pragmaFrag || "React.Fragment"; | ||
var JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/; | ||
var JSX_FRAG_ANNOTATION_REGEX = /\*?\s*@jsxFrag\s+([^\s]+)/; | ||
const THROW_IF_NAMESPACE = options.throwIfNamespace === undefined ? true : !!options.throwIfNamespace; | ||
const PRAGMA_DEFAULT = options.pragma || "React.createElement"; | ||
const PRAGMA_FRAG_DEFAULT = options.pragmaFrag || "React.Fragment"; | ||
const JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/; | ||
const JSX_FRAG_ANNOTATION_REGEX = /\*?\s*@jsxFrag\s+([^\s]+)/; | ||
var createIdentifierParser = function createIdentifierParser(id) { | ||
return function () { | ||
return id.split(".").map(function (name) { | ||
return _core().types.identifier(name); | ||
}).reduce(function (object, property) { | ||
return _core().types.memberExpression(object, property); | ||
}); | ||
}; | ||
const createIdentifierParser = id => () => { | ||
return id.split(".").map(name => _core().types.identifier(name)).reduce((object, property) => _core().types.memberExpression(object, property)); | ||
}; | ||
var visitor = (0, _helperBuilderReactJsx().default)({ | ||
pre: function pre(state) { | ||
var tagName = state.tagName; | ||
var args = state.args; | ||
const visitor = (0, _helperBuilderReactJsx().default)({ | ||
pre(state) { | ||
const tagName = state.tagName; | ||
const args = state.args; | ||
@@ -84,19 +78,21 @@ if (_core().types.react.isCompatTag(tagName)) { | ||
}, | ||
post: function post(state, pass) { | ||
post(state, pass) { | ||
state.callee = pass.get("jsxIdentifier")(); | ||
}, | ||
throwIfNamespace: THROW_IF_NAMESPACE | ||
}); | ||
visitor.Program = { | ||
enter: function enter(path, state) { | ||
var file = state.file; | ||
var pragma = PRAGMA_DEFAULT; | ||
var pragmaFrag = PRAGMA_FRAG_DEFAULT; | ||
var pragmaSet = !!options.pragma; | ||
var pragmaFragSet = !!options.pragmaFrag; | ||
enter(path, state) { | ||
const file = state.file; | ||
let pragma = PRAGMA_DEFAULT; | ||
let pragmaFrag = PRAGMA_FRAG_DEFAULT; | ||
let pragmaSet = !!options.pragma; | ||
let pragmaFragSet = !!options.pragmaFrag; | ||
var _arr = file.ast.comments; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var comment = _arr[_i]; | ||
var jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value); | ||
const comment = _arr[_i]; | ||
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value); | ||
@@ -108,3 +104,3 @@ if (jsxMatches) { | ||
var jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value); | ||
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value); | ||
@@ -123,3 +119,4 @@ if (jsxFragMatches) { | ||
}, | ||
exit: function exit(path, state) { | ||
exit(path, state) { | ||
if (state.get("pragmaSet") && state.get("usedFragment") && !state.get("pragmaFragSet")) { | ||
@@ -129,2 +126,3 @@ throw new Error("transform-react-jsx: pragma has been set but " + "pragmafrag has not been set"); | ||
} | ||
}; | ||
@@ -140,3 +138,3 @@ | ||
inherits: _pluginSyntaxJsx().default, | ||
visitor: visitor | ||
visitor | ||
}; | ||
@@ -143,0 +141,0 @@ }); |
{ | ||
"name": "@babel/plugin-transform-react-jsx", | ||
"version": "7.0.0-beta.46", | ||
"version": "7.0.0-beta.47", | ||
"description": "Turn JSX into React function calls", | ||
@@ -12,13 +12,13 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx", | ||
"dependencies": { | ||
"@babel/helper-builder-react-jsx": "7.0.0-beta.46", | ||
"@babel/helper-plugin-utils": "7.0.0-beta.46", | ||
"@babel/plugin-syntax-jsx": "7.0.0-beta.46" | ||
"@babel/helper-builder-react-jsx": "7.0.0-beta.47", | ||
"@babel/helper-plugin-utils": "7.0.0-beta.47", | ||
"@babel/plugin-syntax-jsx": "7.0.0-beta.47" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.46" | ||
"@babel/core": "7.0.0-beta.47" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.46", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.46" | ||
"@babel/core": "7.0.0-beta.47", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.47" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
7780
102
+ Added@babel/code-frame@7.0.0-beta.47(transitive)
+ Added@babel/core@7.0.0-beta.47(transitive)
+ Added@babel/generator@7.0.0-beta.47(transitive)
+ Added@babel/helper-builder-react-jsx@7.0.0-beta.47(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.47(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.47(transitive)
+ Added@babel/helper-plugin-utils@7.0.0-beta.47(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.47(transitive)
+ Added@babel/helpers@7.0.0-beta.47(transitive)
+ Added@babel/highlight@7.0.0-beta.47(transitive)
+ Added@babel/plugin-syntax-jsx@7.0.0-beta.47(transitive)
+ Added@babel/template@7.0.0-beta.47(transitive)
+ Added@babel/traverse@7.0.0-beta.47(transitive)
+ Added@babel/types@7.0.0-beta.47(transitive)
+ Addedbabylon@7.0.0-beta.47(transitive)
- Removed@babel/code-frame@7.0.0-beta.46(transitive)
- Removed@babel/core@7.0.0-beta.46(transitive)
- Removed@babel/generator@7.0.0-beta.46(transitive)
- Removed@babel/helper-builder-react-jsx@7.0.0-beta.46(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.46(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.46(transitive)
- Removed@babel/helper-plugin-utils@7.0.0-beta.46(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.46(transitive)
- Removed@babel/helpers@7.0.0-beta.46(transitive)
- Removed@babel/highlight@7.0.0-beta.46(transitive)
- Removed@babel/plugin-syntax-jsx@7.0.0-beta.46(transitive)
- Removed@babel/template@7.0.0-beta.46(transitive)
- Removed@babel/traverse@7.0.0-beta.46(transitive)
- Removed@babel/types@7.0.0-beta.46(transitive)
- Removedbabylon@7.0.0-beta.46(transitive)