Skip to content

Commit 64ea88e

Browse files
authored
Workaround TypeScript resolution bug (#20)
1 parent 89114a4 commit 64ea88e

File tree

5 files changed

+44
-14
lines changed

5 files changed

+44
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixes [#19](https://github.com/compulim/use-ref-from/issues/19). Updated `exports` field to workaround [TypeScript resolution bug](https://github.com/microsoft/TypeScript/issues/50762), by [@compulim](https://github.com/compulim), in PR [#20](https://github.com/compulim/use-ref-from/pull/20)
13+
1014
## [0.0.2] - 2023-03-21
1115

1216
### Fixed

packages/use-ref-from/package.json

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,38 @@
33
"version": "0.0.0-0",
44
"description": "React.useRef with an immediate setter and read-only value.",
55
"files": [
6-
"./lib/*"
6+
"./lib/"
77
],
88
"exports": {
99
".": {
10-
"import": "./lib/esmodules/index.js",
11-
"require": "./lib/commonjs/index.js",
12-
"types": "./lib/types/index.d.ts"
10+
"import": {
11+
"types": "./lib/esmodules-types/index.d.ts",
12+
"default": "./lib/esmodules/index.js"
13+
},
14+
"require": {
15+
"types": "./lib/commonjs-types/index.d.ts",
16+
"default": "./lib/commonjs/index.js"
17+
}
1318
},
1419
"./useRefFrom": {
15-
"import": "./lib/esmodules/useRefFrom.js",
16-
"require": "./lib/commonjs/useRefFrom.js",
17-
"types": "./lib/types/useRefFrom.d.ts"
20+
"import": {
21+
"types": "./lib/esmodules-types/useRefFrom.d.ts",
22+
"default": "./lib/esmodules/useRefFrom.js"
23+
},
24+
"require": {
25+
"types": "./lib/commonjs-types/useRefFrom.d.ts",
26+
"default": "./lib/commonjs/useRefFrom.js"
27+
}
1828
}
1929
},
2030
"main": "./lib/commonjs/index.js",
21-
"typings": "./lib/types/index.d.ts",
31+
"typings": "./lib/commonjs-types/index.d.ts",
2232
"scripts": {
23-
"build": "npm run build:babel && npm run build:typescript",
24-
"build:babel": "npm run build:babel:commonjs && npm run build:babel:esmodules",
33+
"build": "npm run build:babel:commonjs && npm run build:babel:esmodules && npm run build:typescript:commonjs && npm run build:typescript:esmodules",
2534
"build:babel:commonjs": "babel src --config-file ./babel.commonjs.config.json --extensions .ts,.tsx --out-dir ./lib/commonjs/",
2635
"build:babel:esmodules": "babel src --config-file ./babel.esmodules.config.json --extensions .ts,.tsx --out-dir ./lib/esmodules/",
27-
"build:typescript": "tsc --project ./src/tsconfig.declaration.json",
36+
"build:typescript:commonjs": "tsc --project ./src/tsconfig.declaration.commonjs.json",
37+
"build:typescript:esmodules": "tsc --project ./src/tsconfig.declaration.esmodules.json",
2838
"bump": "npm run bump:prod && npm run bump:dev && npm run bump:auditfix && npm run bump:babel",
2939
"bump:auditfix": "npm audit fix || exit 0",
3040
"bump:babel": "npm run bump:babel:commonjs && npm run bump:babel:esmodules",
@@ -34,7 +44,9 @@
3444
"bump:prod": "if [ `cat package.json | jq -r '(.dependencies // {}) | length'` -ne 0 ]; then npm install --save-exact $(cat package.json | jq -r '(.pinDependencies // {}) as $p | ((.dependencies // {}) | keys) | map(. + \"@\" + ($p[.] // [\"latest\"])[0]) | .[]'); fi",
3545
"postbump": "cat package.json | jq '. + (.dependencies = (((.dependencies // {}) + (.localPeerDependencies // {})) | to_entries | sort_by(.key) | from_entries)) | (.devDependencies = (((.devDependencies // {}) + (.localPeerDevDependencies // {})) | to_entries | sort_by(.key) | from_entries))' > package-temp.json && mv package-temp.json package.json",
3646
"prebump": "cat package.json | jq '(((.localPeerDependencies // {}) | keys | map([\"dependencies\", .])) + ((.localPeerDevDependencies // {}) | keys | map([\"devDependencies\", .]))) as $localPeerPaths | delpaths($localPeerPaths)' > package-temp.json && mv package-temp.json package.json",
37-
"precommit": "eslint ./src/",
47+
"precommit": "npm run precommit:eslint && npm run precommit:typescript",
48+
"precommit:eslint": "eslint ./src/",
49+
"precommit:typescript": "tsc --noEmit --project ./src/tsconfig.json",
3850
"prepack": "cp ../../CHANGELOG.md . && cp ../../LICENSE . && cp ../../README.md .",
3951
"test": "jest"
4052
},
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"declarationDir": "../lib/commonjs-types/",
4+
"module": "CommonJS"
5+
},
6+
"extends": "./tsconfig.declaration.json"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"declarationDir": "../lib/esmodules-types/",
4+
"module": "ESNext"
5+
},
6+
"extends": "./tsconfig.declaration.json"
7+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"compilerOptions": {
33
"declaration": true,
4-
"declarationDir": "../lib/types/",
5-
"emitDeclarationOnly": true
4+
"emitDeclarationOnly": true,
5+
"moduleResolution": "NodeNext"
66
},
77
"extends": "./tsconfig.json"
88
}

0 commit comments

Comments
 (0)