babel-plugin-realar
Advanced tools
Comparing version 0.2.3 to 0.2.4
{ | ||
"name": "babel-plugin-realar", | ||
"description": "Automatic observe jsx arrow functions for Realar", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"main": "./src/plugin.js", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -13,3 +13,3 @@ const { is_allowed } = require('./is-allowed'); | ||
if (is_allowed(state)) { | ||
view_transform(path, (state.opts || {}).decorator); | ||
view_transform(path, state.opts); | ||
} | ||
@@ -16,0 +16,0 @@ }, |
const { types, template, traverse } = require('@babel/core'); | ||
const default_decorator_fn_name = 'require("realar").observe'; | ||
module.exports = { | ||
default_decorator_fn_name, | ||
view_transform, | ||
}; | ||
function view_transform(path, decorator_fn_name = default_decorator_fn_name) { | ||
function view_transform(path, opts = {}) { | ||
let cursor = path; | ||
@@ -81,3 +78,8 @@ let cursor_path; | ||
const decorated = template(`${decorator_fn_name}(BODY)`)({ | ||
let tpl = `${opts.decorator || 'require("realar").observe'}(BODY)`; | ||
if ((!opts.decorator && opts.memo !== false) || opts.memo === true) { | ||
tpl = `require("react").memo(${tpl})`; | ||
} | ||
const decorated = template(tpl)({ | ||
BODY: cursor, | ||
@@ -84,0 +86,0 @@ }); |
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
6570
138