@bigbinary/babel-preset-neeto 1.0.2 → 1.0.3
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/README.md +2 -0
- package/docs/zustand-pick.md +36 -5
- package/package.json +1 -1
- package/src/plugins/zustand-pick/constants.js +0 -1
package/README.md
CHANGED
|
@@ -69,3 +69,5 @@ A babel transformer to minimize boilerplate code in neeto products.
|
|
|
69
69
|
|
|
70
70
|
- Learning material:
|
|
71
71
|
https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md
|
|
72
|
+
- Some important points to note while integrating babel-preset to host projects:
|
|
73
|
+
https://youtu.be/zZfIIObnj_Q
|
package/docs/zustand-pick.md
CHANGED
|
@@ -152,8 +152,39 @@ syntax errors during transpilation.
|
|
|
152
152
|
const { order, setOrder } = useGlobalStore.pick();
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
## Notes
|
|
156
|
+
|
|
157
|
+
#### All nested property access are optional chained
|
|
158
|
+
|
|
159
|
+
No need to worry if any of the properties in your store nesting may be
|
|
160
|
+
null/undefined. This transformer adds optional chaining in all levels of
|
|
161
|
+
nesting. That is:
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
const { order, customer } = useGlobalStore.pick([sessionId, "globals"]);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Will be transformed to:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
import { shallow } from "zustand/shallow";
|
|
171
|
+
const { order, customer } = useGlobalStore(
|
|
172
|
+
store => ({
|
|
173
|
+
order: store[sessionId]?.["globals"]?.["order"],
|
|
174
|
+
customer: store[sessionId]?.["globals"]?.["customer"],
|
|
175
|
+
}),
|
|
176
|
+
shallow
|
|
177
|
+
);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
So your code won't fail if `store[sessionId]` is null or
|
|
181
|
+
`store[sessionId].globals` is null.
|
|
182
|
+
|
|
183
|
+
#### This plugin should run on user's code
|
|
184
|
+
|
|
185
|
+
You might encounter errors if some other plugin transforms the code before
|
|
186
|
+
babel-plugin-neeto. **babel-plugin-neeto expects that it runs first on the code
|
|
187
|
+
before any other plugin performs transformations.**
|
|
188
|
+
|
|
189
|
+
If your zustand-pick syntax is correct, and you are still getting errors, check
|
|
190
|
+
for other babel-plugins or babel-presets transforming your code before we do.
|
package/package.json
CHANGED