Skip to content

Commit e00bcb4

Browse files
committed
Merge pull request #408 from antonioru/fix/package-specifiers
fix(specifiers): Updates package.json specifiers
2 parents 08917a0 + 98a2187 commit e00bcb4

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

.github/workflows/ci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ jobs:
4545
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4646

4747
- name: Prepare distribution
48-
run: cp package.json README.md LICENSE.txt CHANGELOG.md CONTRIBUTING.md CODE_OF_CONDUCT.md ./dist
48+
run: |
49+
node scripts/generate-exports.js
50+
cp package.json README.md LICENSE.txt CHANGELOG.md CONTRIBUTING.md CODE_OF_CONDUCT.md ./dist
4951
5052
- name: Publish
5153
run: |

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1029,4 +1029,10 @@ Errored release
10291029

10301030
### Fixes
10311031

1032-
- Deprecated github actions version
1032+
- Deprecated GitHub actions version
1033+
1034+
## [4.2.1] - 2023-03-18
1035+
1036+
### Fixes
1037+
1038+
- package.json specifiers (exports)

package.json

-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@
102102
"webpack": "5.76.1"
103103
},
104104
"exports": {
105-
".": {
106-
"import": "./esm/index.js",
107-
"require": "./index.js"
108-
},
109105
"./useWindowScroll": {
110106
"import": "./esm/useWindowScroll.js",
111107
"require": "./useWindowScroll.js"

scripts/generate-exports.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,19 @@ const srcFiles = globSync(`${srcPath}/*.ts`)
1111
.map((file) => file.replace(`${srcPath}/`, '').replace('.ts', ''))
1212
.filter((file) => file !== 'index')
1313

14-
const defaultExports = {
15-
'.': {
16-
import: './esm/index.js',
17-
require: './index.js'
18-
}
19-
}
20-
2114
const exportsObj = srcFiles.reduce((acc, file) => ({
2215
...acc,
2316
[`./${file}`]: {
2417
import: `./esm/${file}.js`,
2518
require: `./${file}.js`
2619
}
27-
}), defaultExports)
20+
}), {})
2821

2922
const packageJsonText = fs.readFileSync(pkgPath)
3023
const packageJson = JSON.parse(packageJsonText)
3124

3225
const nextPackageJson = { ...packageJson, exports: exportsObj }
3326

34-
console.log('\nUPDATING EXPORTS: ', nextPackageJson)
27+
console.log('\nUPDATING EXPORTS: ', Object.keys(exportsObj))
3528

3629
fs.writeFileSync(pkgPath, JSON.stringify(nextPackageJson, null, 2))

0 commit comments

Comments
 (0)