@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 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
@@ -152,8 +152,39 @@ syntax errors during transpilation.
152
152
  const { order, setOrder } = useGlobalStore.pick();
153
153
  ```
154
154
 
155
- 4. You might also encounter errors if some other plugin transforms the code
156
- before babel-plugin-neeto. If your syntax is correct, and you are still
157
- getting errors, check for other babel-plugins or babel-presets transforming
158
- your code before we do. **babel-plugin-neeto expects that it runs first on
159
- the code before any other plugin performs transformations.**
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/babel-preset-neeto",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A babel preset to transform short code to boilerplate at compile time",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -44,7 +44,6 @@ const PICK_GENERIC_PATTERN = {
44
44
 
45
45
  const PICK_STRICT_PATTERN = {
46
46
  type: "VariableDeclaration",
47
- kind: "const",
48
47
  declarations: matchesWithLength([
49
48
  mergeDeepLeft(
50
49
  {