Skip to content

Commit

Permalink
improved treeshaking
Browse files Browse the repository at this point in the history
  • Loading branch information
XantreDev committed Mar 2, 2024
1 parent d8fea62 commit b595046
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-eggs-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@preact-signals/utils": patch
---

Improved treeshacking by avoiding `export *`
11 changes: 4 additions & 7 deletions packages/utils/src/lib/components/components/index.ts
Original file line number Diff line number Diff line change
@@ -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";
17 changes: 14 additions & 3 deletions packages/utils/src/lib/components/index.ts
Original file line number Diff line number Diff line change
@@ -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";
11 changes: 10 additions & 1 deletion packages/utils/src/lib/flat-store/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
export * from "./createFlatStore";
export {
type FlatStore,
type FlatStoreOfSignalsBody,
type ReadonlyFlatStore,
type ReadonlySignalsKeys,
createFlatStore,
createFlatStoreOfSignals,
flatStore,
flatStoreOfSignals,
} from "./createFlatStore";
9 changes: 6 additions & 3 deletions packages/utils/src/lib/hocs/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from "./reactifyLite";
export * from "./withSignalProps";

export {
type ReactifyLiteFn,
type ReactiveProps,
reactifyLite,
} from "./reactifyLite";
export { type WithSignalProp, withSignalProps } from "./withSignalProps";
8 changes: 7 additions & 1 deletion packages/utils/src/lib/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -10,5 +15,6 @@ export {
useSignalEffectOnce,
useSignalOfReactive,
useSignalOfState,
type Dispose,
} from "./utility";
export { useDeepReactive, useDeepSignal, useShallowReactive } from "./store";
34 changes: 31 additions & 3 deletions packages/utils/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import "./store/sideEffects";

export * from "./$";
export {
$,
$w,
signalOf$,
ReactiveRef,
Uncached,
WritableReactiveRef,
WritableUncached,
type WritableRefOptions,
} from "./$";
export {
createFlatStore,
flatStore,
Expand All @@ -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,
Expand All @@ -23,8 +49,9 @@ export {
unwrapReactive,
rafReaction,
isExplicitFalsy,
writableRefOfArrayProp,
writableRefOfArrayProp,
writableRefOfObjectProp,
toSolidLikeSignal,
type ExplicitFalsy,
type GetTruthyValue,
type GetValue,
Expand All @@ -34,6 +61,7 @@ export {
type CreateFunction,
type Reactive,
type Setter,
type ReactionOptions,
} from "./utils";

export {
Expand Down
6 changes: 4 additions & 2 deletions packages/utils/src/lib/resource/index.ts
Original file line number Diff line number Diff line change
@@ -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";
17 changes: 10 additions & 7 deletions packages/utils/src/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -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";

0 comments on commit b595046

Please sign in to comment.