babel-plugin-minibum-jsx 1.1.0 → 1.1.2
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 +16 -0
- package/package.json +2 -2
- package/src/index.js +8 -1
package/README
CHANGED
|
@@ -7,3 +7,19 @@ runtime calls required to create and compose UI components.
|
|
|
7
7
|
|
|
8
8
|
The plugin is intended to keep component markup concise while fitting into a
|
|
9
9
|
small, fast build pipeline.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the Babel plugin with npm:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install --save-dev babel-plugin-minibum-jsx
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then add `minibum-jsx` to the `plugins` array in your Babel configuration:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"plugins": ["minibum-jsx"]
|
|
24
|
+
}
|
|
25
|
+
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-minibum-jsx",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Minibum JSX is a lightweight JSX plugin for the Minibum ecosystem. It enables\nJSX syntax in application source files and transforms JSX elements into the\nruntime calls required to create and compose UI components.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"exports": {
|
package/src/index.js
CHANGED
|
@@ -66,7 +66,14 @@ export default function minibumJsx({ types: t }) {
|
|
|
66
66
|
|
|
67
67
|
function convertChild(child) {
|
|
68
68
|
if (t.isJSXText(child)) {
|
|
69
|
-
const
|
|
69
|
+
const value = child.value.replace(/\r\n?/g, "\n");
|
|
70
|
+
const text = value.includes("\n")
|
|
71
|
+
? value
|
|
72
|
+
.split("\n")
|
|
73
|
+
.map((line) => line.trim())
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.join(" ")
|
|
76
|
+
: value.replace(/[ \t]+/g, " ");
|
|
70
77
|
return text ? t.stringLiteral(text) : null;
|
|
71
78
|
}
|
|
72
79
|
if (t.isJSXExpressionContainer(child)) {
|