Comparing version 1.0.3 to 1.1.0
@@ -0,1 +1,12 @@ | ||
# [1.1.0](https://github.com/jquense/jarle/compare/v1.0.3...v1.1.0) (2021-01-22) | ||
### Features | ||
* allow component returns and export default ([1000f48](https://github.com/jquense/jarle/commit/1000f48271f0a9424c9e00b27323b5a89e99de42)) | ||
## [1.0.3](https://github.com/jquense/jarle/compare/v1.0.2...v1.0.3) (2021-01-12) | ||
@@ -2,0 +13,0 @@ |
@@ -16,2 +16,4 @@ "use strict"; | ||
var _reactIs = require("react-is"); | ||
var _sourcemapCodec = require("sourcemap-codec"); | ||
@@ -150,2 +152,10 @@ | ||
if (! /*#__PURE__*/(0, _react.isValidElement)(element)) { | ||
if ((0, _reactIs.isValidElementType)(element)) { | ||
element = /*#__PURE__*/(0, _react.createElement)(element); | ||
} else { | ||
reject(new SyntaxError('The code did not return a valid React element or element type')); | ||
} | ||
} | ||
resolve(element); | ||
@@ -152,0 +162,0 @@ }); |
@@ -12,8 +12,22 @@ "use strict"; | ||
leave(node) { | ||
if (node.body.find(n => n.type === 'ReturnStatement')) { | ||
return; | ||
const body = node.body.concat().reverse(); | ||
let lastExpr; | ||
for (const _node of body) { | ||
switch (_node.type) { | ||
case 'ExpressionStatement': | ||
case 'ClassDeclaration': | ||
case 'FunctionDeclaration': | ||
lastExpr = lastExpr || _node; | ||
break; | ||
case 'ReturnStatement': | ||
return; | ||
case 'ExportDefaultDeclaration': | ||
this.overwrite(_node.start, _node.declaration.start, ''); | ||
lastExpr = _node.declaration; | ||
} | ||
} | ||
const lastExpr = node.body.concat().reverse().find(n => n.type === 'ExpressionStatement' || n.type === 'ClassDeclaration' || n.type === 'FunctionDeclaration'); | ||
if (!lastExpr) { | ||
@@ -20,0 +34,0 @@ return; |
@@ -16,2 +16,4 @@ "use strict"; | ||
var _reactIs = require("react-is"); | ||
var _sourcemapCodec = require("sourcemap-codec"); | ||
@@ -150,2 +152,10 @@ | ||
if (! /*#__PURE__*/(0, _react.isValidElement)(element)) { | ||
if ((0, _reactIs.isValidElementType)(element)) { | ||
element = /*#__PURE__*/(0, _react.createElement)(element); | ||
} else { | ||
reject(new SyntaxError('The code did not return a valid React element or element type')); | ||
} | ||
} | ||
resolve(element); | ||
@@ -152,0 +162,0 @@ }); |
@@ -12,8 +12,22 @@ "use strict"; | ||
leave(node) { | ||
if (node.body.find(n => n.type === 'ReturnStatement')) { | ||
return; | ||
const body = node.body.concat().reverse(); | ||
let lastExpr; | ||
for (const _node of body) { | ||
switch (_node.type) { | ||
case 'ExpressionStatement': | ||
case 'ClassDeclaration': | ||
case 'FunctionDeclaration': | ||
lastExpr = lastExpr || _node; | ||
break; | ||
case 'ReturnStatement': | ||
return; | ||
case 'ExportDefaultDeclaration': | ||
this.overwrite(_node.start, _node.declaration.start, ''); | ||
lastExpr = _node.declaration; | ||
} | ||
} | ||
const lastExpr = node.body.concat().reverse().find(n => n.type === 'ExpressionStatement' || n.type === 'ClassDeclaration' || n.type === 'FunctionDeclaration'); | ||
if (!lastExpr) { | ||
@@ -20,0 +34,0 @@ return; |
{ | ||
"name": "jarle", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"main": "lib/index.js", | ||
@@ -65,2 +65,3 @@ "module": "esm/index.js", | ||
"@types/react-dom": "^16.9.7", | ||
"@types/react-is": "^17.0.0", | ||
"acorn": "^8.0.1", | ||
@@ -72,2 +73,3 @@ "acorn-jsx": "^5.2.0", | ||
"prop-types": "^15.7.2", | ||
"react-is": "^17.0.1", | ||
"react-simple-code-editor": "^0.11.0", | ||
@@ -74,0 +76,0 @@ "sourcemap-codec": "^1.4.8" |
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
170584
4980
17
+ Added@types/react-is@^17.0.0
+ Addedreact-is@^17.0.1
+ Added@types/react@17.0.83(transitive)
+ Added@types/react-is@17.0.7(transitive)
+ Addedreact-is@17.0.2(transitive)