robuild 0.1.12 → 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-C4bkK2Xj.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",
@@ -2223,7 +2268,7 @@ function createBuildResult(entries, startTime) {
2223
2268
  * Perform watch build using rolldown's built-in watch mode
2224
2269
  */
2225
2270
  async function performWatchBuild(config, ctx, startTime) {
2226
- const { performBuild } = await import("./build-BxwmFw-W.mjs");
2271
+ const { performBuild } = await import("./build-BdC3yali.mjs");
2227
2272
  await performBuild(config, ctx, startTime);
2228
2273
  const bundleEntries = (config.entries || []).filter((entry) => {
2229
2274
  if (typeof entry === "string") return !entry.endsWith("/");
@@ -2243,7 +2288,7 @@ async function performWatchBuild(config, ctx, startTime) {
2243
2288
  */
2244
2289
  async function startRolldownWatch(config, ctx, bundleEntries) {
2245
2290
  logger.info("Watching for changes...");
2246
- const { inheritConfig } = await import("./build-BxwmFw-W.mjs");
2291
+ const { inheritConfig } = await import("./build-BdC3yali.mjs");
2247
2292
  const watchConfigs = [];
2248
2293
  for (const rawEntry of bundleEntries) {
2249
2294
  let entry = typeof rawEntry === "string" ? parseEntryString(rawEntry) : rawEntry;
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  name: "robuild",
4
4
  type: "module",
5
- version: "0.1.12",
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-C4bkK2Xj.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-C4bkK2Xj.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.12",
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",