You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 1, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,27 @@ This repository is inspired by [this article](https://v8.dev/blog/cost-of-javasc
9
9
10
10
> As long as the JSON string is only evaluated once, the JSON.parse approach is much faster compared to the JavaScript object literal, especially for cold loads.
11
11
12
-
**Caution!!** : I made this plugin for my understanding about AST and babel plugin, so this plugin is not production ready.
12
+
## Caution!!
13
+
### this plugin may not be production ready
14
+
I just made this plugin for my understanding about AST and babel plugin.
15
+
16
+
### this plugin doesn't support partially JSON expression
17
+
18
+
I decided not to support partially JSON expression like below.
19
+
20
+
> Partially JSON expressions such as [notValid, {isValid:true}] ensuring {isValid:true} is transformed.
21
+
22
+
```
23
+
const data = { bar: invalid_object, foo: 'foo' }
24
+
↓
25
+
const data = { bar: invalid_object, JSON.parse('{"foo": "foo"}')}
26
+
```
27
+
28
+
This is because I think most large objects are not partially JSON expressions. **JSON.parse() is much faster in the case that object is 10 kB or larger. Converting small object to JSON.parse expression is not meaningful.**
29
+
30
+
### this plugin produces output that only works in modern environments (e.g. Node.js v10+)
31
+
32
+
I don't care about some backwards compatibilities like [this issues](https://github.com/nd-02110114/babel-plugin-object-to-json-parse/issues/12).
0 commit comments