Skip to content

Commit a925aa7

Browse files
thomasballingerConvex, Inc.
authored andcommitted
Simplify internal types (#30190)
Simplify internal types setup by adding an export condition for them. GitOrigin-RevId: 10224f310264de74bf437e8ffe926fd08bf82811
1 parent 6577d59 commit a925aa7

File tree

3 files changed

+83
-23
lines changed

3 files changed

+83
-23
lines changed

.npmignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ dist/internal-types/test
1616
dist/types/test
1717
test_fixtures
1818
src/test
19-
custom-vitest-environment
19+
custom-vitest-environment.ts
20+
vitest.config.js
2021

2122
.eslintrc.*
2223
.prettierignore
@@ -30,9 +31,10 @@ build.py
3031
build.cjs
3132
tmpPackage*
3233
tmpDist*
33-
api-extractor-configs/temp/
34+
api-extractor-configs/
3435
*.log
3536
.knip.json
37+
.github
3638

3739
# rush output
3840
*.chunks.jsonl

package.json

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,91 +16,139 @@
1616
"exports": {
1717
".": {
1818
"require": {
19-
"types": "./dist/internal-cjs-types/index.d.ts",
19+
"convex-internal-types": {
20+
"types": "./dist/internal-cjs-types/index.d.ts"
21+
},
22+
"types": "./dist/cjs-types/index.d.ts",
2023
"require": "./dist/cjs/index.js"
2124
},
2225
"import": {
23-
"types": "./dist/internal-esm-types/index.d.ts",
26+
"convex-internal-types": {
27+
"types": "./dist/internal-esm-types/index.d.ts"
28+
},
29+
"types": "./dist/esm-types/index.d.ts",
2430
"import": "./dist/esm/index.js"
2531
}
2632
},
2733
"./server": {
2834
"require": {
29-
"types": "./dist/internal-cjs-types/server/index.d.ts",
35+
"convex-internal-types": {
36+
"types": "./dist/internal-cjs-types/server/index.d.ts"
37+
},
38+
"types": "./dist/cjs-types/server/index.d.ts",
3039
"require": "./dist/cjs/server/index.js"
3140
},
3241
"import": {
33-
"types": "./dist/internal-esm-types/server/index.d.ts",
42+
"convex-internal-types": {
43+
"types": "./dist/internal-esm-types/server/index.d.ts"
44+
},
45+
"types": "./dist/esm-types/server/index.d.ts",
3446
"import": "./dist/esm/server/index.js"
3547
}
3648
},
3749
"./react": {
3850
"require": {
39-
"types": "./dist/internal-cjs-types/react/index.d.ts",
51+
"convex-internal-types": {
52+
"types": "./dist/internal-cjs-types/react/index.d.ts"
53+
},
54+
"types": "./dist/cjs-types/react/index.d.ts",
4055
"require": "./dist/cjs/react/index.js"
4156
},
4257
"import": {
43-
"types": "./dist/internal-esm-types/react/index.d.ts",
58+
"convex-internal-types": {
59+
"types": "./dist/internal-esm-types/react/index.d.ts"
60+
},
61+
"types": "./dist/esm-types/react/index.d.ts",
4462
"import": "./dist/esm/react/index.js"
4563
}
4664
},
4765
"./react-auth0": {
4866
"require": {
49-
"types": "./dist/internal-cjs-types/react-auth0/index.d.ts",
67+
"convex-internal-types": {
68+
"types": "./dist/internal-cjs-types/react-auth0/index.d.ts"
69+
},
70+
"types": "./dist/cjs-types/react-auth0/index.d.ts",
5071
"require": "./dist/cjs/react-auth0/index.js"
5172
},
5273
"import": {
53-
"types": "./dist/internal-esm-types/react-auth0/index.d.ts",
74+
"convex-internal-types": {
75+
"types": "./dist/internal-esm-types/react-auth0/index.d.ts"
76+
},
77+
"types": "./dist/esm-types/react-auth0/index.d.ts",
5478
"import": "./dist/esm/react-auth0/index.js"
5579
}
5680
},
5781
"./react-clerk": {
5882
"require": {
59-
"types": "./dist/internal-cjs-types/react-clerk/index.d.ts",
83+
"convex-internal-types": {
84+
"types": "./dist/internal-cjs-types/react-clerk/index.d.ts"
85+
},
86+
"types": "./dist/cjs-types/react-clerk/index.d.ts",
6087
"require": "./dist/cjs/react-clerk/index.js"
6188
},
6289
"import": {
63-
"types": "./dist/internal-esm-types/react-clerk/index.d.ts",
90+
"convex-internal-types": {
91+
"types": "./dist/internal-esm-types/react-clerk/index.d.ts"
92+
},
93+
"types": "./dist/esm-types/react-clerk/index.d.ts",
6494
"import": "./dist/esm/react-clerk/index.js"
6595
}
6696
},
6797
"./nextjs": {
6898
"require": {
69-
"types": "./dist/internal-cjs-types/nextjs/index.d.ts",
99+
"convex-internal-types": {
100+
"types": "./dist/internal-cjs-types/nextjs/index.d.ts"
101+
},
102+
"types": "./dist/cjs-types/nextjs/index.d.ts",
70103
"require": "./dist/cjs/nextjs/index.js"
71104
},
72105
"import": {
73-
"types": "./dist/internal-esm-types/nextjs/index.d.ts",
106+
"convex-internal-types": {
107+
"types": "./dist/internal-esm-types/nextjs/index.d.ts"
108+
},
109+
"types": "./dist/esm-types/nextjs/index.d.ts",
74110
"import": "./dist/esm/nextjs/index.js"
75111
}
76112
},
77113
"./browser": {
78114
"require": {
79-
"types": "./dist/internal-cjs-types/browser/index.d.ts",
115+
"convex-internal-types": {
116+
"types": "./dist/internal-cjs-types/browser/index.d.ts"
117+
},
118+
"types": "./dist/cjs-types/browser/index.d.ts",
80119
"node": "./dist/cjs/browser/index-node.js",
81120
"require": "./dist/cjs/browser/index.js"
82121
},
83122
"import": {
84-
"types": "./dist/internal-esm-types/browser/index.d.ts",
123+
"convex-internal-types": {
124+
"types": "./dist/internal-esm-types/browser/index.d.ts"
125+
},
126+
"types": "./dist/esm-types/browser/index.d.ts",
85127
"node": "./dist/esm/browser/index-node.js",
86128
"import": "./dist/esm/browser/index.js"
87129
}
88130
},
89131
"./values": {
90132
"require": {
91-
"types": "./dist/internal-cjs-types/values/index.d.ts",
133+
"convex-internal-types": {
134+
"types": "./dist/internal-cjs-types/values/index.d.ts"
135+
},
136+
"types": "./dist/cjs-types/values/index.d.ts",
92137
"require": "./dist/cjs/values/index.js"
93138
},
94139
"import": {
95-
"types": "./dist/internal-esm-types/values/index.d.ts",
140+
"convex-internal-types": {
141+
"types": "./dist/internal-esm-types/values/index.d.ts"
142+
},
143+
"types": "./dist/esm-types/values/index.d.ts",
96144
"import": "./dist/esm/values/index.js"
97145
}
98146
},
99147
"./package.json": "./package.json"
100148
},
101149
"@comment typesVersions": [
102-
"This type field in exports is only supported with moduleResolution",
103-
"set to node16 or nodenext, which are not yet widely used. "
150+
"Thi types field in exports is only supported with moduleResolution",
151+
"set to node16 or nodenext so typesVersions is still useful."
104152
],
105153
"typesVersions": {
106154
"*": {

scripts/postpack.mjs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ console.log("modifying package.json");
2525
let packageJson = JSON.parse(
2626
fs.readFileSync(path.join(tmpPackage, "package.json")),
2727
);
28-
pointToPublic(packageJson.exports);
28+
removeInternal(packageJson.exports);
2929
pointToPublic(packageJson.typesVersions);
3030

3131
console.log("removing dev-only ts-node CLI script");
@@ -56,8 +56,6 @@ fs.rmSync(path.join(tmpPackage, "dist", "internal-esm-types"), {
5656
recursive: true,
5757
});
5858

59-
// Remove a few more @internal types
60-
console.log("modifying types to remove remaining @internal types");
6159
auditInternal(tmpPackage);
6260

6361
run("tar", "czvf", tarball, "-C", tmpDir, "package");
@@ -75,6 +73,18 @@ function getOnlyTarball(dirname) {
7573
return path.join(dirname, tarballs[0]);
7674
}
7775

76+
function removeInternal(obj) {
77+
for (const key of Object.keys(obj)) {
78+
let value = obj[key];
79+
if (key === "convex-internal-types") {
80+
delete obj[key];
81+
}
82+
if (typeof value === "object") {
83+
removeInternal(value);
84+
}
85+
}
86+
}
87+
7888
function pointToPublic(obj) {
7989
for (const key of Object.keys(obj)) {
8090
let value = obj[key];

0 commit comments

Comments
 (0)