From 2d903be6c78adf54a33aad0771adc27f07339fa2 Mon Sep 17 00:00:00 2001 From: Hubert Bieszczad Date: Fri, 13 Dec 2024 11:50:32 +0100 Subject: [PATCH 1/2] fix: components exports --- package.json | 15 +++++++ plugin/__tests__/dependencies.spec.js | 40 +++++++++--------- plugin/__tests__/ref.spec.js | 32 +++++++------- plugin/__tests__/stylesheet.spec.js | 60 +++++++++++++-------------- plugin/__tests__/variants.spec.js | 18 ++++---- plugin/import.js | 4 +- 6 files changed, 92 insertions(+), 77 deletions(-) diff --git a/package.json b/package.json index 25fbec8b..c82bf888 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,21 @@ "types": "lib/typescript/src/index.d.ts", "react-native": "src/index", "source": "src/index", + "exports": { + ".": { + "types": "./lib/typescript/src/index.d.ts", + "module": "./lib/module/index", + "default": "./lib/commonjs/index" + }, + "./components/native/*": { + "module": "./lib/module/components/native/*", + "default": "./lib/commonjs/components/native/*" + }, + "./plugin": { + "module": "./plugin/index.js", + "default": "./plugin/index.js" + } + }, "files": [ "src", "lib", diff --git a/plugin/__tests__/dependencies.spec.js b/plugin/__tests__/dependencies.spec.js index a9e5d4a8..d392ddf4 100644 --- a/plugin/__tests__/dependencies.spec.js +++ b/plugin/__tests__/dependencies.spec.js @@ -44,8 +44,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -102,8 +102,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -154,8 +154,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -264,8 +264,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -386,8 +386,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -441,8 +441,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -488,8 +488,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -538,8 +538,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -608,8 +608,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -680,8 +680,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' diff --git a/plugin/__tests__/ref.spec.js b/plugin/__tests__/ref.spec.js index 3b7d41c3..46b0bbd5 100644 --- a/plugin/__tests__/ref.spec.js +++ b/plugin/__tests__/ref.spec.js @@ -70,8 +70,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' export const Example = () => { return ( @@ -112,7 +112,7 @@ pluginTester({ }) `, output: ` - import { View } from 'react-native-unistyles/src/components/native/View' + import { View } from 'react-native-unistyles/components/native/View' import { Text } from 'custom-lib' @@ -161,8 +161,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import React from 'react' import { StyleSheet } from 'react-native-unistyles' @@ -217,8 +217,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { useRef } from 'react' import { StyleSheet } from 'react-native-unistyles' @@ -283,8 +283,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import React from 'react' import { StyleSheet } from 'react-native-unistyles' @@ -354,8 +354,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import React from 'react' import { StyleSheet } from 'react-native-unistyles' @@ -423,8 +423,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import React from 'react' import { StyleSheet } from 'react-native-unistyles' @@ -486,7 +486,7 @@ pluginTester({ })) `, output: ` - import { View } from 'react-native-unistyles/src/components/native/View' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -538,7 +538,7 @@ pluginTester({ })) `, output: ` - import { View } from 'react-native-unistyles/src/components/native/View' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -582,7 +582,7 @@ pluginTester({ })) `, output: ` - import { View } from 'react-native-unistyles/src/components/native/View' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' diff --git a/plugin/__tests__/stylesheet.spec.js b/plugin/__tests__/stylesheet.spec.js index 85d421d7..8d2a0075 100644 --- a/plugin/__tests__/stylesheet.spec.js +++ b/plugin/__tests__/stylesheet.spec.js @@ -34,8 +34,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -78,8 +78,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -123,8 +123,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet as ST } from 'react-native-unistyles' @@ -169,8 +169,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -216,8 +216,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -264,8 +264,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -313,8 +313,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -364,8 +364,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -423,8 +423,8 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -488,9 +488,9 @@ pluginTester({ }) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { Pressable } from 'react-native-unistyles/src/components/native/Pressable' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { Pressable } from 'react-native-unistyles/components/native/Pressable' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -547,9 +547,9 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { Pressable } from 'react-native-unistyles/src/components/native/Pressable' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { Pressable } from 'react-native-unistyles/components/native/Pressable' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -608,9 +608,9 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { Pressable } from 'react-native-unistyles/src/components/native/Pressable' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { Pressable } from 'react-native-unistyles/components/native/Pressable' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' @@ -671,9 +671,9 @@ pluginTester({ }) `, output: ` - import { Text as SuperText } from 'react-native-unistyles/src/components/native/Text' - import { Pressable } from 'react-native-unistyles/src/components/native/Pressable' - import { View as RNView } from 'react-native-unistyles/src/components/native/View' + import { Text as SuperText } from 'react-native-unistyles/components/native/Text' + import { Pressable } from 'react-native-unistyles/components/native/Pressable' + import { View as RNView } from 'react-native-unistyles/components/native/View' import { StyleSheet } from 'react-native-unistyles' diff --git a/plugin/__tests__/variants.spec.js b/plugin/__tests__/variants.spec.js index 1d0c7679..65b9b538 100644 --- a/plugin/__tests__/variants.spec.js +++ b/plugin/__tests__/variants.spec.js @@ -54,8 +54,8 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' - import { View } from 'react-native-unistyles/src/components/native/View' + import { Text } from 'react-native-unistyles/components/native/Text' + import { View } from 'react-native-unistyles/components/native/View' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -143,7 +143,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import React from 'react' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -229,7 +229,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -315,7 +315,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import React from 'react' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -402,7 +402,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import React from 'react' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -495,7 +495,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import React from 'react' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -594,7 +594,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import React from 'react' import { StyleSheet, Variants } from 'react-native-unistyles' @@ -703,7 +703,7 @@ pluginTester({ })) `, output: ` - import { Text } from 'react-native-unistyles/src/components/native/Text' + import { Text } from 'react-native-unistyles/components/native/Text' import React from 'react' import { StyleSheet, Variants } from 'react-native-unistyles' diff --git a/plugin/import.js b/plugin/import.js index 801be835..f6c827a3 100644 --- a/plugin/import.js +++ b/plugin/import.js @@ -30,8 +30,8 @@ function addUnistylesImport(t, path, state) { const newImport = t.importDeclaration( [t.importSpecifier(t.identifier(localName), t.identifier(name))], t.stringLiteral(state.opts.isLocal - ? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/src/components/native/${name}`) - : `react-native-unistyles/src/components/native/${name}` + ? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${name}`) + : `react-native-unistyles/components/native/${name}` ) ) From bae7a628b5987412f1e89eac4ccd2c2c2eefa8b5 Mon Sep 17 00:00:00 2001 From: Hubert Bieszczad Date: Fri, 13 Dec 2024 12:34:23 +0100 Subject: [PATCH 2/2] fix: components exports --- components/native/ActivityIndicator/package.json | 3 +++ components/native/FlatList/package.json | 3 +++ components/native/Image/package.json | 3 +++ components/native/ImageBackground/package.json | 3 +++ components/native/KeyboardAvoidingView/package.json | 3 +++ components/native/Pressable/package.json | 3 +++ components/native/RefreshControl/package.json | 3 +++ components/native/ScrollView/package.json | 3 +++ components/native/SectionList/package.json | 3 +++ components/native/Switch/package.json | 3 +++ components/native/Text/package.json | 3 +++ components/native/TextInput/package.json | 3 +++ components/native/TouchableHighlight/package.json | 3 +++ components/native/TouchableOpacity/package.json | 3 +++ components/native/View/package.json | 3 +++ components/native/VirtualizedList/package.json | 3 +++ 16 files changed, 48 insertions(+) create mode 100644 components/native/ActivityIndicator/package.json create mode 100644 components/native/FlatList/package.json create mode 100644 components/native/Image/package.json create mode 100644 components/native/ImageBackground/package.json create mode 100644 components/native/KeyboardAvoidingView/package.json create mode 100644 components/native/Pressable/package.json create mode 100644 components/native/RefreshControl/package.json create mode 100644 components/native/ScrollView/package.json create mode 100644 components/native/SectionList/package.json create mode 100644 components/native/Switch/package.json create mode 100644 components/native/Text/package.json create mode 100644 components/native/TextInput/package.json create mode 100644 components/native/TouchableHighlight/package.json create mode 100644 components/native/TouchableOpacity/package.json create mode 100644 components/native/View/package.json create mode 100644 components/native/VirtualizedList/package.json diff --git a/components/native/ActivityIndicator/package.json b/components/native/ActivityIndicator/package.json new file mode 100644 index 00000000..6332ae02 --- /dev/null +++ b/components/native/ActivityIndicator/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/ActivityIndicator.js" +} diff --git a/components/native/FlatList/package.json b/components/native/FlatList/package.json new file mode 100644 index 00000000..979742ab --- /dev/null +++ b/components/native/FlatList/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/FlatList.js" +} diff --git a/components/native/Image/package.json b/components/native/Image/package.json new file mode 100644 index 00000000..01372443 --- /dev/null +++ b/components/native/Image/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/Image.js" +} diff --git a/components/native/ImageBackground/package.json b/components/native/ImageBackground/package.json new file mode 100644 index 00000000..579856bd --- /dev/null +++ b/components/native/ImageBackground/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/ImageBackground.js" +} diff --git a/components/native/KeyboardAvoidingView/package.json b/components/native/KeyboardAvoidingView/package.json new file mode 100644 index 00000000..0a8a0e6d --- /dev/null +++ b/components/native/KeyboardAvoidingView/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/KeyboardAvoidingView.js" +} diff --git a/components/native/Pressable/package.json b/components/native/Pressable/package.json new file mode 100644 index 00000000..60ca374d --- /dev/null +++ b/components/native/Pressable/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/Pressable.js" +} diff --git a/components/native/RefreshControl/package.json b/components/native/RefreshControl/package.json new file mode 100644 index 00000000..96b801de --- /dev/null +++ b/components/native/RefreshControl/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/RefreshControl.js" +} diff --git a/components/native/ScrollView/package.json b/components/native/ScrollView/package.json new file mode 100644 index 00000000..dfa2d0fa --- /dev/null +++ b/components/native/ScrollView/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/ScrollView.js" +} diff --git a/components/native/SectionList/package.json b/components/native/SectionList/package.json new file mode 100644 index 00000000..1ca9202b --- /dev/null +++ b/components/native/SectionList/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/SectionList.js" +} diff --git a/components/native/Switch/package.json b/components/native/Switch/package.json new file mode 100644 index 00000000..1df72bfa --- /dev/null +++ b/components/native/Switch/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/Switch.js" +} diff --git a/components/native/Text/package.json b/components/native/Text/package.json new file mode 100644 index 00000000..542aca43 --- /dev/null +++ b/components/native/Text/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/Text.js" +} diff --git a/components/native/TextInput/package.json b/components/native/TextInput/package.json new file mode 100644 index 00000000..a86e4d21 --- /dev/null +++ b/components/native/TextInput/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/TextInput.js" +} diff --git a/components/native/TouchableHighlight/package.json b/components/native/TouchableHighlight/package.json new file mode 100644 index 00000000..cb13b793 --- /dev/null +++ b/components/native/TouchableHighlight/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/TouchableHighlight.js" +} diff --git a/components/native/TouchableOpacity/package.json b/components/native/TouchableOpacity/package.json new file mode 100644 index 00000000..fc89d804 --- /dev/null +++ b/components/native/TouchableOpacity/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/TouchableOpacity.js" +} diff --git a/components/native/View/package.json b/components/native/View/package.json new file mode 100644 index 00000000..6ec13a8a --- /dev/null +++ b/components/native/View/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/View.js" +} diff --git a/components/native/VirtualizedList/package.json b/components/native/VirtualizedList/package.json new file mode 100644 index 00000000..7032d796 --- /dev/null +++ b/components/native/VirtualizedList/package.json @@ -0,0 +1,3 @@ +{ + "main": "../../../lib/commonjs/components/native/VirtualizedList.js" +}