From 3f49f661e398b6673bdddacf4f5980e7365db718 Mon Sep 17 00:00:00 2001 From: Slava Bereza Date: Sat, 9 Jul 2022 14:51:05 +0700 Subject: [PATCH] chore: realar vendor added again --- README.md | 8 ++++---- src/view-transform.js | 3 +++ tests/options.test.js | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d24c58b..6b40941 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Automatic observe jsx arrow functions for smartify and purify your code :+1: -That plugin for babel wraps all not wrapped arrow functions (that contains JSX and defined in file global scope) to wrapper function with easy configuring [Mobx](https://github.com/mobxjs/mobx) and [Remini](https://github.com/betula/remini) (_but possible for configure to custom one_). Less code more effectiveness! +That plugin for babel wraps all not wrapped arrow functions (that contains JSX and defined in file global scope) to wrapper function with easy configuring [Mobx](https://github.com/mobxjs/mobx), [Realar](https://github.com/betula/realar) and [Remini](https://github.com/betula/remini) (_but possible for configure to custom one_). Less code more effectiveness! ### Mobx @@ -40,7 +40,7 @@ const App = () => ( module.exports = { "plugins": [ ["jsx-wrapper", { - "decorator": "mobx-react-lite" // "mobx-react", "remini-react", "remini-preact" or some custom + "decorator": "mobx-react-lite" // "mobx-react", "remini-react", "remini-preact", "realar", or some custom }] ] }; @@ -79,7 +79,7 @@ You are no need more to wrap (decorate) JSX components to `observe` function! It module.exports = { "plugins": [ ["jsx-wrapper", { - "decorator": "remini-react" // "remini-preact", "mobx-react", "mobx-react-lite" or some custom + "decorator": "remini-react" // "remini-preact", "realar", "mobx-react", "mobx-react-lite", or some custom }] ] }; @@ -112,7 +112,7 @@ module.exports = { **memo** - boolean flag. Wrap all arrow function React component to `React.memo`. `false` by default. -**decorator** - function name that using to wrapping jsx arrow function component. (_For example: "require('mobx-preact').observer"_) Or name of presetted vendor: "remini-react", "remini-preact", "mobx-react", and "mobx-react-lite". +**decorator** - function name that using to wrapping jsx arrow function component. (_For example: "require('mobx-preact').observer"_) Or name of presetted vendor: "remini-react", "remini-preact", "realar", "mobx-react", and "mobx-react-lite". ### Install diff --git a/src/view-transform.js b/src/view-transform.js index 462ce3b..d51604c 100644 --- a/src/view-transform.js +++ b/src/view-transform.js @@ -108,6 +108,9 @@ function view_transform(path, opts = {}) { case 'remini-preact': decor = 'require("remini/preact").observe'; break; + case 'realar': + decor = 'require("realar").observe'; + break; default: decor = opts.decorator || decor; } diff --git a/tests/options.test.js b/tests/options.test.js index 3bea434..0664c5f 100644 --- a/tests/options.test.js +++ b/tests/options.test.js @@ -64,6 +64,12 @@ test('should work remini/preact decorator option', () => { expect(transform(code, { decorator: 'remini-preact' })).toBe(expected); }); +test('should work realar decorator option', () => { + const code = `const a = (p) =>

`; + const expected = `const a = require("realar").observe(p =>

);`; + expect(transform(code, { decorator: 'realar' })).toBe(expected); +}); + test('should work include option', () => { const code = `const a = p =>

;`; const decorated = `const a = k(p =>

);`;