Skip to content

Commit 8b873cd

Browse files
authored
Merge pull request #563 from thebuilder/fix/correct-exports-field
2 parents 83a5232 + 88058e1 commit 8b873cd

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"main": "./dist/react-intersection-observer.js",
77
"module": "./dist/react-intersection-observer.mjs",
88
"exports": {
9-
"require": "./dist/react-intersection-observer.js",
10-
"default": "./dist/react-intersection-observer.modern.mjs",
11-
"test-utils": "./dist/test-utils.js"
9+
"./test-utils": "./test-utils.js",
10+
".": {
11+
"import": "./react-intersection-observer.modern.mjs",
12+
"require": "./react-intersection-observer.js"
13+
}
1214
},
1315
"unpkg": "./dist/react-intersection-observer.umd.js",
1416
"typings": "./dist/index.d.ts",

scripts/build-copy.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ fields.forEach((key) => {
4242
if (typeof pck[key] === 'object') {
4343
const keys = Object.keys(pck[key]);
4444
keys.forEach((subkey) => {
45-
pck[key][subkey] = pck[key][subkey]?.replace('./dist/', './');
45+
if (typeof pck[key][subkey] === 'string') {
46+
pck[key][subkey] = pck[key][subkey]?.replace('./dist/', './');
47+
} else if (typeof pck[key][subkey] === 'object') {
48+
const sub = pck[key][subkey];
49+
const subkeys = Object.keys(sub);
50+
subkeys.forEach((subsubkey) => {
51+
if (typeof sub[subsubkey] === 'string') {
52+
sub[subsubkey] = sub[subsubkey]?.replace('./dist/', './');
53+
}
54+
});
55+
}
4656
});
4757
} else {
4858
pck[key] = pck[key]?.replace('./dist/', './');

0 commit comments

Comments
 (0)