11"use strict" ;
22
3- const t = require ( "babel-core" ) . types ;
3+ const t = require ( "@babel/core" ) . types ;
4+ const declare = require ( "@babel/helper-plugin-utils" ) . declare ;
45const getTagAndClassNamesAndId = require ( "./utils" ) . getTagAndClassNamesAndId ;
56const revTransform = require ( "./rev" ) ;
67const getOption = require ( "./utils" ) . getOption ;
@@ -26,7 +27,7 @@ const bJsxAttr = (prop, expressionOrValue) => {
2627const bJsxAttributes = objectExpression => {
2728 return objectExpression . properties . map ( node => {
2829 const { key, value, argument } = node ;
29- if ( t . isSpreadProperty ( node ) || t . isSpreadElement ( node ) ) {
30+ if ( t . isSpreadElement ( node ) || t . isSpreadElement ( node ) ) {
3031 return t . JSXSpreadAttribute ( argument ) ;
3132 } else if ( t . isProperty ( node ) && node . computed && ! t . isStringLiteral ( key ) ) {
3233 // to handle h(Abc, { [kek]: 0, ["norm"]: 1 }) to <Abc {...{ [kek]: 0 }} norm={1} />
@@ -128,7 +129,7 @@ const transformHyperscriptToJsx = (node, isTopLevelCall) => {
128129 ? convertToStringLiteral ( intermediateFirstArg )
129130 : intermediateFirstArg ;
130131 const isFirstArgIsConditionalExpression =
131- firstArgument . type === "ConditionalExpression"
132+ firstArgument . type === "ConditionalExpression" ;
132133
133134 // If firstArg is computed should be ignored, but inside the JSX should be wrapped into JSXExprContainer
134135 if (
@@ -212,12 +213,13 @@ const threeArgumentsCase = (firstArg, secondArg, thirdArg) => {
212213} ;
213214
214215let isCssModules = false ;
215- module . exports = function ( ) {
216+ module . exports = declare ( api => {
216217 return {
218+ name : "hyperscript-to-jsx" ,
217219 manipulateOptions ( opts , parserOpts ) {
218220 parserOpts . plugins . push ( "asyncGenerators" ) ;
219221 parserOpts . plugins . push ( "classProperties" ) ;
220- parserOpts . plugins . push ( "decorators" ) ;
222+ parserOpts . plugins . push ( "decorators-legacy " ) ;
221223 parserOpts . plugins . push ( "doExpressions" ) ;
222224 parserOpts . plugins . push ( "dynamicImport" ) ;
223225 parserOpts . plugins . push ( "flow" ) ;
@@ -324,4 +326,4 @@ module.exports = function() {
324326 }
325327 }
326328 } ;
327- } ;
329+ } ) ;
0 commit comments