Skip to content

Convert @primer/react to ESM, don't generate CommonJS bundle. #3410

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

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
04ee8e4
Added type=module to package.json, tests still run.
radglob Jun 12, 2023
14d64ba
Only generate ESM bundle.
radglob Jun 13, 2023
38b6cd0
Create nervous-keys-draw.md
radglob Jun 13, 2023
ed42ed7
Fix babel-defines reference in docs generation.
radglob Jun 13, 2023
eaf4df9
Add type: module to package.json and remove ESM specific export struc…
radglob Jun 20, 2023
2e513cb
Merge branch 'next-major' of github.com:primer/react into convert-to-esm
radglob Jun 20, 2023
3c9651b
Merge branch 'next-major' into convert-to-esm
radglob Jun 20, 2023
16a0362
Forgot to actually add type:module. Oops.
radglob Jun 20, 2023
404aea3
Fix some issues after setting type: module in package.json.
radglob Jun 20, 2023
aa7336f
Fix build step.
radglob Jun 20, 2023
06c0cf9
Fixing more issues.
radglob Jun 20, 2023
f50032d
Update script/get-export-sizes.
radglob Jun 20, 2023
93387aa
Fix broken import from renamed file.
radglob Jun 20, 2023
367fda1
Changed a lot of imports to ESM, fixed references that were failing t…
radglob Jun 21, 2023
ce9f33f
Fix get-export-sizes script.
radglob Jun 21, 2023
940adb7
Fix type-check errors.
radglob Jun 21, 2023
3255027
Merge branch 'next-major' of github.com:primer/react into convert-to-esm
radglob Jul 5, 2023
1e6eac3
Merge branch 'next-major' into convert-to-esm
radglob Jul 5, 2023
c6df2e6
Reference helpers as js files so imports work correctly.
radglob Jul 6, 2023
1b9b936
Change gatsby-node.js to gatsby-node.mjs to fix import issue.
radglob Jul 6, 2023
b431402
Merge branch 'next-major' into convert-to-esm
radglob Jul 7, 2023
05e70b2
Remove deprecated docs props.
radglob Jul 6, 2023
3ade26f
Merge branch 'next-major' into convert-to-esm
radglob Jul 13, 2023
cef2a87
Fix some issues after setting type: module in package.json.
radglob Jun 20, 2023
7038556
Fix comment.
radglob Jul 13, 2023
5bd5d1d
Change some files back to CJS to work better with Gatsby, fix docs ge…
radglob Jul 13, 2023
f1151ef
Merge branch 'next-major' of github.com:primer/react into convert-to-esm
radglob Jul 13, 2023
4272f46
Add changed components declaration to changeset.
radglob Jul 13, 2023
064cc21
Fix tests.
radglob Jul 13, 2023
e971d60
Fix _none_ declaration in changeset file.
radglob Jul 13, 2023
fc7faf8
Merge branch 'next-major' into convert-to-esm
radglob Jul 14, 2023
e977d5f
test(vrt): update snapshots
radglob Jul 14, 2023
b167195
Merge branch 'next-major' into convert-to-esm
radglob Jul 20, 2023
d2fe93e
Merge branch 'next-major' into convert-to-esm
radglob Jul 21, 2023
4b752b0
Merge branch 'next-major' into convert-to-esm
radglob Jul 24, 2023
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
7 changes: 7 additions & 0 deletions .changeset/nervous-keys-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@primer/react": major
---

Convert @primer/react to ESM and no longer generate CommonJS bundle.

<!-- Changed components: _none_ -->
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion babel.config.js → babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const defines = require('./babel-defines')
const defines = require('./babel-defines.cjs')

function replacementPlugin(env) {
return ['babel-plugin-transform-replace-expressions', {replace: defines[env]}]
Expand Down
2 changes: 1 addition & 1 deletion docs/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const defines = require('../babel-defines')
const defines = require('../babel-defines.cjs')
const docgen = require('react-docgen-typescript')
const globby = require('globby')

Expand Down
233 changes: 94 additions & 139 deletions docs/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"gatsby-plugin-alias-imports": "^1.0.5",
"gatsby-plugin-typescript": "2.10.0",
"graphql": "^15.8.0",
"path": "^0.12.7",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-docgen-typescript": "^2.0.0",
Expand Down
4 changes: 0 additions & 4 deletions docs/src/@primer/gatsby-theme-doctocat/mdx-components.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {Box, Link} from '@primer/react'
import InlineCode from '@primer/gatsby-theme-doctocat/src/components/inline-code'
import {ComponentChecklist} from '../../component-checklist'
// eslint-disable-next-line import/no-deprecated
import {Props} from '../../props'
import {PropsTable} from '../../props-table'
import {ComponentProps} from '../../component-props'

Expand All @@ -11,8 +9,6 @@ export default {
Link,
InlineCode,
ComponentChecklist,
// eslint-disable-next-line import/no-deprecated
Props,
PropsTable,
ComponentProps,
// HACK: MDX doesn't support rendering subcomponents with dot notation
Expand Down
67 changes: 0 additions & 67 deletions docs/src/props.js

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/components/ActionList.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('ActionList', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/ActionMenu.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('ActionMenu', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Avatar.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Avatar', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/AvatarPair.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('AvatarPair', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/AvatarStack.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('AvatarStack', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/BranchName.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('BranchName', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Breadcrumbs.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Breadcrumbs', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Button.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Button', () => {
test.describe('Playground', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/ButtonGroup.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('ButtonGroup', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Checkbox.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Checkbox', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/CheckboxGroup.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('CheckboxGroup', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/CircleBadge.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('CircleBadge', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/CircleOcticon.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('CircleOcticon', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/CounterLabel.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('CounterLabel', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/DataTable.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('DataTable', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Details.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Details', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/FilterList.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('FilterList', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/FilteredSearch.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('FilteredSearch', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Flash.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Flash', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Header.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Header', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Heading.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Heading', () => {
test.describe('Default', () => {
Expand Down
6 changes: 3 additions & 3 deletions e2e/components/Hidden.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {viewports} from '../test-helpers/viewports'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'
import {viewports} from '../test-helpers/viewports.js'

test.describe('Hidden', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/IconButton.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('IconButton', () => {
test.describe('Playground', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/InlineAutocomplete.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('InlineAutocomplete', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Label.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Label', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/LabelGroup.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('LabelGroup', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Link.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Link', () => {
test.describe('Default', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/LinkButton.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('LinkButton', () => {
test.describe('Playground', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/PageHeader.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

// TODO: remove the color contrast rule once the constract issue is fixed
test.describe('PageHeader', () => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/PageLayout.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {test, expect} from '@playwright/test'
import type {Page} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

const isInViewPort = (page: Page, boundingBox: {x: number; y: number; width: number; height: number}) => {
let width
Expand Down
4 changes: 2 additions & 2 deletions e2e/components/Pagehead.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {test, expect} from '@playwright/test'
import {visit} from '../test-helpers/storybook'
import {themes} from '../test-helpers/themes'
import {visit} from '../test-helpers/storybook.js'
import {themes} from '../test-helpers/themes.js'

test.describe('Pagehead', () => {
test.describe('Default', () => {
Expand Down
Loading