robuild 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -109
- package/dist/_chunks/build-CHtyq9DQ.mjs +2283 -0
- package/dist/_chunks/config-CeOzkcue.d.mts +492 -0
- package/dist/_chunks/package-DgQX21eh.mjs +84 -0
- package/dist/cli.mjs +134 -13
- package/dist/config.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +8 -2
- package/dist/_chunks/build-DuPhfTzX.mjs +0 -563
- package/dist/_chunks/config-BZW4dLYD.d.mts +0 -138
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { build } from "./_chunks/build-
|
|
2
|
+
import { build } from "./_chunks/build-CHtyq9DQ.mjs";
|
|
3
3
|
import { consola } from "consola";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
5
|
import { loadConfig } from "c12";
|
|
@@ -9,21 +9,105 @@ const args = parseArgs({
|
|
|
9
9
|
args: process.argv.slice(2),
|
|
10
10
|
allowPositionals: true,
|
|
11
11
|
options: {
|
|
12
|
-
dir: {
|
|
12
|
+
"dir": {
|
|
13
13
|
type: "string",
|
|
14
14
|
default: "."
|
|
15
15
|
},
|
|
16
|
-
stub: {
|
|
16
|
+
"stub": {
|
|
17
17
|
type: "boolean",
|
|
18
18
|
default: false
|
|
19
19
|
},
|
|
20
|
-
watch: {
|
|
20
|
+
"watch": {
|
|
21
21
|
type: "boolean",
|
|
22
22
|
default: false,
|
|
23
23
|
short: "w"
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"format": {
|
|
26
|
+
type: "string",
|
|
27
|
+
multiple: true
|
|
28
|
+
},
|
|
29
|
+
"platform": { type: "string" },
|
|
30
|
+
"target": { type: "string" },
|
|
31
|
+
"global-name": { type: "string" },
|
|
32
|
+
"clean": {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
default: true
|
|
35
|
+
},
|
|
36
|
+
"no-clean": { type: "boolean" },
|
|
37
|
+
"external": {
|
|
38
|
+
type: "string",
|
|
39
|
+
multiple: true
|
|
40
|
+
},
|
|
41
|
+
"no-external": {
|
|
42
|
+
type: "string",
|
|
43
|
+
multiple: true
|
|
44
|
+
},
|
|
45
|
+
"log-level": { type: "string" },
|
|
46
|
+
"on-success": { type: "string" },
|
|
47
|
+
"fail-on-warn": { type: "boolean" },
|
|
48
|
+
"ignore-watch": {
|
|
49
|
+
type: "string",
|
|
50
|
+
multiple: true
|
|
51
|
+
},
|
|
52
|
+
"from-vite": { type: "boolean" },
|
|
53
|
+
"workspace": { type: "boolean" },
|
|
54
|
+
"filter": {
|
|
55
|
+
type: "string",
|
|
56
|
+
multiple: true
|
|
57
|
+
},
|
|
58
|
+
"generate-exports": { type: "boolean" },
|
|
59
|
+
"cjs-default": { type: "string" },
|
|
60
|
+
"shims": { type: "boolean" },
|
|
61
|
+
"skip-node-modules": { type: "boolean" },
|
|
62
|
+
"unbundle": { type: "boolean" },
|
|
63
|
+
"help": { type: "boolean" },
|
|
64
|
+
"version": { type: "boolean" }
|
|
25
65
|
}
|
|
26
66
|
});
|
|
67
|
+
if (args.values.help) {
|
|
68
|
+
console.log(`
|
|
69
|
+
Usage: robuild [options] [entries...]
|
|
70
|
+
|
|
71
|
+
Options:
|
|
72
|
+
--dir <dir> Working directory (default: ".")
|
|
73
|
+
--stub Generate stub files instead of building
|
|
74
|
+
-w, --watch Enable watch mode
|
|
75
|
+
--format <format> Output format(s): esm, cjs, iife, umd (can be used multiple times)
|
|
76
|
+
--platform <platform> Target platform: browser, node, neutral
|
|
77
|
+
--target <target> Target ES version: es5, es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext
|
|
78
|
+
--global-name <name> Global variable name for IIFE/UMD formats
|
|
79
|
+
--clean Clean output directory before build (default: true)
|
|
80
|
+
--no-clean Disable cleaning output directory
|
|
81
|
+
--external <module> Mark dependencies as external (can be used multiple times)
|
|
82
|
+
--no-external <module> Force bundle dependencies (can be used multiple times)
|
|
83
|
+
--log-level <level> Log level: silent, error, warn, info, verbose (default: info)
|
|
84
|
+
--on-success <command> Command to run after successful build
|
|
85
|
+
--fail-on-warn Fail build on warnings
|
|
86
|
+
--ignore-watch <pattern> Ignore patterns in watch mode (can be used multiple times)
|
|
87
|
+
--from-vite Load configuration from Vite config file
|
|
88
|
+
--workspace Enable workspace mode for monorepo builds
|
|
89
|
+
--filter <pattern> Filter workspace packages by name or path pattern (can be used multiple times)
|
|
90
|
+
--generate-exports Generate package.json exports field
|
|
91
|
+
--cjs-default <mode> CommonJS default export handling: true, false, auto (default: auto)
|
|
92
|
+
--shims Enable CJS/ESM compatibility shims
|
|
93
|
+
--skip-node-modules Skip bundling node_modules dependencies
|
|
94
|
+
--unbundle Preserve file structure without bundling
|
|
95
|
+
--help Show this help message
|
|
96
|
+
--version Show version number
|
|
97
|
+
|
|
98
|
+
Examples:
|
|
99
|
+
robuild src/index.ts # Bundle single file
|
|
100
|
+
robuild src/index.ts --format esm cjs # Multiple formats
|
|
101
|
+
robuild src/ --watch # Transform directory in watch mode
|
|
102
|
+
robuild --help # Show help
|
|
103
|
+
`);
|
|
104
|
+
process.exit(0);
|
|
105
|
+
}
|
|
106
|
+
if (args.values.version) {
|
|
107
|
+
const pkg = await import("../package.json", { with: { type: "json" } });
|
|
108
|
+
console.log(pkg.default.version);
|
|
109
|
+
process.exit(0);
|
|
110
|
+
}
|
|
27
111
|
const { config = {} } = await loadConfig({
|
|
28
112
|
name: "robuild",
|
|
29
113
|
configFile: "build.config",
|
|
@@ -33,15 +117,34 @@ const rawEntries = args.positionals.length > 0 ? args.positionals : config.entri
|
|
|
33
117
|
const entries = rawEntries.map((entry) => {
|
|
34
118
|
if (typeof entry === "string") {
|
|
35
119
|
const [input, outDir] = entry.split(":");
|
|
36
|
-
|
|
120
|
+
if (input.endsWith("/")) return {
|
|
37
121
|
type: "transform",
|
|
38
122
|
input,
|
|
39
123
|
outDir
|
|
40
|
-
} : {
|
|
41
|
-
type: "bundle",
|
|
42
|
-
input: input.split(","),
|
|
43
|
-
outDir
|
|
44
124
|
};
|
|
125
|
+
else {
|
|
126
|
+
const baseEntry = {
|
|
127
|
+
type: "bundle",
|
|
128
|
+
input: input.split(","),
|
|
129
|
+
outDir
|
|
130
|
+
};
|
|
131
|
+
if (args.values.format) baseEntry.format = args.values.format;
|
|
132
|
+
if (args.values.platform) baseEntry.platform = args.values.platform;
|
|
133
|
+
if (args.values.target) baseEntry.target = args.values.target;
|
|
134
|
+
if (args.values["global-name"]) baseEntry.globalName = args.values["global-name"];
|
|
135
|
+
if (args.values["no-clean"]) baseEntry.clean = false;
|
|
136
|
+
else if (args.values.clean !== void 0) baseEntry.clean = args.values.clean;
|
|
137
|
+
if (args.values.external) baseEntry.external = args.values.external.map((ext) => ext.startsWith("/") && ext.endsWith("/") ? new RegExp(ext.slice(1, -1)) : ext);
|
|
138
|
+
if (args.values["no-external"]) baseEntry.noExternal = args.values["no-external"].map((ext) => ext.startsWith("/") && ext.endsWith("/") ? new RegExp(ext.slice(1, -1)) : ext);
|
|
139
|
+
if (args.values["cjs-default"]) {
|
|
140
|
+
const mode = args.values["cjs-default"];
|
|
141
|
+
baseEntry.cjsDefault = mode === "true" ? true : mode === "false" ? false : mode;
|
|
142
|
+
}
|
|
143
|
+
if (args.values.shims) baseEntry.shims = true;
|
|
144
|
+
if (args.values["skip-node-modules"]) baseEntry.skipNodeModules = true;
|
|
145
|
+
if (args.values.unbundle) baseEntry.unbundle = true;
|
|
146
|
+
return baseEntry;
|
|
147
|
+
}
|
|
45
148
|
}
|
|
46
149
|
return entry;
|
|
47
150
|
});
|
|
@@ -50,14 +153,32 @@ if (rawEntries.length === 0) {
|
|
|
50
153
|
consola.error("No build entries specified.");
|
|
51
154
|
process.exit(1);
|
|
52
155
|
}
|
|
53
|
-
|
|
156
|
+
const buildConfig = {
|
|
54
157
|
cwd: args.values.dir,
|
|
55
158
|
...config,
|
|
56
159
|
entries,
|
|
57
160
|
watch: args.values.watch ? {
|
|
58
161
|
enabled: true,
|
|
59
|
-
...config.watch
|
|
162
|
+
...config.watch,
|
|
163
|
+
...args.values["ignore-watch"] ? { exclude: [...config.watch?.exclude || [], ...args.values["ignore-watch"]] } : {}
|
|
60
164
|
} : config.watch
|
|
61
|
-
}
|
|
165
|
+
};
|
|
166
|
+
if (args.values["log-level"]) buildConfig.logLevel = args.values["log-level"];
|
|
167
|
+
if (args.values["on-success"]) buildConfig.onSuccess = args.values["on-success"];
|
|
168
|
+
if (args.values["fail-on-warn"]) buildConfig.failOnWarn = true;
|
|
169
|
+
if (args.values["ignore-watch"]) buildConfig.ignoreWatch = args.values["ignore-watch"];
|
|
170
|
+
if (args.values["from-vite"]) buildConfig.fromVite = true;
|
|
171
|
+
if (args.values.workspace) buildConfig.workspace = {
|
|
172
|
+
packages: ["packages/*", "apps/*"],
|
|
173
|
+
...config.workspace
|
|
174
|
+
};
|
|
175
|
+
if (args.values.filter) buildConfig.filter = args.values.filter;
|
|
176
|
+
if (args.values["generate-exports"]) buildConfig.exports = {
|
|
177
|
+
enabled: true,
|
|
178
|
+
includeTypes: true,
|
|
179
|
+
autoUpdate: true,
|
|
180
|
+
...config.exports
|
|
181
|
+
};
|
|
182
|
+
await build(buildConfig);
|
|
62
183
|
|
|
63
184
|
//#endregion
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { defineConfig } from "./_chunks/config-
|
|
1
|
+
import { defineConfig } from "./_chunks/config-CeOzkcue.mjs";
|
|
2
2
|
export { defineConfig };
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "robuild",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.8",
|
|
5
5
|
"packageManager": "pnpm@10.11.1",
|
|
6
6
|
"description": "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"robuild": "esno src/cli.ts",
|
|
25
25
|
"prepack": "pnpm build",
|
|
26
26
|
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
|
27
|
-
"test": "
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
28
29
|
"test:types": "tsc --noEmit --skipLibCheck",
|
|
29
30
|
"docs:dev": "vitepress dev docs",
|
|
30
31
|
"docs:build": "vitepress build docs",
|
|
@@ -32,11 +33,15 @@
|
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"c12": "^3.0.4",
|
|
36
|
+
"cac": "^6.7.14",
|
|
35
37
|
"chokidar": "^4.0.3",
|
|
36
38
|
"consola": "^3.4.2",
|
|
37
39
|
"defu": "^6.1.4",
|
|
38
40
|
"exsolve": "^1.0.5",
|
|
41
|
+
"glob": "^11.0.3",
|
|
42
|
+
"js-yaml": "^4.1.0",
|
|
39
43
|
"magic-string": "^0.30.17",
|
|
44
|
+
"minimatch": "^10.0.3",
|
|
40
45
|
"oxc-minify": "^0.89.0",
|
|
41
46
|
"oxc-parser": "^0.89.0",
|
|
42
47
|
"oxc-transform": "^0.89.0",
|
|
@@ -48,6 +53,7 @@
|
|
|
48
53
|
},
|
|
49
54
|
"devDependencies": {
|
|
50
55
|
"@antfu/eslint-config": "^5.3.0",
|
|
56
|
+
"@types/js-yaml": "^4.0.9",
|
|
51
57
|
"@types/node": "^24.4.0",
|
|
52
58
|
"@vitest/coverage-v8": "^3.2.2",
|
|
53
59
|
"automd": "^0.4.0",
|