Skip to content

Commit

Permalink
Merge pull request #444 from jpudysz/fix/module-exports
Browse files Browse the repository at this point in the history
fix: module exports
  • Loading branch information
jpudysz authored Dec 16, 2024
2 parents 64c1887 + 42c4cc7 commit a3eadc7
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 24 deletions.
3 changes: 2 additions & 1 deletion components/native/ActivityIndicator/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/ActivityIndicator.js"
"main": "../../../lib/commonjs/components/native/ActivityIndicator.js",
"module": "../../../lib/module/components/native/ActivityIndicator.js"
}
3 changes: 2 additions & 1 deletion components/native/FlatList/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/FlatList.js"
"main": "../../../lib/commonjs/components/native/FlatList.js",
"module": "../../../lib/module/components/native/FlatList.js"
}
3 changes: 2 additions & 1 deletion components/native/Image/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/Image.js"
"main": "../../../lib/commonjs/components/native/Image.js",
"module": "../../../lib/module/components/native/Image.js"
}
3 changes: 2 additions & 1 deletion components/native/ImageBackground/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/ImageBackground.js"
"main": "../../../lib/commonjs/components/native/ImageBackground.js",
"module": "../../../lib/module/components/native/ImageBackground.js"
}
3 changes: 2 additions & 1 deletion components/native/KeyboardAvoidingView/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/KeyboardAvoidingView.js"
"main": "../../../lib/commonjs/components/native/KeyboardAvoidingView.js",
"module": "../../../lib/module/components/native/KeyboardAvoidingView.js"
}
1 change: 1 addition & 0 deletions components/native/Pressable/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"main": "../../../lib/commonjs/components/native/Pressable.js",
"module": "../../../lib/module/components/native/Pressable.js",
"react-native": "../../../lib/commonjs/components/native/Pressable.native.js"
}
3 changes: 2 additions & 1 deletion components/native/RefreshControl/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/RefreshControl.js"
"main": "../../../lib/commonjs/components/native/RefreshControl.js",
"module": "../../../lib/module/components/native/RefreshControl.js"
}
3 changes: 2 additions & 1 deletion components/native/ScrollView/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/ScrollView.js"
"main": "../../../lib/commonjs/components/native/ScrollView.js",
"module": "../../../lib/module/components/native/ScrollView.js"
}
3 changes: 2 additions & 1 deletion components/native/SectionList/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/SectionList.js"
"main": "../../../lib/commonjs/components/native/SectionList.js",
"module": "../../../lib/module/components/native/SectionList.js"
}
3 changes: 2 additions & 1 deletion components/native/Switch/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/Switch.js"
"main": "../../../lib/commonjs/components/native/Switch.js",
"module": "../../../lib/module/components/native/Switch.js"
}
3 changes: 2 additions & 1 deletion components/native/Text/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/Text.js"
"main": "../../../lib/commonjs/components/native/Text.js",
"module": "../../../lib/module/components/native/Text.js"
}
3 changes: 2 additions & 1 deletion components/native/TextInput/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/TextInput.js"
"main": "../../../lib/commonjs/components/native/TextInput.js",
"module": "../../../lib/module/components/native/TextInput.js"
}
3 changes: 2 additions & 1 deletion components/native/TouchableHighlight/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/TouchableHighlight.js"
"main": "../../../lib/commonjs/components/native/TouchableHighlight.js",
"module": "../../../lib/module/components/native/TouchableHighlight.js"
}
3 changes: 2 additions & 1 deletion components/native/TouchableOpacity/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/TouchableOpacity.js"
"main": "../../../lib/commonjs/components/native/TouchableOpacity.js",
"module": "../../../lib/module/components/native/TouchableOpacity.js"
}
3 changes: 2 additions & 1 deletion components/native/View/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/View.js"
"main": "../../../lib/commonjs/components/native/View.js",
"module": "../../../lib/module/components/native/View.js"
}
3 changes: 2 additions & 1 deletion components/native/VirtualizedList/package.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"main": "../../../lib/commonjs/components/native/VirtualizedList.js"
"main": "../../../lib/commonjs/components/native/VirtualizedList.js",
"module": "../../../lib/module/components/native/VirtualizedList.js"
}
10 changes: 2 additions & 8 deletions src/web/shadowRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { UnistylesTheme, UnistylesValues } from '../types'
import { UnistylesListener } from './listener'
import { UnistylesRegistry } from './registry'
import { deepMergeObjects } from '../utils'
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument, keyInObject } from './utils'
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument } from './utils'
import { getVariants } from './variants'

type Style = UnistylesValues | ((...args: Array<any>) => UnistylesValues)
Expand Down Expand Up @@ -67,13 +67,6 @@ class UnistylesShadowRegistryBuilder {

// Regular style
if (!secrets) {
Object.keys(unistyleStyle).forEach(key => {
if (keyInObject(ref.style, key)) {
// @ts-expect-error - Styles won't have read only properties
ref.style[key] = ''
}
})

return unistyleStyle as UnistylesValues
}

Expand Down Expand Up @@ -133,6 +126,7 @@ class UnistylesShadowRegistryBuilder {
this.classNamesMap.set(ref, newClassNames)
// Add new classnames to the ref
ref.classList.add(...newClassNames)
ref.removeAttribute('styles')

return newClassNames
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/utils/unistyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
}

export const extractSecrets = (object: any) => {
return keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
return object && keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
}

export const removeInlineStyles = (values: UnistylesValues) => {
Expand Down

0 comments on commit a3eadc7

Please sign in to comment.