robuild 0.1.11 → 0.1.13

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.
@@ -1,3 +1,3 @@
1
- import { n as inheritConfig, r as performBuild, t as build } from "./build--tBh0Drv.mjs";
1
+ import { n as inheritConfig, r as performBuild, t as build } from "./build-KdFkw9tq.mjs";
2
2
 
3
3
  export { inheritConfig, performBuild };
@@ -1491,6 +1491,7 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1491
1491
  });
1492
1492
  formatConfig.plugins = [...Array.isArray(formatConfig.plugins) ? formatConfig.plugins : [formatConfig.plugins], ...Array.isArray(dtsPlugins) ? dtsPlugins : [dtsPlugins]];
1493
1493
  }
1494
+ const needsCjsDts = entry.dts !== false && (format === "cjs" || format === "commonjs") && isMultiFormat && (entry.cjsDefault ?? true);
1494
1495
  const res = await rolldown(formatConfig);
1495
1496
  const formatOutDir = fullOutDir;
1496
1497
  let entryFileName = `[name]${extension}`;
@@ -1503,6 +1504,7 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1503
1504
  const robuildOutputConfig = {
1504
1505
  dir: formatOutDir,
1505
1506
  format,
1507
+ exports: entry.cjsDefault ?? true ? "auto" : "named",
1506
1508
  entryFileNames: entryFileName,
1507
1509
  chunkFileNames: (chunk) => {
1508
1510
  if (chunk.name.endsWith(".d") || chunk.name.includes(".d.")) return `[name].mjs`;
@@ -1521,6 +1523,41 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1521
1523
  await hooks.rolldownOutput?.(outConfig, res, ctx);
1522
1524
  const { output } = await res.write(outConfig);
1523
1525
  await res.close();
1526
+ if (needsCjsDts) {
1527
+ const cjsDtsConfig = { ...baseRolldownConfig };
1528
+ const dtsPlugins = dts({
1529
+ cwd: ctx.pkgDir,
1530
+ emitDtsOnly: true,
1531
+ cjsDefault: true,
1532
+ ...typeof entry.dts === "object" ? entry.dts : {}
1533
+ });
1534
+ cjsDtsConfig.plugins = [...Array.isArray(cjsDtsConfig.plugins) ? cjsDtsConfig.plugins : [cjsDtsConfig.plugins], ...Array.isArray(dtsPlugins) ? dtsPlugins : [dtsPlugins]];
1535
+ const cjsDtsRes = await rolldown(cjsDtsConfig);
1536
+ const cjsDtsOutput = await cjsDtsRes.write({
1537
+ dir: formatOutDir,
1538
+ format: "es",
1539
+ entryFileNames: "[name].d.cts",
1540
+ chunkFileNames: "[name]2.d.cts"
1541
+ });
1542
+ await cjsDtsRes.close();
1543
+ const { readFile: rf, unlink: ul, rename: rn, stat } = await import("node:fs/promises");
1544
+ for (const chunk of cjsDtsOutput.output) {
1545
+ if (chunk.type !== "chunk") continue;
1546
+ const filePath = join(formatOutDir, chunk.fileName);
1547
+ const content = await rf(filePath, "utf8");
1548
+ if (content.trim() === "export { };" || content.trim() === "") await ul(filePath);
1549
+ else if (chunk.fileName.includes("2.d.cts")) {
1550
+ const newFilePath = join(formatOutDir, chunk.fileName.replace("2.d.cts", ".d.cts"));
1551
+ try {
1552
+ if ((await stat(newFilePath)).isFile()) {
1553
+ const existingContent = await rf(newFilePath, "utf8");
1554
+ if (existingContent.trim() === "export { };" || existingContent.trim() === "") await ul(newFilePath);
1555
+ }
1556
+ } catch {}
1557
+ await rn(filePath, newFilePath);
1558
+ }
1559
+ }
1560
+ }
1524
1561
  const depsCache = /* @__PURE__ */ new Map();
1525
1562
  const resolveDeps = (chunk) => {
1526
1563
  if (!depsCache.has(chunk)) depsCache.set(chunk, /* @__PURE__ */ new Set());
@@ -1595,10 +1632,18 @@ async function rolldownBuild(ctx, entry, hooks, config) {
1595
1632
  o.deps.length > 0 ? colors.dim(` Dependencies: ${o.deps.join(", ")}`) : ""
1596
1633
  ].filter(Boolean).join("\n")).join("\n\n")}`);
1597
1634
  }
1635
+ /**
1636
+ * Ensure a path is properly formatted for resolveModulePath.
1637
+ * Adds './' prefix for relative paths that don't start with './' or '../'
1638
+ */
1639
+ function ensureRelativePrefix(path) {
1640
+ if (isAbsolute(path) || path.startsWith("./") || path.startsWith("../")) return path;
1641
+ return `./${path}`;
1642
+ }
1598
1643
  function normalizeBundleInputs(input, ctx) {
1599
1644
  const inputs = {};
1600
1645
  if (typeof input === "object" && !Array.isArray(input)) {
1601
- for (const [name, src] of Object.entries(input)) inputs[name] = resolveModulePath(src, {
1646
+ for (const [name, src] of Object.entries(input)) inputs[name] = resolveModulePath(ensureRelativePrefix(src), {
1602
1647
  from: ctx.pkgDir,
1603
1648
  extensions: [
1604
1649
  ".ts",
@@ -1611,7 +1656,7 @@ function normalizeBundleInputs(input, ctx) {
1611
1656
  return inputs;
1612
1657
  }
1613
1658
  for (let src of Array.isArray(input) ? input : [input]) {
1614
- src = resolveModulePath(src, {
1659
+ src = resolveModulePath(ensureRelativePrefix(src), {
1615
1660
  from: ctx.pkgDir,
1616
1661
  extensions: [
1617
1662
  ".ts",
@@ -2007,6 +2052,34 @@ function convertTarget(target) {
2007
2052
  function convertExternal(external) {
2008
2053
  return external;
2009
2054
  }
2055
+ /**
2056
+ * Check if entries are auto-generated defaults (single entry pointing to src/index.ts)
2057
+ */
2058
+ function isDefaultEntries(entries) {
2059
+ if (!entries || entries.length !== 1) return false;
2060
+ const entry = entries[0];
2061
+ if (typeof entry === "string") return false;
2062
+ if (entry.type !== "bundle") return false;
2063
+ const input = entry.input;
2064
+ if (Array.isArray(input) && input.length === 1) return input[0] === "src/index.ts" || input[0].endsWith("/src/index.ts");
2065
+ if (typeof input === "string") return input === "src/index.ts" || input.endsWith("/src/index.ts");
2066
+ return false;
2067
+ }
2068
+ /**
2069
+ * Merge Vite config with robuild config
2070
+ * Vite entries take precedence over auto-generated default entries
2071
+ */
2072
+ function mergeViteConfig(viteConfig, config) {
2073
+ if (viteConfig.entries && viteConfig.entries.length > 0 && isDefaultEntries(config.entries)) return {
2074
+ ...viteConfig,
2075
+ ...config,
2076
+ entries: viteConfig.entries
2077
+ };
2078
+ return {
2079
+ ...viteConfig,
2080
+ ...config
2081
+ };
2082
+ }
2010
2083
 
2011
2084
  //#endregion
2012
2085
  //#region src/transforms/exports.ts
@@ -2195,7 +2268,7 @@ function createBuildResult(entries, startTime) {
2195
2268
  * Perform watch build using rolldown's built-in watch mode
2196
2269
  */
2197
2270
  async function performWatchBuild(config, ctx, startTime) {
2198
- const { performBuild } = await import("./build-CJFQ6BGl.mjs");
2271
+ const { performBuild } = await import("./build-BdC3yali.mjs");
2199
2272
  await performBuild(config, ctx, startTime);
2200
2273
  const bundleEntries = (config.entries || []).filter((entry) => {
2201
2274
  if (typeof entry === "string") return !entry.endsWith("/");
@@ -2215,7 +2288,7 @@ async function performWatchBuild(config, ctx, startTime) {
2215
2288
  */
2216
2289
  async function startRolldownWatch(config, ctx, bundleEntries) {
2217
2290
  logger.info("Watching for changes...");
2218
- const { inheritConfig } = await import("./build-CJFQ6BGl.mjs");
2291
+ const { inheritConfig } = await import("./build-BdC3yali.mjs");
2219
2292
  const watchConfigs = [];
2220
2293
  for (const rawEntry of bundleEntries) {
2221
2294
  let entry = typeof rawEntry === "string" ? parseEntryString(rawEntry) : rawEntry;
@@ -2339,10 +2412,7 @@ async function build(config) {
2339
2412
  let finalConfig = config;
2340
2413
  if (config.fromVite) {
2341
2414
  logger.verbose("Loading configuration from Vite config file");
2342
- finalConfig = {
2343
- ...await loadViteConfig(pkgDir),
2344
- ...config
2345
- };
2415
+ finalConfig = mergeViteConfig(await loadViteConfig(pkgDir), config);
2346
2416
  }
2347
2417
  finalConfig = normalizeTsupConfig(finalConfig);
2348
2418
  if (finalConfig.watch?.enabled) {
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  name: "robuild",
4
4
  type: "module",
5
- version: "0.1.11",
5
+ version: "0.1.13",
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",
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as configureLogger, t as build, v as logger } from "./_chunks/build--tBh0Drv.mjs";
2
+ import { _ as configureLogger, t as build, v as logger } from "./_chunks/build-KdFkw9tq.mjs";
3
3
  import module from "node:module";
4
4
  import { colors } from "consola/utils";
5
5
  import process from "node:process";
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { S as resolveCssOptions, a as createSkipNodeModulesPlugin, b as createLightningCSSPlugin, c as createNodeShimsPlugin, d as hasShebang, f as makeExecutable, g as hasGlobImports, h as createGlobImportPlugin, i as RobuildPluginManager, l as createShimsPlugin, m as nodeProtocolPlugin, o as DEFAULT_SHIMS_CONFIG, p as shebangPlugin, s as createBrowserShimsPlugin, t as build, u as SHEBANG_RE, v as logger, x as esbuildTargetToLightningCSS, y as createCssCodeSplitPlugin } from "./_chunks/build--tBh0Drv.mjs";
1
+ import { S as resolveCssOptions, a as createSkipNodeModulesPlugin, b as createLightningCSSPlugin, c as createNodeShimsPlugin, d as hasShebang, f as makeExecutable, g as hasGlobImports, h as createGlobImportPlugin, i as RobuildPluginManager, l as createShimsPlugin, m as nodeProtocolPlugin, o as DEFAULT_SHIMS_CONFIG, p as shebangPlugin, s as createBrowserShimsPlugin, t as build, u as SHEBANG_RE, v as logger, x as esbuildTargetToLightningCSS, y as createCssCodeSplitPlugin } from "./_chunks/build-KdFkw9tq.mjs";
2
2
  import { t as defineConfig } from "./_chunks/config-BGTiuDLt.mjs";
3
3
  import { extname } from "node:path";
4
4
  import { readFile } from "node:fs/promises";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "robuild",
3
3
  "type": "module",
4
- "version": "0.1.11",
4
+ "version": "0.1.13",
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",