robuild 0.0.9 → 0.0.11

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
@@ -4,6 +4,12 @@
4
4
 
5
5
  # 📦 robuild 😯 [![npm](https://img.shields.io/npm/v/robuild.svg)](https://npmjs.com/package/robuild)
6
6
 
7
+ [![npm version][npm-version-src]][npm-version-href]
8
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
9
+ [![bundle][bundle-src]][bundle-href]
10
+ [![JSDocs][jsdocs-src]][jsdocs-href]
11
+ [![License][license-src]][license-href]
12
+
7
13
  English | <a href="./README-zh.md">简体中文</a>
8
14
 
9
15
  ⚡️ Zero-config ESM/TS package builder. Powered by [**Oxc**](https://oxc.rs/), [**Rolldown**](https://rolldown.rs/) and [**rolldown-plugin-dts**](https://github.com/sxzz/rolldown-plugin-dts).
@@ -89,4 +95,16 @@ Visit our documentation site for detailed guides, API reference, and examples.
89
95
 
90
96
  ## License
91
97
 
92
- 💛 Released under the [MIT](./LICENSE) license.
98
+ 💛 [MIT](./LICENSE) License © [Sunny-117](https://github.com/Sunny-117)
99
+ <!-- Badges -->
100
+
101
+ [npm-version-src]: https://img.shields.io/npm/v/robuild?style=flat&colorA=080f12&colorB=1fa669
102
+ [npm-version-href]: https://npmjs.com/package/robuild
103
+ [npm-downloads-src]: https://img.shields.io/npm/dm/robuild?style=flat&colorA=080f12&colorB=1fa669
104
+ [npm-downloads-href]: https://npmjs.com/package/robuild
105
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/robuild?style=flat&colorA=080f12&colorB=1fa669&label=minzip
106
+ [bundle-href]: https://bundlephobia.com/result?p=robuild
107
+ [license-src]: https://img.shields.io/github/license/Sunny-117/robuild.svg?style=flat&colorA=080f12&colorB=1fa669
108
+ [license-href]: https://github.com/Sunny-117/robuild/blob/main/LICENSE
109
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
110
+ [jsdocs-href]: https://www.jsdocs.io/package/robuild
@@ -1043,11 +1043,48 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1043
1043
  }
1044
1044
  return;
1045
1045
  }
1046
- const externalDeps = [
1046
+ let externalDeps = [
1047
1047
  ...builtinModules,
1048
1048
  ...builtinModules.map((m) => `node:${m}`),
1049
1049
  ...[...Object.keys(ctx.pkg.dependencies || {}), ...Object.keys(ctx.pkg.peerDependencies || {})].flatMap((p) => [p, /* @__PURE__ */ new RegExp(`^${p}/`)])
1050
1050
  ];
1051
+ if (entry.noExternal) {
1052
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1053
+ if (typeof entry.noExternal === "function") {
1054
+ const predicate = entry.noExternal;
1055
+ const depNames = [...Object.keys(ctx.pkg.dependencies || {}), ...Object.keys(ctx.pkg.peerDependencies || {})];
1056
+ const excludedNames = /* @__PURE__ */ new Set();
1057
+ for (const name of depNames) try {
1058
+ if (predicate(name)) excludedNames.add(name);
1059
+ } catch {}
1060
+ externalDeps = externalDeps.filter((dep) => {
1061
+ if (typeof dep === "string") return !excludedNames.has(dep);
1062
+ if (dep instanceof RegExp) {
1063
+ for (const name of excludedNames) if (dep.source.startsWith(`^${escapeRegExp(name)}/`)) return false;
1064
+ return true;
1065
+ }
1066
+ return true;
1067
+ });
1068
+ } else if (Array.isArray(entry.noExternal)) {
1069
+ const rules = entry.noExternal;
1070
+ externalDeps = externalDeps.filter((dep) => {
1071
+ for (const rule of rules) if (typeof rule === "string") {
1072
+ if (typeof dep === "string") {
1073
+ if (dep === rule) return false;
1074
+ } else if (dep instanceof RegExp) {
1075
+ if (dep.source.startsWith(`^${escapeRegExp(rule)}/`)) return false;
1076
+ }
1077
+ } else if (rule instanceof RegExp) {
1078
+ if (typeof dep === "string") {
1079
+ if (rule.test(dep)) return false;
1080
+ } else if (dep instanceof RegExp) {
1081
+ if (dep.source === rule.source && dep.flags === rule.flags) return false;
1082
+ }
1083
+ }
1084
+ return true;
1085
+ });
1086
+ }
1087
+ }
1051
1088
  if (entry.external) if (typeof entry.external === "function") {} else externalDeps.push(...entry.external);
1052
1089
  const defineOptions = {};
1053
1090
  if (entry.env) for (const [key, value] of Object.entries(entry.env)) defineOptions[`process.env.${key}`] = JSON.stringify(value);
@@ -1142,6 +1179,7 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1142
1179
  banner: resolveChunkAddon(entry.banner, format),
1143
1180
  footer: resolveChunkAddon(entry.footer, format)
1144
1181
  };
1182
+ if (entry.sourcemap !== void 0) outConfig.sourcemap = entry.sourcemap;
1145
1183
  await hooks.rolldownOutput?.(outConfig, res, ctx);
1146
1184
  const { output } = await res.write(outConfig);
1147
1185
  await res.close();
@@ -1174,6 +1212,11 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1174
1212
  const hashedFilePath = join(formatOutDir, hashedFileName);
1175
1213
  const { rename } = await import("node:fs/promises");
1176
1214
  await rename(finalFilePath, hashedFilePath);
1215
+ try {
1216
+ const mapOld = `${finalFilePath}.map`;
1217
+ const mapNew = `${hashedFilePath}.map`;
1218
+ await rename(mapOld, mapNew);
1219
+ } catch {}
1177
1220
  finalFileName = hashedFileName;
1178
1221
  finalFilePath = hashedFilePath;
1179
1222
  }
@@ -155,6 +155,14 @@ interface _BuildEntry {
155
155
  */
156
156
  define?: Record<string, string>;
157
157
  /**
158
+ * Generate source maps for built files.
159
+ *
160
+ * - `true` - emit separate `.map` files
161
+ * - `'inline'` - embed source maps in generated files
162
+ * - `'hidden'` - emit map files but do not add sourceMappingURL comment
163
+ */
164
+ sourcemap?: boolean | "inline" | "hidden" | Record<string, any>;
165
+ /**
158
166
  * External dependencies that should not be bundled.
159
167
  */
160
168
  external?: (string | RegExp)[] | ((id: string, importer?: string) => boolean);
@@ -395,6 +403,14 @@ interface BuildConfig {
395
403
  hooks?: BuildHooks;
396
404
  watch?: WatchOptions;
397
405
  /**
406
+ * Output directory for builds.
407
+ */
408
+ outDir?: string;
409
+ /**
410
+ * Clean output directory before build.
411
+ */
412
+ clean?: boolean | string[];
413
+ /**
398
414
  * Plugins to use during build
399
415
  */
400
416
  plugins?: RobuildPlugin[];
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var name = "robuild";
3
3
  var type = "module";
4
- var version = "0.0.9";
4
+ var version = "0.0.11";
5
5
  var packageManager = "pnpm@10.11.1";
6
6
  var description = "Zero-config ESM/TS package builder. Powered by Rolldown and Oxc";
7
7
  var license = "MIT";
@@ -27,7 +27,8 @@ var scripts = {
27
27
  "test:types": "tsc --noEmit --skipLibCheck",
28
28
  "docs:dev": "vitepress dev docs",
29
29
  "docs:build": "vitepress build docs",
30
- "docs:preview": "vitepress preview docs"
30
+ "docs:preview": "vitepress preview docs",
31
+ "commit": "git-cz"
31
32
  };
32
33
  var dependencies = {
33
34
  "c12": "^3.0.4",
@@ -58,6 +59,7 @@ var devDependencies = {
58
59
  "changelogen": "^0.6.1",
59
60
  "eslint": "^9.28.0",
60
61
  "esno": "^4.8.0",
62
+ "git-cz": "^4.9.0",
61
63
  "prettier": "^3.5.3",
62
64
  "vitepress": "^1.6.3",
63
65
  "vitest": "^3.2.2"
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { build } from "./_chunks/build-BwB_tOe9.mjs";
2
+ import { build } from "./_chunks/build-BFnZNGy3.mjs";
3
3
  import { consola } from "consola";
4
4
  import { parseArgs } from "node:util";
5
5
  import { loadConfig } from "c12";
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { defineConfig } from "./_chunks/config-CeOzkcue.mjs";
1
+ import { defineConfig } from "./_chunks/config-BDpkh_pL.mjs";
2
2
  export { defineConfig };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { BuildConfig, BuildEntry, BundleEntry, TransformEntry, defineConfig } from "./_chunks/config-CeOzkcue.mjs";
1
+ import { BuildConfig, BuildEntry, BundleEntry, TransformEntry, defineConfig } from "./_chunks/config-BDpkh_pL.mjs";
2
2
 
3
3
  //#region src/build.d.ts
4
4
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { build } from "./_chunks/build-BwB_tOe9.mjs";
1
+ import { build } from "./_chunks/build-BFnZNGy3.mjs";
2
2
  import { defineConfig } from "./_chunks/config-B_2eqpNJ.mjs";
3
3
 
4
4
  export { build, defineConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "robuild",
3
3
  "type": "module",
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
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",
@@ -29,7 +29,8 @@
29
29
  "test:types": "tsc --noEmit --skipLibCheck",
30
30
  "docs:dev": "vitepress dev docs",
31
31
  "docs:build": "vitepress build docs",
32
- "docs:preview": "vitepress preview docs"
32
+ "docs:preview": "vitepress preview docs",
33
+ "commit": "git-cz"
33
34
  },
34
35
  "dependencies": {
35
36
  "c12": "^3.0.4",
@@ -60,6 +61,7 @@
60
61
  "changelogen": "^0.6.1",
61
62
  "eslint": "^9.28.0",
62
63
  "esno": "^4.8.0",
64
+ "git-cz": "^4.9.0",
63
65
  "prettier": "^3.5.3",
64
66
  "vitepress": "^1.6.3",
65
67
  "vitest": "^3.2.2"