Skip to content

Commit 2efe0d7

Browse files
committed
Use JS script
1 parent aedb21e commit 2efe0d7

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"plugin:react/recommended",
1414
"prettier"
1515
],
16+
"exclude": ["scripts/*.js"],
1617
"rules": {
1718
"deprecation/deprecation": "error",
1819
"react-hooks/rules-of-hooks": "error",

fix-exports-type.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

scripts/fix-exports-type.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env node
2+
// This script defines the type of exports in the dist directory using minimal
3+
// package.json files. Setting the type in the main package.json file does not
4+
// work because we want to support both CommonJS and ES Module exports in the
5+
// same package.
6+
7+
const FS = require('node:fs')
8+
9+
const DIST_DIR = 'dist'
10+
11+
FS.writeFileSync(
12+
`${DIST_DIR}/cjs/package.json`,
13+
JSON.stringify({
14+
type: 'commonjs',
15+
}),
16+
)
17+
18+
FS.writeFileSync(
19+
`${DIST_DIR}/esm/package.json`,
20+
JSON.stringify({
21+
type: 'module',
22+
}),
23+
)

0 commit comments

Comments
 (0)