robuild 0.1.4 → 0.1.6

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 CHANGED
@@ -97,21 +97,17 @@ Visit our documentation site for detailed guides, API reference, and examples.
97
97
  <!-- coverage-start -->
98
98
  | File | Stmts | Branch | Funcs | Lines |
99
99
  |------|-------|--------|-------|-------|
100
- | **All files** | **30.90%** | **64.07%** | **51.02%** | **30.90%** |
101
- | src/build.ts | 70.93% | 55.56% | 100.00% | 70.93% |
102
- | src/builders | 58.78% | 57.38% | 41.18% | 58.78% |
103
- | src/config | 19.62% | 65.00% | 46.67% | 19.62% |
104
- | src/config.ts | 0.00% | 100.00% | 100.00% | 0.00% |
105
- | src/core | 63.86% | 90.91% | 50.00% | 63.86% |
106
- | src/deprecated | 0.00% | 100.00% | 100.00% | 0.00% |
107
- | src/index.ts | 0.00% | 0.00% | 0.00% | 0.00% |
108
- | src/plugins | 13.62% | 68.75% | 47.37% | 13.62% |
109
- | src/plugins/builtin | 7.65% | 92.31% | 23.33% | 7.65% |
110
- | src/plugins/extras | 0.00% | 100.00% | 100.00% | 0.00% |
111
- | src/transforms | 16.94% | 78.95% | 66.67% | 16.94% |
112
- | src/types.ts | 0.00% | 100.00% | 100.00% | 0.00% |
113
- | src/utils | 75.87% | 62.50% | 77.27% | 75.87% |
114
- | src/watch.ts | 4.24% | 0.00% | 0.00% | 4.24% |
100
+ | **All files** | **86.44%** | **80.12%** | **92.94%** | **86.32%** |
101
+ | src/build.ts | 84.15% | 67.74% | 100.00% | 83.54% |
102
+ | src/builders | 89.89% | 82.80% | 96.43% | 89.89% |
103
+ | src/config | 85.38% | 67.96% | 100.00% | 84.92% |
104
+ | src/core | 74.19% | 57.14% | 68.42% | 74.19% |
105
+ | src/plugins | 97.50% | 95.37% | 97.37% | 97.46% |
106
+ | src/plugins/builtin | 88.15% | 84.92% | 95.59% | 88.12% |
107
+ | src/plugins/extras | 96.55% | 100.00% | 100.00% | 96.30% |
108
+ | src/transforms | 71.43% | 63.77% | 81.82% | 71.27% |
109
+ | src/utils | 88.29% | 85.44% | 100.00% | 88.29% |
110
+ | src/watch.ts | 81.48% | 81.82% | 57.14% | 81.48% |
115
111
  <!-- coverage-end -->
116
112
 
117
113
  Run coverage locally:
@@ -132,5 +128,5 @@ pnpm test:coverage
132
128
  [bundle-href]: https://bundlephobia.com/result?p=robuild
133
129
  [license-src]: https://img.shields.io/github/license/Sunny-117/robuild.svg?style=flat&colorA=080f12&colorB=1fa669
134
130
  [license-href]: https://github.com/Sunny-117/robuild/blob/main/LICENSE
135
- [coverage-src]: https://img.shields.io/badge/coverage-30.9%25-orange?style=flat&colorA=080f12
131
+ [coverage-src]: https://img.shields.io/badge/coverage-86.4%25-brightgreen?style=flat&colorA=080f12
136
132
  [coverage-href]: #test-coverage
@@ -0,0 +1,3 @@
1
+ import { n as performBuild, t as build } from "./build-rD4AllYV.mjs";
2
+
3
+ export { performBuild };
@@ -3,7 +3,7 @@ import { builtinModules } from "node:module";
3
3
  import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
4
4
  import { colors } from "consola/utils";
5
5
  import prettyBytes from "pretty-bytes";
6
- import { cp, mkdir, readFile, readdir, rm, symlink, writeFile } from "node:fs/promises";
6
+ import { cp, mkdir, readFile, readdir, rm, symlink, unlink, writeFile } from "node:fs/promises";
7
7
  import { resolveModulePath } from "exsolve";
8
8
  import { parseSync } from "oxc-parser";
9
9
  import { rolldown, watch } from "rolldown";
@@ -879,6 +879,54 @@ function createSkipNodeModulesPlugin(options) {
879
879
  };
880
880
  }
881
881
 
882
+ //#endregion
883
+ //#region src/plugins/builtin/wasm.ts
884
+ /**
885
+ * Default WASM configuration
886
+ */
887
+ const DEFAULT_WASM_CONFIG = {
888
+ enabled: true,
889
+ maxFileSize: 14 * 1024,
890
+ fileName: "[hash][extname]",
891
+ publicPath: "",
892
+ targetEnv: "auto"
893
+ };
894
+ /**
895
+ * Normalize WASM configuration
896
+ */
897
+ function normalizeWasmConfig(config) {
898
+ if (!config) return null;
899
+ if (config === true) return { ...DEFAULT_WASM_CONFIG };
900
+ if (!config.enabled) return null;
901
+ return {
902
+ ...DEFAULT_WASM_CONFIG,
903
+ ...config
904
+ };
905
+ }
906
+ /**
907
+ * Create WASM plugin for robuild
908
+ *
909
+ * This is a wrapper that dynamically imports rolldown-plugin-wasm
910
+ * to avoid making it a required dependency.
911
+ *
912
+ * @param config WASM configuration options
913
+ * @returns Rolldown plugin for WASM support
914
+ */
915
+ async function createWasmPlugin(config) {
916
+ try {
917
+ const { wasm } = await import("./dist-fY5yKI94.mjs");
918
+ return wasm({
919
+ maxFileSize: config.maxFileSize,
920
+ fileName: config.fileName,
921
+ publicPath: config.publicPath,
922
+ targetEnv: config.targetEnv
923
+ });
924
+ } catch (error) {
925
+ if (error.code === "ERR_MODULE_NOT_FOUND") return null;
926
+ throw error;
927
+ }
928
+ }
929
+
882
930
  //#endregion
883
931
  //#region src/transforms/banner.ts
884
932
  /**
@@ -995,6 +1043,8 @@ async function rolldownBuild(ctx, entry, hooks, config) {
995
1043
  if (entry.dtsOnly) {
996
1044
  logger.info("Running in dtsOnly mode - only generating declaration files");
997
1045
  entry.dts = entry.dts === false ? true : entry.dts || true;
1046
+ formats.length = 0;
1047
+ formats.push("esm");
998
1048
  }
999
1049
  if (entry.stub) {
1000
1050
  for (const [distName, srcPath] of Object.entries(inputs)) {
@@ -1046,6 +1096,15 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1046
1096
  resolveId: skipPlugin.resolveId
1047
1097
  });
1048
1098
  }
1099
+ const wasmConfig = normalizeWasmConfig(entry.wasm ?? config?.wasm);
1100
+ if (wasmConfig) {
1101
+ const wasmPlugin = await createWasmPlugin(wasmConfig);
1102
+ if (wasmPlugin) rolldownPlugins.push(wasmPlugin);
1103
+ else {
1104
+ logger.warn("WASM support is enabled but rolldown-plugin-wasm is not installed.");
1105
+ logger.warn("Install it with: pnpm add -D rolldown-plugin-wasm");
1106
+ }
1107
+ }
1049
1108
  rolldownPlugins.push(...pluginManager.getRolldownPlugins());
1050
1109
  const moduleTypes = {};
1051
1110
  if (entry.loaders) for (const [ext, config] of Object.entries(entry.loaders)) moduleTypes[ext] = config.loader;
@@ -1083,7 +1142,8 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1083
1142
  const res = await rolldown(formatConfig);
1084
1143
  const formatOutDir = fullOutDir;
1085
1144
  let entryFileName = `[name]${extension}`;
1086
- if (isMultiFormat) {
1145
+ if (entry.fileName) entryFileName = entry.fileName;
1146
+ else if (isMultiFormat) {
1087
1147
  if (format === "cjs" || format === "commonjs") entryFileName = `[name].cjs`;
1088
1148
  else if (format === "es" || format === "esm" || format === "module") entryFileName = `[name].mjs`;
1089
1149
  else if (format === "iife" || format === "umd") entryFileName = `[name].js`;
@@ -1155,6 +1215,22 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1155
1215
  });
1156
1216
  }
1157
1217
  }
1218
+ if (entry.dtsOnly) {
1219
+ const jsFilesToDelete = [];
1220
+ for (const outputEntry of allOutputEntries) {
1221
+ const filePath = filePathMap.get(outputEntry.name);
1222
+ if (filePath && !filePath.endsWith(".d.ts") && !filePath.endsWith(".d.mts") && !filePath.endsWith(".d.cts")) jsFilesToDelete.push(filePath);
1223
+ }
1224
+ for (const filePath of jsFilesToDelete) try {
1225
+ await unlink(filePath);
1226
+ try {
1227
+ await unlink(`${filePath}.map`);
1228
+ } catch {}
1229
+ } catch {}
1230
+ const dtsEntries = allOutputEntries.filter((o) => o.name.endsWith(".d.ts") || o.name.endsWith(".d.mts") || o.name.endsWith(".d.cts"));
1231
+ allOutputEntries.length = 0;
1232
+ allOutputEntries.push(...dtsEntries);
1233
+ }
1158
1234
  if (entry.copy) await copyFiles(ctx.pkgDir, fullOutDir, entry.copy);
1159
1235
  await pluginManager.executeRobuildBuildEnd({ allOutputEntries });
1160
1236
  logger.log(`\n${allOutputEntries.map((o) => [
@@ -1206,7 +1282,8 @@ function normalizeBundleInputs(input, ctx) {
1206
1282
  * Unbundle mode: preserve file structure without bundling
1207
1283
  */
1208
1284
  async function unbundleTransform(ctx, entry) {
1209
- await processDirectoryUnbundled(isAbsolute(entry.input) ? entry.input : join(ctx.pkgDir, entry.input), join(ctx.pkgDir, entry.outDir || "dist"), entry);
1285
+ const inputDir = entry.input;
1286
+ await processDirectoryUnbundled(inputDir, entry.outDir || join(ctx.pkgDir, "dist"), entry);
1210
1287
  }
1211
1288
  /**
1212
1289
  * Process directory in unbundle mode
@@ -1763,7 +1840,7 @@ function createBuildResult(entries, startTime) {
1763
1840
  * Perform watch build using rolldown's built-in watch mode
1764
1841
  */
1765
1842
  async function performWatchBuild(config, ctx, startTime) {
1766
- const { performBuild } = await import("./build-BY2-r2pO.mjs");
1843
+ const { performBuild } = await import("./build-CelwCERM.mjs");
1767
1844
  await performBuild(config, ctx, startTime);
1768
1845
  const bundleEntries = (config.entries || []).filter((entry) => {
1769
1846
  if (typeof entry === "string") return !entry.endsWith("/");
@@ -0,0 +1,7 @@
1
+ //#region src/config.ts
2
+ function defineConfig(config) {
3
+ return config;
4
+ }
5
+
6
+ //#endregion
7
+ export { defineConfig as t };
@@ -0,0 +1,247 @@
1
+ import path from "node:path";
2
+ import { readFile } from "node:fs/promises";
3
+ import { createHash } from "node:crypto";
4
+ import { Buffer } from "node:buffer";
5
+ import { exactRegex, id, include, or } from "rolldown/filter";
6
+
7
+ //#region node_modules/.pnpm/rolldown-plugin-wasm@0.2.1_rolldown@1.0.0-rc.5/node_modules/rolldown-plugin-wasm/dist/index.mjs
8
+ const HELPERS_ID = "\0wasm-helpers.js";
9
+ const nodeFilePath = `
10
+ const { readFile } = process.getBuiltinModule('fs/promises')
11
+ const path = process.getBuiltinModule('path')
12
+
13
+ return readFile(path.resolve(import.meta.dirname, filepath)).then(
14
+ (buffer) => instantiate(buffer, imports)
15
+ )
16
+ `;
17
+ const nodeDecode = `
18
+ const { Buffer } = process.getBuiltinModule('buffer')
19
+ buf = Buffer.from(src, 'base64')
20
+ `;
21
+ const browserFilePath = `
22
+ return instantiate(fetch(filepath), imports, true);
23
+ `;
24
+ const browserDecode = `
25
+ const raw = globalThis.atob(src)
26
+ const len = raw.length
27
+ buf = new Uint8Array(new ArrayBuffer(len))
28
+ for (let i = 0; i < len; i++) {
29
+ buf[i] = raw.charCodeAt(i)
30
+ }
31
+ `;
32
+ const autoModule = `
33
+ let buf = null
34
+ const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null
35
+
36
+ if (filepath && isNode) {
37
+ ${nodeFilePath}
38
+ } else if (filepath) {
39
+ ${browserFilePath}
40
+ }
41
+
42
+ if (isNode) {
43
+ ${nodeDecode}
44
+ } else {
45
+ ${browserDecode}
46
+ }
47
+ `;
48
+ const nodeModule = `
49
+ let buf = null
50
+ if (filepath) {
51
+ ${nodeFilePath}
52
+ }
53
+
54
+ ${nodeDecode}
55
+ `;
56
+ const browserModule = `
57
+ let buf = null
58
+ if (filepath) {
59
+ ${browserFilePath}
60
+ }
61
+
62
+ ${browserDecode}
63
+ `;
64
+ const autoInlineModule = `
65
+ let buf = null
66
+ const isNode = typeof process !== 'undefined' && process.versions != null && process.versions.node != null
67
+ if (isNode) {
68
+ ${nodeDecode}
69
+ } else {
70
+ ${browserDecode}
71
+ }
72
+ `;
73
+ function envModule(env) {
74
+ switch (env) {
75
+ case "auto": return autoModule;
76
+ case "auto-inline": return autoInlineModule;
77
+ case "browser": return browserModule;
78
+ case "node": return nodeModule;
79
+ default: return null;
80
+ }
81
+ }
82
+ const getHelpersModule = (env) => `
83
+ export function loadWasmModule(sync, filepath, src, imports) {
84
+ function instantiate(source, imports, stream) {
85
+ const instantiate = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate;
86
+ return instantiate(source, imports).then(({ instance }) => instance)
87
+ }
88
+
89
+ ${envModule(env)}
90
+
91
+ if (sync) {
92
+ const mod = new WebAssembly.Module(buf)
93
+ return new WebAssembly.Instance(mod, imports)
94
+ } else {
95
+ return instantiate(buf, imports)
96
+ }
97
+ }
98
+ `;
99
+ function codegenSimpleObject(obj) {
100
+ return `{ ${obj.map(({ key, value }) => {
101
+ return `${key}: ${typeof value === "string" ? value : codegenSimpleObject(value)}`;
102
+ }).join(",\n")} }`;
103
+ }
104
+ async function parseWasm(buffer) {
105
+ try {
106
+ const wasmModule = await WebAssembly.compile(buffer);
107
+ return {
108
+ imports: Object.entries(WebAssembly.Module.imports(wasmModule).reduce((result, item) => ({
109
+ ...result,
110
+ [item.module]: [...result[item.module] || [], item.name]
111
+ }), {})),
112
+ exports: WebAssembly.Module.exports(wasmModule).map((item) => item.name)
113
+ };
114
+ } catch (error) {
115
+ throw new Error(`Failed to parse WASM file: ${error.message}`, { cause: error });
116
+ }
117
+ }
118
+ function parseId(url) {
119
+ const [file, query] = url.split("?");
120
+ return [
121
+ file,
122
+ query,
123
+ new URLSearchParams(query)
124
+ ];
125
+ }
126
+ function wasm(options = {}) {
127
+ let { maxFileSize = 14 * 1024, publicPath = "", targetEnv, fileName = "[hash][extname]" } = options;
128
+ const copies = Object.create(null);
129
+ return {
130
+ name: "wasm",
131
+ buildStart(options$1) {
132
+ if (targetEnv == null) switch (options$1.platform) {
133
+ case "browser":
134
+ targetEnv = "browser";
135
+ break;
136
+ case "node":
137
+ targetEnv = "node";
138
+ break;
139
+ default: targetEnv = "auto";
140
+ }
141
+ },
142
+ resolveId: {
143
+ filter: [include(or(id(exactRegex(HELPERS_ID)), id(/\.wasm$/, { cleanUrl: true })))],
144
+ async handler(id$1, ...args) {
145
+ if (id$1 === HELPERS_ID) return id$1;
146
+ const [file, query] = parseId(id$1);
147
+ if (!query) return;
148
+ const resolved = await this.resolve(file, ...args);
149
+ if (resolved) resolved.id += `?${query}`;
150
+ return resolved;
151
+ }
152
+ },
153
+ load: {
154
+ filter: [include(or(id(exactRegex(HELPERS_ID)), id(/\.wasm$/, { cleanUrl: true })))],
155
+ async handler(id$1) {
156
+ if (id$1 === HELPERS_ID) return getHelpersModule(targetEnv || "auto");
157
+ const [file, , params] = parseId(id$1);
158
+ const buffer = await readFile(file);
159
+ const isInit = params.has("init");
160
+ const isSync = params.has("sync");
161
+ const isUrl = params.has("url");
162
+ if (isSync && isUrl) this.error("`sync` and `url` parameters cannot be used together.");
163
+ this.addWatchFile(file);
164
+ if (!isInit) this.getModuleInfo(id$1).meta.wasmInfo = await parseWasm(buffer);
165
+ function shouldInline() {
166
+ if (isUrl) return false;
167
+ if (isSync) return true;
168
+ if (targetEnv === "auto-inline") return true;
169
+ if (maxFileSize === 0) return false;
170
+ return buffer.length <= maxFileSize;
171
+ }
172
+ if (!shouldInline()) {
173
+ const hash = createHash("sha1").update(buffer).digest("hex").slice(0, 16);
174
+ const ext = path.extname(file);
175
+ const name = path.basename(file, ext);
176
+ const outputFileName = fileName.replaceAll("[hash]", hash).replaceAll("[extname]", ext).replaceAll("[name]", name);
177
+ copies[file] = {
178
+ filename: outputFileName,
179
+ publicFilepath: `${publicPath}${outputFileName}`,
180
+ buffer
181
+ };
182
+ }
183
+ return buffer.toString("binary");
184
+ }
185
+ },
186
+ transform: {
187
+ filter: [include(id(/\.wasm$/, { cleanUrl: true }))],
188
+ handler(code, id$1) {
189
+ const [file, , params] = parseId(id$1);
190
+ const publicFilepath = copies[file] ? JSON.stringify(copies[file].publicFilepath) : null;
191
+ let src;
192
+ const isSync = params.has("sync");
193
+ if (params.has("url")) {
194
+ if (!publicFilepath) this.error("`url` parameter can only be used with non-inlined files.");
195
+ return `export default ${publicFilepath}`;
196
+ }
197
+ if (publicFilepath === null) src = `'${Buffer.from(code, "binary").toString("base64")}'`;
198
+ else {
199
+ if (isSync) this.error("non-inlined files can not be `sync`.");
200
+ src = null;
201
+ }
202
+ const isInit = params.has("init");
203
+ let codegen = `import { loadWasmModule } from ${JSON.stringify(HELPERS_ID)}
204
+ ${isInit ? "export default " : ""}function __wasm_init(imports) {
205
+ return loadWasmModule(${isSync}, ${publicFilepath}, ${src}, imports)
206
+ }\n`;
207
+ const mod = this.getModuleInfo(id$1);
208
+ if (!isInit) {
209
+ const { imports, exports } = mod.meta.wasmInfo;
210
+ codegen += imports.map(([from], i) => {
211
+ return `import * as _wasmImport_${i} from ${JSON.stringify(from)}\n`;
212
+ });
213
+ const importObject = imports.map(([from, names], i) => {
214
+ return {
215
+ key: JSON.stringify(from),
216
+ value: names.map((name) => {
217
+ return {
218
+ key: JSON.stringify(name),
219
+ value: `_wasmImport_${i}[${JSON.stringify(name)}]`
220
+ };
221
+ })
222
+ };
223
+ });
224
+ codegen += `const instance = await __wasm_init(${codegenSimpleObject(importObject)})\n`;
225
+ codegen += exports.map((name) => {
226
+ return `export ${name === "default" ? "default" : `const ${name} =`} instance.exports.${name}`;
227
+ }).join("\n");
228
+ }
229
+ return {
230
+ map: { mappings: "" },
231
+ code: codegen
232
+ };
233
+ }
234
+ },
235
+ generateBundle() {
236
+ for (const copy of Object.values(copies)) this.emitFile({
237
+ type: "asset",
238
+ source: copy.buffer,
239
+ name: "Rolldown WASM Asset",
240
+ fileName: copy.filename
241
+ });
242
+ }
243
+ };
244
+ }
245
+
246
+ //#endregion
247
+ export { wasm };
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  name: "robuild",
4
4
  type: "module",
5
- version: "0.1.4",
5
+ version: "0.1.6",
6
6
  packageManager: "pnpm@10.11.1",
7
7
  description: "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc",
8
8
  license: "MIT",
@@ -33,44 +33,49 @@ var package_default = {
33
33
  "test:coverage:raw": "vitest run --coverage && node scripts/update-coverage.mjs",
34
34
  "test:coverage:watch": "vitest --coverage",
35
35
  "test:ui": "vitest --ui",
36
- "test:types": "tsc --noEmit --skipLibCheck src/**/*.ts",
36
+ "test:types": "tsc --noEmit",
37
37
  "docs:dev": "vitepress dev docs",
38
38
  "docs:build": "turbo docs:build:raw --filter=robuild",
39
39
  "docs:build:raw": "vitepress build docs",
40
40
  "docs:preview": "vitepress preview docs",
41
41
  "commit": "git-cz",
42
- "clean": "rm -rf .turbo dist coverage"
42
+ "clean": "rm -rf .turbo dist coverage",
43
+ "prepare": "husky"
43
44
  },
44
45
  dependencies: {
45
- "c12": "4.0.0-beta.2",
46
+ "c12": "4.0.0-beta.3",
46
47
  "cac": "^6.7.14",
47
48
  "chokidar": "^5.0.0",
48
49
  "consola": "^3.4.2",
49
50
  "exsolve": "^1.0.8",
50
- "glob": "^13.0.3",
51
+ "glob": "^13.0.6",
51
52
  "js-yaml": "^4.1.1",
52
53
  "magic-string": "^0.30.21",
53
- "minimatch": "^10.2.0",
54
- "oxc-minify": "^0.112.0",
55
- "oxc-parser": "^0.112.0",
56
- "oxc-transform": "^0.112.0",
54
+ "minimatch": "^10.2.2",
55
+ "oxc-minify": "^0.114.0",
56
+ "oxc-parser": "^0.114.0",
57
+ "oxc-transform": "^0.114.0",
57
58
  "pretty-bytes": "^7.1.0",
58
- "rolldown": "1.0.0-rc.4",
59
+ "rolldown": "1.0.0-rc.5",
59
60
  "rolldown-plugin-dts": "^0.22.1",
60
61
  "tinyglobby": "^0.2.15",
61
62
  "typescript": "^5.9.3"
62
63
  },
63
64
  devDependencies: {
64
65
  "@types/js-yaml": "^4.0.9",
65
- "@types/node": "^25.2.3",
66
+ "@types/node": "^25.3.0",
66
67
  "@vitest/coverage-v8": "^4.0.18",
67
68
  "automd": "^0.4.3",
68
69
  "changelogen": "^0.6.2",
69
70
  "esno": "^4.8.0",
70
71
  "git-cz": "^4.9.0",
72
+ "husky": "^9.1.7",
73
+ "lint-staged": "^16.2.7",
71
74
  "oxlint": "^1.49.0",
72
- "turbo": "^2.8.7",
75
+ "rolldown-plugin-wasm": "^0.2.1",
76
+ "turbo": "^2.8.10",
73
77
  "vitepress": "^1.6.4",
78
+ "vitepress-plugin-group-icons": "^1.7.1",
74
79
  "vitest": "^4.0.18"
75
80
  }
76
81
  };
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { g as logger, h as configureLogger, t as build } from "./_chunks/build-UBcR7iC8.mjs";
2
+ import { g as logger, h as configureLogger, t as build } from "./_chunks/build-rD4AllYV.mjs";
3
3
  import { colors } from "consola/utils";
4
4
  import process from "node:process";
5
5
  import { loadConfig } from "c12";
package/dist/config.d.mts CHANGED
@@ -84,6 +84,21 @@ interface _BuildEntry {
84
84
  * Defaults to `dist/` if not provided.
85
85
  */
86
86
  outDir?: string;
87
+ /**
88
+ * Custom output file name.
89
+ *
90
+ * Overrides the default naming convention. Should include the file extension.
91
+ * Only works with single-entry builds.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * {
96
+ * input: './src/index.ts',
97
+ * fileName: 'bundle.min.js'
98
+ * }
99
+ * ```
100
+ */
101
+ fileName?: string;
87
102
  /**
88
103
  * Avoid actual build but instead link to the source files.
89
104
  */
@@ -242,6 +257,15 @@ interface _BuildEntry {
242
257
  * @default false
243
258
  */
244
259
  unbundle?: boolean;
260
+ /**
261
+ * WASM support configuration for this entry.
262
+ *
263
+ * When enabled, you can import .wasm files directly.
264
+ * Overrides the global `wasm` config if set.
265
+ *
266
+ * @default false
267
+ */
268
+ wasm?: boolean | WasmOptions;
245
269
  }
246
270
  type BundleEntry = _BuildEntry & {
247
271
  type: 'bundle';
@@ -451,6 +475,60 @@ interface GlobImportOptions {
451
475
  */
452
476
  eager?: boolean;
453
477
  }
478
+ /**
479
+ * WASM support configuration options.
480
+ *
481
+ * When enabled, robuild will use rolldown-plugin-wasm to handle .wasm file imports.
482
+ *
483
+ * @see https://github.com/sxzz/rolldown-plugin-wasm
484
+ */
485
+ interface WasmOptions {
486
+ /**
487
+ * Enable WASM support.
488
+ *
489
+ * @default false
490
+ */
491
+ enabled?: boolean;
492
+ /**
493
+ * Maximum file size (in bytes) for inlining WASM modules.
494
+ *
495
+ * Files larger than this will be emitted as separate files.
496
+ * Set to 0 to always emit as separate files.
497
+ *
498
+ * @default 14336 (14KB)
499
+ */
500
+ maxFileSize?: number;
501
+ /**
502
+ * Output filename pattern for WASM files.
503
+ *
504
+ * Supports placeholders:
505
+ * - `[hash]` - Content hash
506
+ * - `[name]` - Original filename without extension
507
+ * - `[extname]` - File extension (e.g., `.wasm`)
508
+ *
509
+ * @default '[hash][extname]'
510
+ */
511
+ fileName?: string;
512
+ /**
513
+ * Public path prefix for WASM files.
514
+ *
515
+ * Used when WASM files need to be loaded from a specific URL path.
516
+ *
517
+ * @example '/assets/'
518
+ */
519
+ publicPath?: string;
520
+ /**
521
+ * Target environment for WASM instantiation.
522
+ *
523
+ * - `'auto'` - Detect environment at runtime (works in both Node.js and browser)
524
+ * - `'auto-inline'` - Always inline, decode based on environment
525
+ * - `'browser'` - Browser-only (omits Node.js built-in modules)
526
+ * - `'node'` - Node.js-only (requires Node.js 20.16.0+)
527
+ *
528
+ * @default 'auto'
529
+ */
530
+ targetEnv?: 'auto' | 'auto-inline' | 'browser' | 'node';
531
+ }
454
532
  interface BuildHooks {
455
533
  /**
456
534
  * Called at the start of the build process
@@ -684,6 +762,28 @@ interface BuildConfig {
684
762
  * Glob import configuration
685
763
  */
686
764
  globImport?: GlobImportOptions;
765
+ /**
766
+ * WASM support configuration.
767
+ *
768
+ * When enabled, you can import .wasm files directly in your code.
769
+ *
770
+ * @example
771
+ * ```ts
772
+ * // Direct import (sync)
773
+ * import { add } from './math.wasm'
774
+ *
775
+ * // Async initialization
776
+ * import init from './math.wasm?init'
777
+ * const instance = await init()
778
+ *
779
+ * // Sync initialization
780
+ * import initSync from './math.wasm?init&sync'
781
+ * const instance = initSync()
782
+ * ```
783
+ *
784
+ * @default false
785
+ */
786
+ wasm?: boolean | WasmOptions;
687
787
  /**
688
788
  * Log level for build output.
689
789
  *
package/dist/config.mjs CHANGED
@@ -1,7 +1,3 @@
1
- //#region src/config.ts
2
- function defineConfig(config) {
3
- return config;
4
- }
1
+ import { t as defineConfig } from "./_chunks/config-BlC5U5aX.mjs";
5
2
 
6
- //#endregion
7
3
  export { defineConfig };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { a as createBrowserShimsPlugin, c as SHEBANG_RE, d as shebangPlugin, f as nodeProtocolPlugin, g as logger, i as DEFAULT_SHIMS_CONFIG, l as hasShebang, m as hasGlobImports, o as createNodeShimsPlugin, p as createGlobImportPlugin, r as createSkipNodeModulesPlugin, s as createShimsPlugin, t as build, u as makeExecutable } from "./_chunks/build-UBcR7iC8.mjs";
1
+ import { a as createBrowserShimsPlugin, c as SHEBANG_RE, d as shebangPlugin, f as nodeProtocolPlugin, g as logger, i as DEFAULT_SHIMS_CONFIG, l as hasShebang, m as hasGlobImports, o as createNodeShimsPlugin, p as createGlobImportPlugin, r as createSkipNodeModulesPlugin, s as createShimsPlugin, t as build, u as makeExecutable } from "./_chunks/build-rD4AllYV.mjs";
2
2
  import { t as RobuildPluginManager } from "./_chunks/manager-uQxDLzY6.mjs";
3
- import { defineConfig } from "./config.mjs";
3
+ import { t as defineConfig } from "./_chunks/config-BlC5U5aX.mjs";
4
4
  import { extname } from "node:path";
5
5
  import { readFile } from "node:fs/promises";
6
6
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "robuild",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
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",
@@ -34,44 +34,49 @@
34
34
  "test:coverage:raw": "vitest run --coverage && node scripts/update-coverage.mjs",
35
35
  "test:coverage:watch": "vitest --coverage",
36
36
  "test:ui": "vitest --ui",
37
- "test:types": "tsc --noEmit --skipLibCheck src/**/*.ts",
37
+ "test:types": "tsc --noEmit",
38
38
  "docs:dev": "vitepress dev docs",
39
39
  "docs:build": "turbo docs:build:raw --filter=robuild",
40
40
  "docs:build:raw": "vitepress build docs",
41
41
  "docs:preview": "vitepress preview docs",
42
42
  "commit": "git-cz",
43
- "clean": "rm -rf .turbo dist coverage"
43
+ "clean": "rm -rf .turbo dist coverage",
44
+ "prepare": "husky"
44
45
  },
45
46
  "dependencies": {
46
- "c12": "4.0.0-beta.2",
47
+ "c12": "4.0.0-beta.3",
47
48
  "cac": "^6.7.14",
48
49
  "chokidar": "^5.0.0",
49
50
  "consola": "^3.4.2",
50
51
  "exsolve": "^1.0.8",
51
- "glob": "^13.0.3",
52
+ "glob": "^13.0.6",
52
53
  "js-yaml": "^4.1.1",
53
54
  "magic-string": "^0.30.21",
54
- "minimatch": "^10.2.0",
55
- "oxc-minify": "^0.112.0",
56
- "oxc-parser": "^0.112.0",
57
- "oxc-transform": "^0.112.0",
55
+ "minimatch": "^10.2.2",
56
+ "oxc-minify": "^0.114.0",
57
+ "oxc-parser": "^0.114.0",
58
+ "oxc-transform": "^0.114.0",
58
59
  "pretty-bytes": "^7.1.0",
59
- "rolldown": "1.0.0-rc.4",
60
+ "rolldown": "1.0.0-rc.5",
60
61
  "rolldown-plugin-dts": "^0.22.1",
61
62
  "tinyglobby": "^0.2.15",
62
63
  "typescript": "^5.9.3"
63
64
  },
64
65
  "devDependencies": {
65
66
  "@types/js-yaml": "^4.0.9",
66
- "@types/node": "^25.2.3",
67
+ "@types/node": "^25.3.0",
67
68
  "@vitest/coverage-v8": "^4.0.18",
68
69
  "automd": "^0.4.3",
69
70
  "changelogen": "^0.6.2",
70
71
  "esno": "^4.8.0",
71
72
  "git-cz": "^4.9.0",
73
+ "husky": "^9.1.7",
74
+ "lint-staged": "^16.2.7",
72
75
  "oxlint": "^1.49.0",
73
- "turbo": "^2.8.7",
76
+ "rolldown-plugin-wasm": "^0.2.1",
77
+ "turbo": "^2.8.10",
74
78
  "vitepress": "^1.6.4",
79
+ "vitepress-plugin-group-icons": "^1.7.1",
75
80
  "vitest": "^4.0.18"
76
81
  }
77
82
  }
@@ -1,3 +0,0 @@
1
- import { n as performBuild, t as build } from "./build-UBcR7iC8.mjs";
2
-
3
- export { performBuild };