robuild 0.1.12 → 0.1.14
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.
|
@@ -1491,10 +1491,12 @@ 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}`;
|
|
1497
1498
|
if (entry.fileName) entryFileName = entry.fileName;
|
|
1499
|
+
else if (entry.outExtensions) entryFileName = `[name].${applyOutExtensions(format, entry.outExtensions).js}`;
|
|
1498
1500
|
else if (isMultiFormat) {
|
|
1499
1501
|
if (format === "cjs" || format === "commonjs") entryFileName = `[name].cjs`;
|
|
1500
1502
|
else if (format === "es" || format === "esm" || format === "module") entryFileName = `[name].mjs`;
|
|
@@ -1503,6 +1505,7 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1503
1505
|
const robuildOutputConfig = {
|
|
1504
1506
|
dir: formatOutDir,
|
|
1505
1507
|
format,
|
|
1508
|
+
exports: entry.cjsDefault ?? true ? "auto" : "named",
|
|
1506
1509
|
entryFileNames: entryFileName,
|
|
1507
1510
|
chunkFileNames: (chunk) => {
|
|
1508
1511
|
if (chunk.name.endsWith(".d") || chunk.name.includes(".d.")) return `[name].mjs`;
|
|
@@ -1521,6 +1524,41 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1521
1524
|
await hooks.rolldownOutput?.(outConfig, res, ctx);
|
|
1522
1525
|
const { output } = await res.write(outConfig);
|
|
1523
1526
|
await res.close();
|
|
1527
|
+
if (needsCjsDts) {
|
|
1528
|
+
const cjsDtsConfig = { ...baseRolldownConfig };
|
|
1529
|
+
const dtsPlugins = dts({
|
|
1530
|
+
cwd: ctx.pkgDir,
|
|
1531
|
+
emitDtsOnly: true,
|
|
1532
|
+
cjsDefault: true,
|
|
1533
|
+
...typeof entry.dts === "object" ? entry.dts : {}
|
|
1534
|
+
});
|
|
1535
|
+
cjsDtsConfig.plugins = [...Array.isArray(cjsDtsConfig.plugins) ? cjsDtsConfig.plugins : [cjsDtsConfig.plugins], ...Array.isArray(dtsPlugins) ? dtsPlugins : [dtsPlugins]];
|
|
1536
|
+
const cjsDtsRes = await rolldown(cjsDtsConfig);
|
|
1537
|
+
const cjsDtsOutput = await cjsDtsRes.write({
|
|
1538
|
+
dir: formatOutDir,
|
|
1539
|
+
format: "es",
|
|
1540
|
+
entryFileNames: "[name].d.cts",
|
|
1541
|
+
chunkFileNames: "[name]2.d.cts"
|
|
1542
|
+
});
|
|
1543
|
+
await cjsDtsRes.close();
|
|
1544
|
+
const { readFile: rf, unlink: ul, rename: rn, stat } = await import("node:fs/promises");
|
|
1545
|
+
for (const chunk of cjsDtsOutput.output) {
|
|
1546
|
+
if (chunk.type !== "chunk") continue;
|
|
1547
|
+
const filePath = join(formatOutDir, chunk.fileName);
|
|
1548
|
+
const content = await rf(filePath, "utf8");
|
|
1549
|
+
if (content.trim() === "export { };" || content.trim() === "") await ul(filePath);
|
|
1550
|
+
else if (chunk.fileName.includes("2.d.cts")) {
|
|
1551
|
+
const newFilePath = join(formatOutDir, chunk.fileName.replace("2.d.cts", ".d.cts"));
|
|
1552
|
+
try {
|
|
1553
|
+
if ((await stat(newFilePath)).isFile()) {
|
|
1554
|
+
const existingContent = await rf(newFilePath, "utf8");
|
|
1555
|
+
if (existingContent.trim() === "export { };" || existingContent.trim() === "") await ul(newFilePath);
|
|
1556
|
+
}
|
|
1557
|
+
} catch {}
|
|
1558
|
+
await rn(filePath, newFilePath);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1524
1562
|
const depsCache = /* @__PURE__ */ new Map();
|
|
1525
1563
|
const resolveDeps = (chunk) => {
|
|
1526
1564
|
if (!depsCache.has(chunk)) depsCache.set(chunk, /* @__PURE__ */ new Set());
|
|
@@ -1595,10 +1633,18 @@ async function rolldownBuild(ctx, entry, hooks, config) {
|
|
|
1595
1633
|
o.deps.length > 0 ? colors.dim(` Dependencies: ${o.deps.join(", ")}`) : ""
|
|
1596
1634
|
].filter(Boolean).join("\n")).join("\n\n")}`);
|
|
1597
1635
|
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Ensure a path is properly formatted for resolveModulePath.
|
|
1638
|
+
* Adds './' prefix for relative paths that don't start with './' or '../'
|
|
1639
|
+
*/
|
|
1640
|
+
function ensureRelativePrefix(path) {
|
|
1641
|
+
if (isAbsolute(path) || path.startsWith("./") || path.startsWith("../")) return path;
|
|
1642
|
+
return `./${path}`;
|
|
1643
|
+
}
|
|
1598
1644
|
function normalizeBundleInputs(input, ctx) {
|
|
1599
1645
|
const inputs = {};
|
|
1600
1646
|
if (typeof input === "object" && !Array.isArray(input)) {
|
|
1601
|
-
for (const [name, src] of Object.entries(input)) inputs[name] = resolveModulePath(src, {
|
|
1647
|
+
for (const [name, src] of Object.entries(input)) inputs[name] = resolveModulePath(ensureRelativePrefix(src), {
|
|
1602
1648
|
from: ctx.pkgDir,
|
|
1603
1649
|
extensions: [
|
|
1604
1650
|
".ts",
|
|
@@ -1611,7 +1657,7 @@ function normalizeBundleInputs(input, ctx) {
|
|
|
1611
1657
|
return inputs;
|
|
1612
1658
|
}
|
|
1613
1659
|
for (let src of Array.isArray(input) ? input : [input]) {
|
|
1614
|
-
src = resolveModulePath(src, {
|
|
1660
|
+
src = resolveModulePath(ensureRelativePrefix(src), {
|
|
1615
1661
|
from: ctx.pkgDir,
|
|
1616
1662
|
extensions: [
|
|
1617
1663
|
".ts",
|
|
@@ -2223,7 +2269,7 @@ function createBuildResult(entries, startTime) {
|
|
|
2223
2269
|
* Perform watch build using rolldown's built-in watch mode
|
|
2224
2270
|
*/
|
|
2225
2271
|
async function performWatchBuild(config, ctx, startTime) {
|
|
2226
|
-
const { performBuild } = await import("./build-
|
|
2272
|
+
const { performBuild } = await import("./build-ogb8L7fk.mjs");
|
|
2227
2273
|
await performBuild(config, ctx, startTime);
|
|
2228
2274
|
const bundleEntries = (config.entries || []).filter((entry) => {
|
|
2229
2275
|
if (typeof entry === "string") return !entry.endsWith("/");
|
|
@@ -2243,7 +2289,7 @@ async function performWatchBuild(config, ctx, startTime) {
|
|
|
2243
2289
|
*/
|
|
2244
2290
|
async function startRolldownWatch(config, ctx, bundleEntries) {
|
|
2245
2291
|
logger.info("Watching for changes...");
|
|
2246
|
-
const { inheritConfig } = await import("./build-
|
|
2292
|
+
const { inheritConfig } = await import("./build-ogb8L7fk.mjs");
|
|
2247
2293
|
const watchConfigs = [];
|
|
2248
2294
|
for (const rawEntry of bundleEntries) {
|
|
2249
2295
|
let entry = typeof rawEntry === "string" ? parseEntryString(rawEntry) : rawEntry;
|
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-
|
|
2
|
+
import { _ as configureLogger, t as build, v as logger } from "./_chunks/build-B3vdIgJO.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-
|
|
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-B3vdIgJO.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";
|