Skip to content

Commit 63a2de5

Browse files
authored
Convert commonjs code to esm during build (#2150)
* Build theme-preval to esm * Use default export for theme-preval * Create sweet-elephants-end.md * Update theme-preval snapshot
1 parent 9299d23 commit 63a2de5

File tree

7 files changed

+3258
-3230
lines changed

7 files changed

+3258
-3230
lines changed

.changeset/sweet-elephants-end.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Ensure all files in `lib-esm` are in fact esm and not CommonJS

babel.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ module.exports = {
2222
development: {
2323
presets: makePresets(process.env.BABEL_MODULE || false),
2424
plugins: [
25-
...(process.env.BABEL_MODULE === 'commonjs' ? ['@babel/plugin-transform-modules-commonjs'] : []),
25+
...(process.env.BABEL_MODULE === 'commonjs'
26+
? ['@babel/plugin-transform-modules-commonjs']
27+
: [
28+
'transform-commonjs' // theme-preval is commonjs and needs to be transformed to esm
29+
]),
2630
...sharedPlugins,
2731
replacementPlugin('development')
2832
]

package-lock.json

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
"babel-plugin-open-source": "1.3.2",
141141
"babel-plugin-preval": "5.0.0",
142142
"babel-plugin-styled-components": "2.0.2",
143+
"babel-plugin-transform-commonjs": "1.1.6",
143144
"babel-plugin-transform-replace-expressions": "0.2.0",
144145
"babel-polyfill": "6.26.0",
145146
"chroma-js": "2.1.2",

0 commit comments

Comments
 (0)