Skip to content

Commit

Permalink
feat: remini bindings updated
Browse files Browse the repository at this point in the history
  • Loading branch information
betula committed Jun 19, 2022
1 parent 102fb5f commit e31b7aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [Realar](https://github.com/betula/realar) (_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

Expand Down Expand Up @@ -41,7 +41,7 @@ const App = () => (
module.exports = {
"plugins": [
["jsx-wrapper", {
"decorator": "mobx" // or possible value "mobx-lite", "remini", by default "realar"
"decorator": "mobx" // or possible value "mobx-lite", "remini-react", "remini-preact", by default "realar"
}]
]
};
Expand Down Expand Up @@ -113,7 +113,7 @@ module.exports = {

**memo** - boolean flag. Wrap all arrow function React component to `React.memo`. `false` by default.

**decorator** - function name that used instead of `observe` function from Realar. (_For example: "require('mobx-preact').observer"_) Or name of presetted vendor: "mobx", "mobx-lite", "remini", and "realar" (by default).
**decorator** - function name that used instead of `observe` function from Realar. (_For example: "require('mobx-preact').observer"_) Or name of presetted vendor: "mobx", "mobx-lite", "remini-react", "remini-preact", and "realar" (by default).


### Install
Expand All @@ -131,7 +131,7 @@ And update your babel config:
{
"plugins": [
["jsx-wrapper", {
"decorator": "mobx" // or "remini", by default "realar"
"decorator": "mobx" // or "remini-react", "remini-preact", by default "realar"
}]
]
}
Expand Down
6 changes: 5 additions & 1 deletion src/view-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,12 @@ function view_transform(path, opts = {}) {
case 'mobx-lite':
decor = 'require("mobx-react-lite").observer';
break;
case 'remini-react':
case 'remini':
decor = 'require("remini").observe';
decor = 'require("remini/react").observe';
break;
case 'remini-preact':
decor = 'require("remini/preact").observe';
break;
case 'realar':
break;
Expand Down
14 changes: 13 additions & 1 deletion tests/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ test('should work realar decorator option', () => {

test('should work remini decorator option', () => {
const code = `const a = (p) => <h1 />`;
const expected = `const a = require("remini").observe(p => <h1 />);`;
const expected = `const a = require("remini/react").observe(p => <h1 />);`;
expect(transform(code, { decorator: 'remini' })).toBe(expected);
});

test('should work remini/react decorator option', () => {
const code = `const a = (p) => <h1 />`;
const expected = `const a = require("remini/react").observe(p => <h1 />);`;
expect(transform(code, { decorator: 'remini-react' })).toBe(expected);
});

test('should work remini/preact decorator option', () => {
const code = `const a = (p) => <h1 />`;
const expected = `const a = require("remini/preact").observe(p => <h1 />);`;
expect(transform(code, { decorator: 'remini-preact' })).toBe(expected);
});

test('should work include option', () => {
const code = `const a = p => <h1 />;`;
const decorated = `const a = k(p => <h1 />);`;
Expand Down

0 comments on commit e31b7aa

Please sign in to comment.