Commit a68e005
authored
chore: make all exports from v5 component modules explicit (#3808)
## Description
While doing
#3785 I've
encountered a problem, where I could not export any non-type symbol from
`src/components/tabs/index.ts` because such symbol would be exported
twice - once from `src/index.ts:'export type * from './types'` and once
from `src/index.ts:<my added symbol export>` resulting in duplicated
exports error. This made me notice that our API export structure is
wrong. This PR changes that to one consistent structure across all of
our new components. It should not be a breaking change unless somebody
used deep-imports.
I'll create a doc describing the new system later, but here me out here
first.
1. Each component module should be responsible for defining it's own
public API at `src/components/<component-name>/index.ts` boundary.
Anything not directly importable from that file is not a part of public
API.
2. Root `src/index.tsx` file just reexports all the symbols exported at
the component module level.
3. No `export * from ...` type exports on the component module boundary
level. Only explicit exports are allowed. It's better to not ship some
symbol and add it later, than publish something by accident and remove
it later.
4. No default exports neither from component module boundary level nor
component implementation modules.
Such setup will also allow for easier library modularisation down the
line.
## Changes
Replaces wildcard (`export *` / `export type *`) re-exports with
explicit named exports across all v5 (experimental) component modules:
`Tabs`, `Stack`, `Split`, `SafeAreaView`, and `ScrollViewMarker`.
Also converts default exports to named exports for these components so
that each module's public surface is clearly declared in one place.
- **`src/components/tabs/index.ts`** — explicit type exports, `export
const Tabs` instead of `export default`
- **`src/components/gamma/stack/index.ts`** — explicit type exports,
`export const Stack` instead of `export default`
- **`src/components/gamma/split/index.ts`** — explicit type exports,
`export const Split` instead of `export default`
- **`src/components/safe-area/SafeAreaView.tsx`** — named export instead
of default
- **`src/components/safe-area/index.ts`** — new barrel with explicit
exports
- **`src/components/gamma/scroll-view-marker/`** — named export,
explicit re-exports
- **`src/experimental/index.ts`** — simplified to `export *` from each
component index (which now have explicit surfaces)
- **`src/experimental/types.ts`** — deleted; types are now owned by
their respective component index files
- **`src/index.tsx`** — `export type *` for v4 types; `export * from
'./components/tabs'` to correctly expose `SCREEN_KEY_MORE_NAV_CTRL` and
`Tabs` as a named export
- **`src/types.tsx`** — removed stale re-exports of tabs & shared types
(moved to `src/index.tsx`)
## Test plan
- Verified that `Tabs`, `Stack`, `Split`, `SafeAreaView`,
`ScrollViewMarker` remain importable from their respective entry points.
## Checklist
- [ ] Included code example that can be used to test this change.
- [ ] Updated / created local changelog entries in relevant test files.
- [ ] For visual changes, included screenshots / GIFs / recordings
documenting the change.
- [ ] For API changes, updated relevant public types.
- [ ] Ensured that CI passes1 parent 8fe7607 commit a68e005
13 files changed
Lines changed: 86 additions & 49 deletions
File tree
- src
- components
- gamma
- scroll-view-marker
- split
- stack
- safe-area
- tabs
- experimental
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
6 | 22 | | |
7 | 23 | | |
8 | 24 | | |
9 | 25 | | |
10 | | - | |
| 26 | + | |
11 | 27 | | |
12 | 28 | | |
13 | 29 | | |
14 | 30 | | |
15 | | - | |
16 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
6 | 14 | | |
7 | 15 | | |
8 | 16 | | |
9 | 17 | | |
10 | | - | |
| 18 | + | |
11 | 19 | | |
12 | 20 | | |
13 | 21 | | |
14 | | - | |
15 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
6 | 39 | | |
7 | 40 | | |
8 | 41 | | |
9 | 42 | | |
10 | 43 | | |
11 | 44 | | |
12 | | - | |
| 45 | + | |
13 | 46 | | |
14 | 47 | | |
15 | 48 | | |
16 | | - | |
17 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
8 | 7 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments