Skip to content

Commit

Permalink
feat(project): add subpath pattern to package.json to restrict intern…
Browse files Browse the repository at this point in the history
…al imports (#3186)

* feat(project): add subpath pattern to package.json to restrict internal imports

* refactor(project): move useOverflow to internal/hooks

* docs(adrs): update adopted status for adr

* chore: add changeset

* Update generated/components.json

---------

Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
  • Loading branch information
joshblack and joshblack committed Apr 18, 2023
1 parent ca60603 commit 2b14779
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-crabs-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Modules under an internal export pattern are not able to be imported from outside @primer/react
23 changes: 11 additions & 12 deletions contributor-docs/adrs/adr-016-internal-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
| Stage | Status |
| -------- | ------ |
| Approved ||
| Adopted | 🚧 |
| Adopted | |

## Context

Currently all files live under the `src` directory. In the `npm` package for `@primer/react`, we specify the following export pattern:

```json5
{
"exports": {
exports: {
// ...
"./lib-esm/*": {
"import": [
'./lib-esm/*': {
import: [
// ...
],
"require": [
require: [
// ...
]
}
}
],
},
},
}
```

Expand All @@ -37,10 +37,10 @@ In the `"exports"` field of our `npm` package, we can then add the following pat

```json5
{
"exports": {
exports: {
// ...
"./lib-esm/internal/*": null
}
'./lib-esm/internal/*': null,
},
}
```

Expand All @@ -57,7 +57,6 @@ This pattern would remove any files and folders within `src/internal` from the p
}
```


### Impact

- Update the `"exports"` field in `package.json` to exclude `./lib-esm/internal` from usage
Expand Down
1 change: 1 addition & 0 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
{
"name": "direction",
"type": "'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'nw'",
"defaultValue": "n",
"description": "Sets where the tooltip renders in relation to the target."
},
{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"./lib/*.js",
"./lib/*/index.js"
]
}
},
"./lib-esm/internal/*": null
},
"typings": "lib/index.d.ts",
"sideEffects": false,
Expand Down
2 changes: 1 addition & 1 deletion src/DataTable/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Column, CellAlignment} from './column'
import {UniqueRow} from './row'
import {SortDirection} from './sorting'
import {useTableLayout} from './useTable'
import {useOverflow} from '../hooks/useOverflow'
import {useOverflow} from '../internal/hooks/useOverflow'

// ----------------------------------------------------------------------------
// Table
Expand Down
2 changes: 1 addition & 1 deletion src/PageLayout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {useSlots} from '../hooks/useSlots'
import {BetterSystemStyleObject, merge, SxProp} from '../sx'
import {Theme} from '../ThemeProvider'
import {canUseDOM} from '../utils/environment'
import {useOverflow} from '../utils/useOverflow'
import {useOverflow} from '../internal/hooks/useOverflow'
import {warning} from '../utils/warning'
import VisuallyHidden from '../_VisuallyHidden'
import {useStickyPaneHeight} from './useStickyPaneHeight'
Expand Down
File renamed without changes.
24 changes: 0 additions & 24 deletions src/utils/useOverflow.ts

This file was deleted.

0 comments on commit 2b14779

Please sign in to comment.