Skip to content

Commit

Permalink
fix: reduce bundle size
Browse files Browse the repository at this point in the history
  • Loading branch information
rushelex committed Oct 18, 2024
1 parent fec0c2b commit 4efcb33
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 275 deletions.
216 changes: 3 additions & 213 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@
}
},
"dependencies": {
"@rollup/pluginutils": "5.1.2",
"picocolors": "1.1.1"
},
"devDependencies": {
"@antfu/eslint-config": "3.8.0",
"@arethetypeswrong/cli": "0.16.4",
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@rollup/pluginutils": "5.1.2",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@types/lodash-es": "4.17.12",
Expand All @@ -89,9 +89,6 @@
"pkgroll": "2.5.0",
"prettier": "3.3.3",
"rollup": "4.24.0",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"rollup-plugin-typescript2": "0.36.0",
"semantic-release": "24.1.2",
"typescript": "5.6.3"
}
Expand Down
16 changes: 8 additions & 8 deletions src/context/formatOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export function formatOptions(options: Options): Required<Options> {
enabled = true,
include = [/\.[jt]sx?$/],
throwOnError = true,
formatOutModulePath,
formatOutModulePath = defaultFormatOutModulePath,
formatOut,
onStart,
onDetected,
onEnd,
onStart = () => undefined,
onDetected = () => undefined,
onEnd = () => undefined,
} = options;

let { exclude = DEFAULT_EXCLUDE, outputFilePath = '' } = options;
Expand All @@ -33,11 +33,11 @@ export function formatOptions(options: Options): Required<Options> {
exclude,
throwOnError,
outputFilePath,
formatOutModulePath: formatOutModulePath ?? defaultFormatOutModulePath,
formatOutModulePath,
formatOut: formatOut ?? getDefaultFormatOut(outputFilePath),
onStart: onStart ?? (() => undefined),
onDetected: onDetected ?? (() => undefined),
onEnd: onEnd ?? (() => undefined),
onStart,
onDetected,
onEnd,
};
}

Expand Down
8 changes: 5 additions & 3 deletions src/utils/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isNil, isObject, isString } from 'lodash-es';
import color from 'picocolors';
import { createColors } from 'picocolors';

import type { CircularDependenciesData } from '../types';

Expand All @@ -22,6 +22,8 @@ function JSONFormatter(): Formatter {
function PrettyFormatter(config?: PrettyFormatterConfig): Formatter {
const { colors = true } = config || {};

const color = createColors(colors);

return (data): string => {
if (!isNil(data) && isObject(data) && Object.keys(data).length === 0) {
return '';
Expand All @@ -38,10 +40,10 @@ function PrettyFormatter(config?: PrettyFormatterConfig): Formatter {

let group = '';

group += colors ? color.yellow(entryModuleId) : entryModuleId;
group += color.yellow(entryModuleId);

for (const currentCir of moduleNodes) {
group += `\n` + ` ${currentCir.join(colors ? color.blue(' -> ') : ' -> ')}`;
group += `\n` + ` ${currentCir.join(color.blue(' -> '))}`;
}

groups.push(group);
Expand Down
Loading

0 comments on commit 4efcb33

Please sign in to comment.