Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 728db1d

Browse files
GoodbyeNJNCopilot
andcommitted
feat: refactor package.json and rolldown config for better organization of entry points
Co-authored-by: Copilot <[email protected]>
1 parent a7cf494 commit 728db1d

2 files changed

Lines changed: 84 additions & 60 deletions

File tree

package.json

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,49 @@
1919
},
2020
"type": "module",
2121
"exports": {
22-
".": {
23-
"types": "./dist/common.d.ts",
24-
"import": "./dist/common.js"
25-
},
2622
"./exec": {
27-
"types": "./dist/exec.d.ts",
28-
"import": "./dist/exec.js"
23+
"types": "./dist/exec/index.d.ts",
24+
"import": "./dist/exec/index.js"
25+
},
26+
"./exec/safe": {
27+
"types": "./dist/exec/safe.d.ts",
28+
"import": "./dist/exec/safe.js"
29+
},
30+
"./fp": {
31+
"types": "./dist/fp/index.d.ts",
32+
"import": "./dist/fp/index.js"
2933
},
3034
"./fs": {
31-
"types": "./dist/fs.d.ts",
32-
"import": "./dist/fs.js"
35+
"types": "./dist/fs/index.d.ts",
36+
"import": "./dist/fs/index.js"
37+
},
38+
"./fs/safe": {
39+
"types": "./dist/fs/safe.d.ts",
40+
"import": "./dist/fs/safe.js"
3341
},
3442
"./glob": {
35-
"types": "./dist/glob.d.ts",
36-
"import": "./dist/glob.js"
43+
"types": "./dist/glob/index.d.ts",
44+
"import": "./dist/glob/index.js"
3745
},
3846
"./json": {
39-
"types": "./dist/json.d.ts",
40-
"import": "./dist/json.js"
47+
"types": "./dist/json/index.d.ts",
48+
"import": "./dist/json/index.js"
49+
},
50+
"./json/safe": {
51+
"types": "./dist/json/safe.d.ts",
52+
"import": "./dist/json/safe.js"
4153
},
42-
"./remeda": {
43-
"types": "./dist/remeda.d.ts",
44-
"import": "./dist/remeda.js"
54+
"./option": {
55+
"types": "./dist/option/index.d.ts",
56+
"import": "./dist/option/index.js"
4557
},
4658
"./result": {
47-
"types": "./dist/result.d.ts",
48-
"import": "./dist/result.js"
59+
"types": "./dist/result/index.d.ts",
60+
"import": "./dist/result/index.js"
61+
},
62+
".": {
63+
"types": "./dist/index.d.ts",
64+
"import": "./dist/index.js"
4965
},
5066
"./types": {
5167
"types": "./dist/types.d.ts"

rolldown.config.ts

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,63 @@
11
import { readFile } from "node:fs/promises";
22

3-
import { omit } from "remeda";
43
import { defineConfig } from "rolldown";
54
import { dts } from "rolldown-plugin-dts";
65

76
import { dependencies } from "./package.json";
87

9-
const input = {
10-
common: "src/common/index.ts",
11-
exec: "src/exec/index.ts",
12-
fs: "src/fs/index.ts",
13-
glob: "src/glob/index.ts",
14-
json: "src/json/index.ts",
15-
remeda: "src/remeda/index.ts",
16-
result: "src/result/index.ts",
17-
types: "src/types/index.ts",
18-
globalTypes: "src/types/global-types.d.ts",
19-
};
20-
21-
export default defineConfig([
22-
{
23-
input: omit(input, ["globalTypes"]),
8+
export default defineConfig({
9+
input: {
10+
"exec/index": "src/exec/unsafe/index.ts",
11+
"exec/safe": "src/exec/safe/index.ts",
12+
"fp/index": "src/fp/index.ts",
13+
"fs/index": "src/fs/unsafe/index.ts",
14+
"fs/safe": "src/fs/safe/index.ts",
15+
"glob/index": "src/glob/index.ts",
16+
"json/index": "src/json/unsafe.ts",
17+
"json/safe": "src/json/safe.ts",
18+
"option/index": "src/option/index.ts",
19+
"result/index": "src/result/index.ts",
20+
index: "src/tools/index.ts",
21+
types: "src/types/index.ts",
22+
},
2423

25-
output: {
26-
dir: "dist",
27-
cleanDir: true,
28-
format: "esm",
29-
hashCharacters: "hex",
30-
chunkFileNames: "chunks/chunk-[hash].js",
31-
comments: {
32-
annotation: true,
33-
jsdoc: false,
34-
legal: false,
35-
},
24+
output: {
25+
dir: "dist",
26+
cleanDir: true,
27+
format: "esm",
28+
hashCharacters: "hex",
29+
chunkFileNames: "chunks/chunk-[hash].js",
30+
comments: {
31+
annotation: true,
32+
jsdoc: false,
33+
legal: false,
3634
},
35+
},
3736

38-
external: Object.keys(dependencies),
39-
platform: "node",
37+
external: Object.keys(dependencies),
38+
platform: "node",
4039

41-
plugins: [
42-
dts(),
43-
{
44-
name: "emit-globals-types",
45-
async buildEnd() {
46-
this.emitFile({
47-
type: "prebuilt-chunk",
48-
fileName: "global-types.d.ts",
49-
code: await readFile(input.globalTypes, "utf-8"),
50-
});
51-
},
40+
plugins: [
41+
dts(),
42+
{
43+
name: "emit-globals-types",
44+
async buildEnd() {
45+
this.emitFile({
46+
type: "prebuilt-chunk",
47+
fileName: "global-types.d.ts",
48+
code: await readFile("src/types/global-types.d.ts", "utf-8"),
49+
});
5250
},
53-
],
54-
},
55-
]);
51+
},
52+
{
53+
name: "delete-types-js",
54+
generateBundle(_, bundle) {
55+
for (const fileName of Object.keys(bundle)) {
56+
if (fileName === "types.js") {
57+
delete bundle[fileName];
58+
}
59+
}
60+
},
61+
},
62+
],
63+
});

0 commit comments

Comments
 (0)