-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpub.config.ts
134 lines (110 loc) · 3.07 KB
/
pub.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import { resolve, dirname } from "pathe";
import { fileURLToPath } from "url";
/**
* PublishConfig interface describes the shape of the entire configuration.
*/
export type PublishConfig = {
/**
* The bump mode for versioning, used if the user didn't provide --bump:
* - "autoPatch" automatically increments patch version (1.2.3 -> 1.2.4)
* - "autoMinor" automatically increments minor version (1.2.3 -> 1.3.0)
* - "autoMajor" automatically increments major version (1.2.3 -> 2.0.0)
*/
bump: "autoPatch" | "autoMinor" | "autoMajor";
/**
* If `true`, enables more detailed log output.
*/
verbose: boolean;
/**
* If `true`, do a "publish --dry-run" instead of a real publish.
*/
dryRun: boolean;
/**
* If `true`, build only but skip publishing altogether.
* It also prevents dist folders from being removed.
*/
pausePublish: boolean;
/**
* Where to publish: "npm", "jsr", or "npm-jsr".
* If something else, the script won't publish anywhere, just builds.
*/
registry: "npm" | "jsr" | "npm-jsr";
/**
* Where to emit the NPM build artifacts.
*/
npmDistDir: string;
/**
* Where to emit the JSR build artifacts.
*/
jsrDistDir: string;
/**
* Where the source code resides (default "src" folder).
*/
rootSrcDir: string;
/**
* The bundler to use for building the NPM-optimized package.
*/
builderNpm: "bun" | "copy" | "mkdist" | "rollup" | "untyped";
/**
* The bundler to use for building the JSR-optimized package.
*/
builderJsr: "bun" | "copy" | "mkdist" | "rollup" | "untyped";
/**
* If `true`, minify the build output.
*/
shouldMinify: boolean;
/**
* If `true`, split the build output into multiple chunks.
*/
splitting: boolean;
/**
* Type of sourcemap to generate. Can be `true`, `false`, `"linked"`, `"inline"`, or `"external"`.
*/
sourcemap: boolean | "linked" | "inline" | "external";
/**
* Build target environment. Typically "node" or "browser".
*/
target: "node" | "bun" | "browser";
/**
* Output format. Typically "esm" or "cjs".
*/
format: "esm" | "cjs" | "iife";
/**
* Public path for the output.
*/
publicPath: string;
/**
* Tracks if an error occurred after a successful version bump.
* Used to prevent re-bumping on retry if the error was earlier.
*/
disableBump: boolean;
};
const CURRENT_DIR = dirname(fileURLToPath(import.meta.url));
/**
* Default configuration for the publishing script.
*/
const pubConfig: PublishConfig = {
// Registry configuration
registry: "npm-jsr",
// Bumping configuration
bump: "autoPatch",
disableBump: false,
// Behavior toggles
pausePublish: false,
verbose: false,
dryRun: false,
// Output directories
npmDistDir: resolve(CURRENT_DIR, "dist-npm"),
jsrDistDir: resolve(CURRENT_DIR, "dist-jsr"),
rootSrcDir: resolve(CURRENT_DIR, "src"),
// Build configuration
builderNpm: "mkdist",
builderJsr: "copy",
shouldMinify: true,
splitting: false,
sourcemap: "linked",
publicPath: "/",
target: "node",
format: "esm",
};
export default pubConfig;