@usemotif/compiler-metro 1.2.0 → 1.2.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/package.json +7 -3
- package/src/index.test.ts +0 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usemotif/compiler-metro",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Metro transformer for motif-js static style extraction in React Native.",
|
|
5
5
|
"homepage": "https://github.com/foo-stack/usemotif/tree/main/packages/compiler-metro#readme",
|
|
6
6
|
"bugs": "https://github.com/foo-stack/usemotif/issues",
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"dist",
|
|
15
|
-
"src"
|
|
15
|
+
"src",
|
|
16
|
+
"!src/**/*.test.*",
|
|
17
|
+
"!src/**/*.spec.*",
|
|
18
|
+
"!src/**/__tests__/**",
|
|
19
|
+
"!src/**/__fixtures__/**"
|
|
16
20
|
],
|
|
17
21
|
"type": "module",
|
|
18
22
|
"sideEffects": false,
|
|
@@ -37,7 +41,7 @@
|
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
39
43
|
"@babel/core": "^7.29.0",
|
|
40
|
-
"@usemotif/compiler-babel": "
|
|
44
|
+
"@usemotif/compiler-babel": "workspace:*"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
47
|
"@types/babel__core": "^7.20.5",
|
package/src/index.test.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { transformSync } from '@babel/core';
|
|
2
|
-
import { describe, expect, it } from 'vitest';
|
|
3
|
-
import motifMetro from './index.js';
|
|
4
|
-
|
|
5
|
-
describe('@usemotif/compiler-metro', () => {
|
|
6
|
-
it('returns a [plugin, options] tuple Babel can consume', () => {
|
|
7
|
-
const tuple = motifMetro();
|
|
8
|
-
expect(Array.isArray(tuple)).toBe(true);
|
|
9
|
-
expect(tuple).toHaveLength(2);
|
|
10
|
-
expect(typeof tuple[0]).toBe('function');
|
|
11
|
-
expect(tuple[1]).toMatchObject({ target: 'native' });
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('hoists StyleSheet.create on native target', () => {
|
|
15
|
-
const tuple = motifMetro();
|
|
16
|
-
const result = transformSync(
|
|
17
|
-
`import { Box } from '@usemotif/react-native';\nconst X = () => <Box p={4} />;\n`,
|
|
18
|
-
{
|
|
19
|
-
babelrc: false,
|
|
20
|
-
configFile: false,
|
|
21
|
-
filename: 'test.tsx',
|
|
22
|
-
plugins: [tuple],
|
|
23
|
-
parserOpts: { plugins: ['jsx', 'typescript'] },
|
|
24
|
-
generatorOpts: { compact: false },
|
|
25
|
-
},
|
|
26
|
-
);
|
|
27
|
-
const code = result?.code ?? '';
|
|
28
|
-
expect(code).not.toMatch(/\bp=\{4\}/);
|
|
29
|
-
expect(code).toContain('StyleSheet');
|
|
30
|
-
expect(code).toContain('_motifStyles');
|
|
31
|
-
expect(code).toContain('padding: 4');
|
|
32
|
-
expect(code).toMatch(/style=\{_motifStyles\.id\d+\}/);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('forwards the breakpoints override to the babel plugin options', () => {
|
|
36
|
-
const tuple = motifMetro({ breakpoints: { md: 800 } });
|
|
37
|
-
expect(tuple[1]).toMatchObject({ target: 'native', breakpoints: { md: 800 } });
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('respects target override', () => {
|
|
41
|
-
const tuple = motifMetro({ target: 'web' });
|
|
42
|
-
const result = transformSync(
|
|
43
|
-
`import { Box } from '@usemotif/react';\nconst X = () => <Box p={4} />;\n`,
|
|
44
|
-
{
|
|
45
|
-
babelrc: false,
|
|
46
|
-
configFile: false,
|
|
47
|
-
filename: 'test.tsx',
|
|
48
|
-
plugins: [tuple],
|
|
49
|
-
parserOpts: { plugins: ['jsx', 'typescript'] },
|
|
50
|
-
generatorOpts: { compact: false },
|
|
51
|
-
},
|
|
52
|
-
);
|
|
53
|
-
// With target=web, the static prop should be extracted.
|
|
54
|
-
expect(result?.code).not.toMatch(/\bp=\{4\}/);
|
|
55
|
-
expect(result?.code).toContain('padding: 4');
|
|
56
|
-
});
|
|
57
|
-
});
|