diff --git a/.changeset/fresh-eggs-heal.md b/.changeset/fresh-eggs-heal.md new file mode 100644 index 00000000..8b04b6ad --- /dev/null +++ b/.changeset/fresh-eggs-heal.md @@ -0,0 +1,5 @@ +--- +"@preact-signals/utils": patch +--- + +Improved treeshacking by avoiding `export *` diff --git a/packages/utils/src/lib/components/components/index.ts b/packages/utils/src/lib/components/components/index.ts index 98b24c00..4f67c875 100644 --- a/packages/utils/src/lib/components/components/index.ts +++ b/packages/utils/src/lib/components/components/index.ts @@ -1,7 +1,4 @@ -// export { For } from "./For"; -// export type { ForProps } from "./For"; -export * from "./Computed"; -export * from "./For"; -export * from "./Show"; -export * from "./Switch"; - +export { Computed, type ComputedProps } from "./Computed"; +export { For, type ForProps, type KeyExtractor } from "./For"; +export { Show, type ShowProps } from "./Show"; +export { Match, type MatchProps, Switch, type SwitchProps } from "./Switch"; diff --git a/packages/utils/src/lib/components/index.ts b/packages/utils/src/lib/components/index.ts index 193aaa78..72ca4436 100644 --- a/packages/utils/src/lib/components/index.ts +++ b/packages/utils/src/lib/components/index.ts @@ -1,3 +1,14 @@ -export * from "./components"; -export * from "./type"; - +export { + type ForProps, + type KeyExtractor, + type ComputedProps, + type MatchProps, + type ShowProps, + type SwitchProps, + Computed, + For, + Match, + Show, + Switch, +} from "./components"; +export type * from "./type"; diff --git a/packages/utils/src/lib/flat-store/index.ts b/packages/utils/src/lib/flat-store/index.ts index dd759458..dcf7d0ce 100644 --- a/packages/utils/src/lib/flat-store/index.ts +++ b/packages/utils/src/lib/flat-store/index.ts @@ -1 +1,10 @@ -export * from "./createFlatStore"; +export { + type FlatStore, + type FlatStoreOfSignalsBody, + type ReadonlyFlatStore, + type ReadonlySignalsKeys, + createFlatStore, + createFlatStoreOfSignals, + flatStore, + flatStoreOfSignals, +} from "./createFlatStore"; diff --git a/packages/utils/src/lib/hocs/index.ts b/packages/utils/src/lib/hocs/index.ts index ecd1d807..0a189375 100644 --- a/packages/utils/src/lib/hocs/index.ts +++ b/packages/utils/src/lib/hocs/index.ts @@ -1,3 +1,6 @@ -export * from "./reactifyLite"; -export * from "./withSignalProps"; - +export { + type ReactifyLiteFn, + type ReactiveProps, + reactifyLite, +} from "./reactifyLite"; +export { type WithSignalProp, withSignalProps } from "./withSignalProps"; diff --git a/packages/utils/src/lib/hooks/index.ts b/packages/utils/src/lib/hooks/index.ts index bb413b3e..e784beb7 100644 --- a/packages/utils/src/lib/hooks/index.ts +++ b/packages/utils/src/lib/hooks/index.ts @@ -1,4 +1,9 @@ -export * from "./flat-store"; +export { + useComputedFlatStore, + useFlatStore, + type AnyRecord, + useFlatStoreOfSignals, +} from "./flat-store"; export { useResource } from "./resource"; export { useLinkedSignal, type UnwrapSignalDeep } from "./useLinkedSignal"; export { useReaction } from "./useReaction"; @@ -10,5 +15,6 @@ export { useSignalEffectOnce, useSignalOfReactive, useSignalOfState, + type Dispose, } from "./utility"; export { useDeepReactive, useDeepSignal, useShallowReactive } from "./store"; diff --git a/packages/utils/src/lib/index.ts b/packages/utils/src/lib/index.ts index 2875bc5f..1a1c116f 100644 --- a/packages/utils/src/lib/index.ts +++ b/packages/utils/src/lib/index.ts @@ -1,6 +1,15 @@ import "./store/sideEffects"; -export * from "./$"; +export { + $, + $w, + signalOf$, + ReactiveRef, + Uncached, + WritableReactiveRef, + WritableUncached, + type WritableRefOptions, +} from "./$"; export { createFlatStore, flatStore, @@ -11,7 +20,24 @@ export { type FlatStore, type ReadonlyFlatStore, } from "./flat-store"; -export * from "./resource"; +export { + type CreateResourceReturn, + type Errored, + type InitializedResource, + type Pending, + type Ready, + type Refreshing, + type Resource, + type ResourceActions, + type ResourceFetcher, + type ResourceFetcherInfo, + type ResourceOptions, + type ResourceSource, + type ResourceState, + type Unresolved, + createResource, + resource, +} from "./resource"; export { accessorOfReactive, accessorOfSignal, @@ -23,8 +49,9 @@ export { unwrapReactive, rafReaction, isExplicitFalsy, - writableRefOfArrayProp, + writableRefOfArrayProp, writableRefOfObjectProp, + toSolidLikeSignal, type ExplicitFalsy, type GetTruthyValue, type GetValue, @@ -34,6 +61,7 @@ export { type CreateFunction, type Reactive, type Setter, + type ReactionOptions, } from "./utils"; export { diff --git a/packages/utils/src/lib/resource/index.ts b/packages/utils/src/lib/resource/index.ts index 4588fb32..952fc3c5 100644 --- a/packages/utils/src/lib/resource/index.ts +++ b/packages/utils/src/lib/resource/index.ts @@ -1,2 +1,4 @@ -export * from "./createResource"; -export * from "./resource"; +export { createResource } from "./createResource"; +export { resource } from "./resource"; +export type * from "./resource"; +export type * from "./createResource"; diff --git a/packages/utils/src/lib/utils/index.ts b/packages/utils/src/lib/utils/index.ts index 4e9810bd..32336b77 100644 --- a/packages/utils/src/lib/utils/index.ts +++ b/packages/utils/src/lib/utils/index.ts @@ -1,9 +1,12 @@ export { untracked } from "@preact-signals/unified-signals"; -export * from "./explicitFalsy"; -export * from "./getter"; -export * from "./reactive"; -export * from "./setter"; -export * from "./toSolidApi"; -export * from "./type"; -export * from './object' +export { isExplicitFalsy } from "./explicitFalsy"; +export type * from "./explicitFalsy"; +export { accessorOfSignal, stableAccessorOfSignal } from "./getter"; +export { accessorOfReactive, unwrapReactive } from "./reactive"; +export { setterOfSignal, toggleSignal } from "./setter"; +export { toSolidLikeSignal } from "./toSolidApi"; +export type * from "./toSolidApi"; +export type * from "./type"; +export { writableRefOfArrayProp, writableRefOfObjectProp } from "./object"; export { reaction, rafReaction } from "./reaction"; +export type * from "./reaction";