@bigbinary/babel-preset-neeto 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +1 -1
- package/.neetoci/default.yml +1 -1
- package/.node-version +1 -1
- package/.nvmrc +1 -1
- package/.semaphore/semaphore.yml +1 -1
- package/docs/zustand-pick.md +9 -11
- package/package.json +1 -1
- package/src/plugins/zustand-pick/index.js +9 -8
- package/src/tests/zustand-pick/transformations/array-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/default-value/output.js +3 -4
- package/src/tests/zustand-pick/transformations/dynamic-declare/output.js +5 -7
- package/src/tests/zustand-pick/transformations/dynamic-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/empty-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/no-duplicate-import/input.js +1 -1
- package/src/tests/zustand-pick/transformations/no-duplicate-import/output.js +3 -4
- package/src/tests/zustand-pick/transformations/string-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/use-store-pick/output.js +3 -4
- package/src/tests/zustand-pick/transformations/with-other-imports/output.js +3 -4
- package/.github/CODEOWNERS +0 -1
package/.neetoci/default.yml
CHANGED
package/.node-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
22.13
|
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
22.13
|
package/.semaphore/semaphore.yml
CHANGED
package/docs/zustand-pick.md
CHANGED
|
@@ -6,14 +6,13 @@ When we wanted to pick some properties from a zustand store, this is what we
|
|
|
6
6
|
need to do:
|
|
7
7
|
|
|
8
8
|
```js
|
|
9
|
-
import {
|
|
9
|
+
import { useShallow } from "zustand/shallow";
|
|
10
10
|
|
|
11
11
|
const { order, customer } = useGlobalStore(
|
|
12
|
-
store => ({
|
|
12
|
+
useShallow(store => ({
|
|
13
13
|
order: store[sessionId]?.globals.order,
|
|
14
14
|
customer: store[sessionId]?.globals.customer,
|
|
15
|
-
})
|
|
16
|
-
shallow
|
|
15
|
+
}))
|
|
17
16
|
);
|
|
18
17
|
```
|
|
19
18
|
|
|
@@ -30,14 +29,14 @@ const { order, customer } = useGlobalStore.pick([sessionId, "globals"]);
|
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
You might also notice that we don't have the
|
|
33
|
-
`import {
|
|
34
|
-
don't need that. The plugin will automatically add it for us at the time of
|
|
32
|
+
`import { useShallow } from "zustand/shallow"` statement in this piece of code.
|
|
33
|
+
We don't need that. The plugin will automatically add it for us at the time of
|
|
35
34
|
transpiling.
|
|
36
35
|
|
|
37
36
|
The plugin detects that `order` and `customer` properties are to be fetched from
|
|
38
37
|
the `store[sessionId].globals` property from `useGlobalStore` and it generates
|
|
39
38
|
code for it. Note that the plugin will automatically add
|
|
40
|
-
`import {
|
|
39
|
+
`import { useShallow } from "zustand/shallow"` for us. We don't need to add it
|
|
41
40
|
ourselves.
|
|
42
41
|
|
|
43
42
|
## Allowed syntaxes
|
|
@@ -170,13 +169,12 @@ const { order, customer } = useGlobalStore.pick([sessionId, "globals"]);
|
|
|
170
169
|
Will be transformed to:
|
|
171
170
|
|
|
172
171
|
```js
|
|
173
|
-
import {
|
|
172
|
+
import { useShallow } from "zustand/shallow";
|
|
174
173
|
const { order, customer } = useGlobalStore(
|
|
175
|
-
store => ({
|
|
174
|
+
useShallow(store => ({
|
|
176
175
|
order: store[sessionId]?.["globals"]?.["order"],
|
|
177
176
|
customer: store[sessionId]?.["globals"]?.["customer"],
|
|
178
|
-
})
|
|
179
|
-
shallow
|
|
177
|
+
}))
|
|
180
178
|
);
|
|
181
179
|
```
|
|
182
180
|
|
package/package.json
CHANGED
|
@@ -62,13 +62,14 @@ module.exports = function ({ types }) {
|
|
|
62
62
|
declarator.init = types.callExpression(
|
|
63
63
|
types.identifier(declarator.init.callee.object.name),
|
|
64
64
|
[
|
|
65
|
-
types.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
types.callExpression(types.identifier("useShallow"), [
|
|
66
|
+
types.arrowFunctionExpression(
|
|
67
|
+
[types.identifier("store")],
|
|
68
|
+
types.objectExpression(
|
|
69
|
+
declarator.id.properties.map(toObjectProperty)
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
]),
|
|
72
73
|
]
|
|
73
74
|
);
|
|
74
75
|
|
|
@@ -76,7 +77,7 @@ module.exports = function ({ types }) {
|
|
|
76
77
|
path: astPath,
|
|
77
78
|
types,
|
|
78
79
|
source: "zustand/shallow",
|
|
79
|
-
importName: "
|
|
80
|
+
importName: "useShallow",
|
|
80
81
|
});
|
|
81
82
|
},
|
|
82
83
|
CallExpression(astPath) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { order, customer } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
order: store["state"]?.[sessionId]?.["current"]?.[data]?.["order"],
|
|
5
5
|
customer: store["state"]?.[sessionId]?.["current"]?.[data]?.["customer"],
|
|
6
|
-
})
|
|
7
|
-
shallow
|
|
6
|
+
}))
|
|
8
7
|
);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { orderId = "#1001", customer = {} } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
orderId: store["orderId"],
|
|
5
5
|
customer: store["customer"],
|
|
6
|
-
})
|
|
7
|
-
shallow
|
|
6
|
+
}))
|
|
8
7
|
);
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { [`customer ${id}`]: customer } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
[`customer ${id}`]: store[sessionId]?.[`customer ${id}`],
|
|
5
|
-
})
|
|
6
|
-
shallow
|
|
5
|
+
}))
|
|
7
6
|
);
|
|
8
7
|
const { [orderId]: order } = useGlobalStore(
|
|
9
|
-
store => ({
|
|
8
|
+
useShallow(store => ({
|
|
10
9
|
[orderId]: store[sessionId]?.["orders"]?.[orderId],
|
|
11
|
-
})
|
|
12
|
-
shallow
|
|
10
|
+
}))
|
|
13
11
|
);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { order, customer } = useGlobalStore.pick();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
const { order, customer, address } = useGlobalStore(
|
|
3
|
-
store => ({
|
|
3
|
+
useShallow(store => ({
|
|
4
4
|
order: store["state"]?.["order"],
|
|
5
5
|
customer: store["state"]?.["customer"],
|
|
6
6
|
address: store["state"]?.["address"],
|
|
7
|
-
})
|
|
8
|
-
shallow
|
|
7
|
+
}))
|
|
9
8
|
);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useShallow } from "zustand/shallow";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { sample } from "somewhere";
|
|
4
4
|
const { order, customer } = useGlobalStore(
|
|
5
|
-
store => ({
|
|
5
|
+
useShallow(store => ({
|
|
6
6
|
order: store["order"],
|
|
7
7
|
customer: store["customer"],
|
|
8
|
-
})
|
|
9
|
-
shallow
|
|
8
|
+
}))
|
|
10
9
|
);
|
package/.github/CODEOWNERS
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
* @Amaljith-K
|