Skip to content

Commit

Permalink
chore: realar vendor added again
Browse files Browse the repository at this point in the history
  • Loading branch information
betula committed Jul 9, 2022
1 parent 7a99d1d commit 3f49f66
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 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 [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

Expand Down Expand Up @@ -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
}]
]
};
Expand Down Expand Up @@ -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
}]
]
};
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/view-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => <h1 />`;
const expected = `const a = require("realar").observe(p => <h1 />);`;
expect(transform(code, { decorator: 'realar' })).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 3f49f66

Please sign in to comment.