diff --git a/package.json b/package.json index d175da77..ed6ce349 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-replace": "^5.0.7", "@rollup/pluginutils": "^5.1.0", - "chalk": "^5.3.0", "citty": "^0.1.6", "consola": "^3.2.3", "defu": "^6.1.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bc125d11..baca8371 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,9 +26,6 @@ importers: '@rollup/pluginutils': specifier: ^5.1.0 version: 5.1.0(rollup@4.18.0) - chalk: - specifier: ^5.3.0 - version: 5.3.0 citty: specifier: ^0.1.6 version: 0.1.6 @@ -990,10 +987,6 @@ packages: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - chalk@5.3.0: - resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} - engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - changelogen@0.5.5: resolution: {integrity: sha512-IzgToIJ/R9NhVKmL+PW33ozYkv53bXvufDNUSH3GTKXq1iCHGgkbgbtqEWbo8tnWNnt7nPDpjL8PwSG2iS8RVw==} hasBin: true @@ -3360,8 +3353,6 @@ snapshots: ansi-styles: 4.3.0 supports-color: 7.2.0 - chalk@5.3.0: {} - changelogen@0.5.5(magicast@0.3.4): dependencies: c12: 1.11.1(magicast@0.3.4) diff --git a/src/auto.ts b/src/auto.ts index 9fe9f313..b389e519 100644 --- a/src/auto.ts +++ b/src/auto.ts @@ -3,7 +3,7 @@ import type { BuildEntry, BuildPreset, MkdistBuildEntry } from "./types"; import { existsSync } from "node:fs"; import { normalize, join, resolve } from "pathe"; import { consola } from "consola"; -import chalk from "chalk"; +import { colors } from "consola/utils"; import { definePreset } from "./types"; import { extractExportFilenames, listRecursively, warn } from "./utils"; @@ -38,10 +38,10 @@ export const autoPreset: BuildPreset = definePreset(() => { } consola.info( "Automatically detected entries:", - chalk.cyan( + colors.cyan( ctx.options.entries .map((e) => - chalk.bold( + colors.bold( e.input .replace(ctx.options.rootDir + "/", "") .replace(/\/$/, "/*"), @@ -49,7 +49,7 @@ export const autoPreset: BuildPreset = definePreset(() => { ) .join(", "), ), - chalk.gray( + colors.gray( ["esm", res.cjs && "cjs", res.dts && "dts"] .filter(Boolean) .map((tag) => `[${tag}]`) diff --git a/src/build.ts b/src/build.ts index 5ff626a0..8ac7285b 100644 --- a/src/build.ts +++ b/src/build.ts @@ -3,7 +3,7 @@ import { promises as fsp } from "node:fs"; import { resolve, relative, isAbsolute, normalize } from "pathe"; import { withTrailingSlash } from "ufo"; import type { PackageJson } from "pkg-types"; -import chalk from "chalk"; +import { colors } from "consola/utils"; import { consola } from "consola"; import { defu } from "defu"; import { createHooks } from "hookable"; @@ -228,11 +228,11 @@ async function _build( // Start info consola.info( - chalk.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`), + colors.cyan(`${options.stub ? "Stubbing" : "Building"} ${options.name}`), ); if (process.env.DEBUG) { - consola.info(`${chalk.bold("Root dir:")} ${options.rootDir} - ${chalk.bold("Entries:")} + consola.info(`${colors.bold("Root dir:")} ${options.rootDir} + ${colors.bold("Entries:")} ${options.entries.map((entry) => " " + dumpObject(entry)).join("\n ")} `); } @@ -286,7 +286,7 @@ async function _build( } // Done info - consola.success(chalk.green("Build succeeded for " + options.name)); + consola.success(colors.green("Build succeeded for " + options.name)); // Find all dist files and add missing entries as chunks const outFiles = await globby("**", { cwd: options.outDir }); @@ -313,12 +313,12 @@ async function _build( totalBytes += ctx.buildEntries.find((e) => e.path === chunk)?.bytes || 0; } let line = - ` ${chalk.bold(rPath(entry.path))} (` + + ` ${colors.bold(rPath(entry.path))} (` + [ - totalBytes && `total size: ${chalk.cyan(prettyBytes(totalBytes))}`, - entry.bytes && `chunk size: ${chalk.cyan(prettyBytes(entry.bytes))}`, + totalBytes && `total size: ${colors.cyan(prettyBytes(totalBytes))}`, + entry.bytes && `chunk size: ${colors.cyan(prettyBytes(entry.bytes))}`, entry.exports?.length && - `exports: ${chalk.gray(entry.exports.join(", "))}`, + `exports: ${colors.gray(entry.exports.join(", "))}`, ] .filter(Boolean) .join(", ") + @@ -330,10 +330,10 @@ async function _build( .map((p) => { const chunk = ctx.buildEntries.find((e) => e.path === p) || ({} as any); - return chalk.gray( + return colors.gray( " └─ " + rPath(p) + - chalk.bold( + colors.bold( chunk.bytes ? ` (${prettyBytes(chunk?.bytes)})` : "", ), ); @@ -347,19 +347,19 @@ async function _build( .filter((m) => m.id.includes("node_modules")) .sort((a, b) => (b.bytes || 0) - (a.bytes || 0)) .map((m) => { - return chalk.gray( + return colors.gray( " 📦 " + rPath(m.id) + - chalk.bold(m.bytes ? ` (${prettyBytes(m.bytes)})` : ""), + colors.bold(m.bytes ? ` (${prettyBytes(m.bytes)})` : ""), ); }) .join("\n"); } - consola.log(entry.chunk ? chalk.gray(line) : line); + consola.log(entry.chunk ? colors.gray(line) : line); } console.log( "Σ Total dist size (byte size):", - chalk.cyan( + colors.cyan( prettyBytes(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0)), ), ); diff --git a/src/builders/rollup/watch.ts b/src/builders/rollup/watch.ts index 4647ad6e..cde6f6e3 100644 --- a/src/builders/rollup/watch.ts +++ b/src/builders/rollup/watch.ts @@ -2,7 +2,7 @@ import { relative } from "pathe"; import { watch as _rollupWatch } from "rollup"; import type { RollupOptions } from "../../types"; import consola from "consola"; -import chalk from "chalk"; +import { colors } from "consola/utils"; export function rollupWatch(rollupOptions: RollupOptions): void { const watcher = _rollupWatch(rollupOptions); @@ -24,16 +24,16 @@ export function rollupWatch(rollupOptions: RollupOptions): void { ); watcher.on("change", (id, { event }) => { - consola.info(`${chalk.cyan(relative(".", id))} was ${event}d`); + consola.info(`${colors.cyan(relative(".", id))} was ${event}d`); }); watcher.on("restart", () => { - consola.info(chalk.gray("[unbuild] [rollup] Rebuilding bundle")); + consola.info(colors.gray("[unbuild] [rollup] Rebuilding bundle")); }); watcher.on("event", (event) => { if (event.code === "END") { - consola.success(chalk.green("[unbuild] [rollup] Rebuild finished\n")); + consola.success(colors.green("[unbuild] [rollup] Rebuild finished\n")); } }); } diff --git a/src/validate.ts b/src/validate.ts index fa143cb8..27ba7b2e 100644 --- a/src/validate.ts +++ b/src/validate.ts @@ -1,7 +1,7 @@ import type { PackageJson } from "pkg-types"; import type { BuildContext } from "./types"; import { existsSync } from "node:fs"; -import chalk from "chalk"; +import { colors } from "consola/utils"; import { resolve } from "pathe"; import { arrayIncludes, extractExportFilenames, getpkg, warn } from "./utils"; @@ -34,14 +34,14 @@ export function validateDependencies(ctx: BuildContext): void { warn( ctx, "Potential unused dependencies found: " + - [...unusedDependencies].map((id) => chalk.cyan(id)).join(", "), + [...unusedDependencies].map((id) => colors.cyan(id)).join(", "), ); } if (implicitDependencies.size > 0 && !ctx.options.rollup.inlineDependencies) { warn( ctx, "Potential implicit dependencies found: " + - [...implicitDependencies].map((id) => chalk.cyan(id)).join(", "), + [...implicitDependencies].map((id) => colors.cyan(id)).join(", "), ); } } @@ -79,7 +79,7 @@ export function validatePackage( warn( ctx, `Potential missing package.json files: ${missingOutputs - .map((o) => chalk.cyan(o)) + .map((o) => colors.cyan(o)) .join(", ")}`, ); }