@expo/html-elements 0.4.1 → 0.4.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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/babel/__tests__/transform.test.js +33 -0
- package/babel.js +17 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.4.3 — 2023-05-08
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Prevent babel plugin from running on node_modules. ([#21594](https://github.com/expo/expo/pull/21594) by [@EvanBacon](https://github.com/EvanBacon))
|
|
18
|
+
- Prevent babel plugin from transforming `html` and `body` on web. ([#21594](https://github.com/expo/expo/pull/21594) by [@EvanBacon](https://github.com/EvanBacon))
|
|
19
|
+
|
|
13
20
|
## 0.4.1 — 2023-02-09
|
|
14
21
|
|
|
15
22
|
### 🎉 New features
|
package/README.md
CHANGED
|
@@ -15,6 +15,10 @@ const options = {
|
|
|
15
15
|
},
|
|
16
16
|
],
|
|
17
17
|
],
|
|
18
|
+
caller: {
|
|
19
|
+
name: 'metro',
|
|
20
|
+
platform: 'ios',
|
|
21
|
+
},
|
|
18
22
|
minified: false,
|
|
19
23
|
plugins: [plugin],
|
|
20
24
|
compact: false,
|
|
@@ -36,6 +40,35 @@ function App() {
|
|
|
36
40
|
expect(code).not.toMatch(`@expo/html-elements`);
|
|
37
41
|
});
|
|
38
42
|
|
|
43
|
+
it(`Skips html and body on web`, () => {
|
|
44
|
+
const sourceCode = `
|
|
45
|
+
function App() {
|
|
46
|
+
return <html><body>Test</body></html>;
|
|
47
|
+
}`;
|
|
48
|
+
const { code } = babel.transform(sourceCode, {
|
|
49
|
+
...options,
|
|
50
|
+
caller: {
|
|
51
|
+
...options.caller,
|
|
52
|
+
platform: 'web',
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
expect(code).toMatch(`_jsx("html", { children: _jsx("body", { children: "Test" }) });`);
|
|
56
|
+
const { code: nativeCode } = babel.transform(sourceCode, options);
|
|
57
|
+
expect(nativeCode).toMatch(`_jsx(Div, { children: _jsx(Div, { children: "Test" }) });`);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it(`Skips conversion in node modules`, () => {
|
|
61
|
+
const sourceCode = `
|
|
62
|
+
function App() {
|
|
63
|
+
return <a href="#">Link</a>;
|
|
64
|
+
}`;
|
|
65
|
+
const { code } = babel.transform(sourceCode, {
|
|
66
|
+
...options,
|
|
67
|
+
filename: '/node_modules/foo/bar.js',
|
|
68
|
+
});
|
|
69
|
+
expect(code).not.toMatch(`import { A } from "@expo/html-elements";`);
|
|
70
|
+
});
|
|
71
|
+
|
|
39
72
|
it(`Converts basic link`, () => {
|
|
40
73
|
const sourceCode = `
|
|
41
74
|
function App() {
|
package/babel.js
CHANGED
|
@@ -50,10 +50,26 @@ const elementToComponent = {
|
|
|
50
50
|
// NOTE: head, meta, link should use some special component in the future.
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
function getPlatform(caller) {
|
|
54
|
+
return caller && caller.platform;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = ({ types: t, ...api }, { expo }) => {
|
|
58
|
+
const platform = api.caller(getPlatform);
|
|
59
|
+
|
|
54
60
|
function replaceElement(path, state) {
|
|
61
|
+
// Not supported in node modules
|
|
62
|
+
if (/\/node_modules\//.test(state.filename)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
55
66
|
const { name } = path.node.openingElement.name;
|
|
56
67
|
|
|
68
|
+
if (platform === 'web') {
|
|
69
|
+
if (['html', 'body'].includes(name)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
57
73
|
// Replace element with @expo/html-elements
|
|
58
74
|
const component = elementToComponent[name];
|
|
59
75
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/html-elements",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Universal semantic HTML React components for iOS, Android, web, and desktop",
|
|
5
5
|
"main": "build/Elements.js",
|
|
6
6
|
"types": "build/Elements.d.ts",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"expo-module-scripts": "^3.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
|
|
63
63
|
}
|