Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can now export from @primer/react/drafts #1771

Merged
merged 8 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/content/drafts/ActionList2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ import InlineCode from '@primer/gatsby-theme-doctocat/src/components/inline-code
</Box>

```js
// ESM
import {ActionList} from '@primer/react/lib-esm/drafts'
// or commonjs:
import {ActionList} from '@primer/react/lib/drafts'
import {ActionList} from '@primer/react/drafts'
```

## Examples
Expand Down
5 changes: 1 addition & 4 deletions docs/content/drafts/ActionMenu2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ import {Props} from '../../src/props'
<br />

```js
// ESM
import {ActionMenu} from '@primer/react/lib-esm/drafts'
// or commonjs:
import {ActionMenu} from '@primer/react/lib/drafts'
import {ActionMenu} from '@primer/react/drafts'
```

<br />
Expand Down
5 changes: 1 addition & 4 deletions docs/content/drafts/Button2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import {Button, IconButton, LinkButton} from '@primer/react/drafts'
### Installation

```js
// ESM
import {Button} from '@primer/react/lib-esm/drafts'
// or commonjs:
import {Button} from '@primer/react/lib/drafts'
import {Button} from '@primer/react/drafts'
```

### Default button
Expand Down
4 changes: 1 addition & 3 deletions docs/content/drafts/IconButton.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import {ComponentChecklist} from '../../src/component-checklist'
### Installation

```js
import {IconButton} from '@primer/react/lib-esm/drafts'
// or commonjs:
import {IconButton} from '@primer/react/lib/drafts'
import {IconButton} from '@primer/react/drafts'
```

### Icon only button
Expand Down
4 changes: 1 addition & 3 deletions docs/content/drafts/LinkButton.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import {ArrowRightIcon} from '@primer/octicons-react'
### Installation

```js
import {LinkButton} from '@primer/react/lib-esm/drafts'
// or commonjs:
import {LinkButton} from '@primer/react/lib/drafts'
import {LinkButton} from '@primer/react/drafts'
```

### Default
Expand Down
9 changes: 9 additions & 0 deletions drafts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"_comment1": "this is required only for typescript. once this is fixed https://github.com/microsoft/TypeScript/issues/33079 we can remove this hack",
"name": "@primer/react/drafts",
"types": "../lib-esm/drafts/index.d.ts",
"main": "../lib-esm/drafts/index.js",
"type": "module",
"sideEffects": false
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhhhh, this is big brain time! 🧠

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so without these all the imports work except the typescript build fails. This hack I found in @primer/behavior simply worked here.

12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
"description": "An implementation of GitHub's Primer Design System using React",
"main": "lib/index.js",
"module": "lib-esm/index.js",
"exports": {
".": {
"node": "./lib/index.js",
"default": "./lib-esm/index.js"
},
"./drafts": {
"node": "./lib/drafts/index.js",
"default": "./lib-esm/drafts/index.js"
},
"./lib-esm/*": {
"node": ["./lib/*.js","./lib/*/index.js"],
"default": ["./lib-esm/*.js","./lib-esm/*/index.js"]
}
},
"typings": "lib/index.d.ts",
"sideEffects": false,
"scripts": {
Expand Down Expand Up @@ -34,6 +48,7 @@
"lib",
"lib-esm",
"index.d.ts",
"drafts/package.json",
"!lib/__tests__",
"!lib/stories",
"!lib-esm/__tests__",
Expand Down
10 changes: 5 additions & 5 deletions src/drafts.ts → src/drafts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

// Components
export * from './ActionList2'
export * from './Button2'
export * from './ActionMenu2'
export * from './DropdownMenu2'
export * from './Label2'
export * from '../ActionList2'
export * from '../Button2'
export * from '../ActionMenu2'
export * from '../DropdownMenu2'
export * from '../Label2'