From 44042f392ccaaeb23dd2079c39f39d740fa505f3 Mon Sep 17 00:00:00 2001 From: felixfon <66350602+felixfon@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:04:48 +0800 Subject: [PATCH 1/2] fix: remove decimal places when displaying only bytes --- src/lib/report-size.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/report-size.ts b/src/lib/report-size.ts index 6603df7f..06dd9335 100644 --- a/src/lib/report-size.ts +++ b/src/lib/report-size.ts @@ -2,7 +2,7 @@ import colors from 'picocolors' import type { Logger } from '../log' const prettyBytes = (bytes: number) => { - if (bytes === 0) return '0 B' + if (bytes < 1024) return `${bytes} B` const unit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] const exp = Math.floor(Math.log(bytes) / Math.log(1024)) return `${(bytes / 1024 ** exp).toFixed(2)} ${unit[exp]}` From 072031370d92931ebbb69630d5b144208e539b95 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 20 Mar 2026 14:21:48 +0000 Subject: [PATCH 2/2] chore(ci): [bot] format code --- assets/cjs_shims.js | 13 +++++++------ docs/README.md | 17 +++++++++-------- src/esbuild/swc.ts | 5 ++++- src/options.ts | 4 ++-- vitest.config.mts | 2 +- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/assets/cjs_shims.js b/assets/cjs_shims.js index ea603830..9342fe24 100644 --- a/assets/cjs_shims.js +++ b/assets/cjs_shims.js @@ -3,11 +3,12 @@ // if we export it as `const importMetaUrl = ... __filename ...` // But using a function will not cause this issue -const getImportMetaUrl = () => - typeof document === "undefined" - ? new URL(`file:${__filename}`).href - : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') - ? document.currentScript.src - : new URL("main.js", document.baseURI).href; +const getImportMetaUrl = () => + typeof document === 'undefined' + ? new URL(`file:${__filename}`).href + : document.currentScript && + document.currentScript.tagName.toUpperCase() === 'SCRIPT' + ? document.currentScript.src + : new URL('main.js', document.baseURI).href export const importMetaUrl = /* @__PURE__ */ getImportMetaUrl() diff --git a/docs/README.md b/docs/README.md index e9816cec..e095f33f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -615,6 +615,7 @@ When you use legacy TypeScript decorator by enabling `emitDecoratorMetadata` in decorators. In this case, you can give extra swc configuration in the `tsup.config.ts` file. For example, if you have to define `useDefineForClassFields`, you can do that as follows: + ```ts import { defineConfig } from 'tsup' @@ -626,10 +627,10 @@ export default defineConfig({ swc: { jsc: { transform: { - useDefineForClassFields: true - } - } - } + useDefineForClassFields: true, + }, + }, + }, }) ``` @@ -648,9 +649,9 @@ Note: some SWC options cannot be configured: "keepClassNames": true, "target": "es2022" } - ``` +``` -You can also define a custom `.swcrc` configuration file. Just set `swcrc` to `true` +You can also define a custom `.swcrc` configuration file. Just set `swcrc` to `true` in `tsup.config.ts` to allow SWC plugin to discover automatically your custom swc config file. ```ts @@ -662,8 +663,8 @@ export default defineConfig({ sourcemap: true, clean: true, swc: { - swcrc: true - } + swcrc: true, + }, }) ``` diff --git a/src/esbuild/swc.ts b/src/esbuild/swc.ts index 755009d3..ee12c1dc 100644 --- a/src/esbuild/swc.ts +++ b/src/esbuild/swc.ts @@ -9,7 +9,10 @@ import type { Logger } from '../log' export type SwcPluginConfig = { logger: Logger } & Options -export const swcPlugin = ({ logger, ...swcOptions }: SwcPluginConfig): Plugin => { +export const swcPlugin = ({ + logger, + ...swcOptions +}: SwcPluginConfig): Plugin => { return { name: 'swc', diff --git a/src/options.ts b/src/options.ts index 6bbee23b..7f68bd8c 100644 --- a/src/options.ts +++ b/src/options.ts @@ -257,8 +257,8 @@ export type Options = { * @default true */ removeNodeProtocol?: boolean - - swc?: SwcPluginConfig; + + swc?: SwcPluginConfig } export interface NormalizedExperimentalDtsConfig { diff --git a/vitest.config.mts b/vitest.config.mts index 8f6d3ac6..7e032eda 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -4,6 +4,6 @@ export default defineConfig({ test: { testTimeout: 50000, globalSetup: 'vitest-global.ts', - include: ["test/*.test.ts", "src/**/*.test.ts"] + include: ['test/*.test.ts', 'src/**/*.test.ts'], }, })