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

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

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .changeset/nervous-keys-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": major
---

Convert @primer/react to ESM and no longer generate CommonJS bundle.
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
File renamed without changes.
16 changes: 4 additions & 12 deletions package.json
radglob marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,21 @@
"module": "lib-esm/index.js",
"exports": {
".": {
"import": "./lib-esm/index.js",
"require": "./lib/index.js"
"import": "./lib-esm/index.js"
},
"./experimental": {
"import": "./lib-esm/experimental/index.js",
"require": "./lib/experimental/index.js"
"import": "./lib-esm/experimental/index.js"
},
"./drafts": {
"import": "./lib-esm/drafts/index.js",
"require": "./lib/drafts/index.js"
"import": "./lib-esm/drafts/index.js"
},
"./deprecated": {
"import": "./lib-esm/deprecated/index.js",
"require": "./lib/deprecated/index.js"
"import": "./lib-esm/deprecated/index.js"
},
"./lib-esm/*": {
"import": [
"./lib-esm/*.js",
radglob marked this conversation as resolved.
Show resolved Hide resolved
"./lib-esm/*/index.js"
],
"require": [
"./lib/*.js",
"./lib/*/index.js"
]
},
"./lib-esm/internal/*": null
Expand Down
21 changes: 0 additions & 21 deletions rollup.config.js → rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ const input = new Set([
])

const extensions = ['.js', '.jsx', '.ts', '.tsx']
const ESM_ONLY = new Set([
'@github/combobox-nav',
'@github/markdown-toolbar-element',
'@github/paste-markdown',
'@github/relative-time-element',
'@lit-labs/react',
])
radglob marked this conversation as resolved.
Show resolved Hide resolved
const dependencies = [
...Object.keys(packageJson.peerDependencies ?? {}),
...Object.keys(packageJson.dependencies ?? {}),
Expand Down Expand Up @@ -143,20 +136,6 @@ export default [
},
},

// CommonJS
{
...baseConfig,
external: dependencies.filter(name => !ESM_ONLY.has(name)).map(createPackageRegex),
output: {
interop: 'auto',
dir: 'lib',
format: 'commonjs',
preserveModules: true,
preserveModulesRoot: 'src',
exports: 'auto',
},
},

// Bundles
{
...baseConfig,
Expand Down