From c52a4d6145972a9c28f9bf81ab51f13acd7bbfb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 17 Sep 2024 13:48:55 +0800 Subject: [PATCH] style: format code --- src/esbuild/postcss.ts | 13 ++++++++----- src/index.ts | 13 ++++++++----- src/options.ts | 10 ++++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/esbuild/postcss.ts b/src/esbuild/postcss.ts index 7312d7346..1086827dc 100644 --- a/src/esbuild/postcss.ts +++ b/src/esbuild/postcss.ts @@ -122,11 +122,14 @@ export const postcssPlugin = ({ }) ).code - contents = typeof inject === 'function' - ? await Promise.resolve(inject(JSON.stringify(contents), args.path)) - : `import styleInject from '#style-inject';styleInject(${JSON.stringify( - contents, - )})` + contents = + typeof inject === 'function' + ? await Promise.resolve( + inject(JSON.stringify(contents), args.path), + ) + : `import styleInject from '#style-inject';styleInject(${JSON.stringify( + contents, + )})` return { contents, diff --git a/src/index.ts b/src/index.ts index b3551226f..2b6941593 100644 --- a/src/index.ts +++ b/src/index.ts @@ -209,8 +209,8 @@ export async function build(_options: Options) { const experimentalDtsTask = async () => { if (!options.dts && options.experimentalDts) { - const exports = runTypeScriptCompiler(options); - await runDtsRollup(options, exports); + const exports = runTypeScriptCompiler(options) + await runDtsRollup(options, exports) } } @@ -221,7 +221,7 @@ export async function build(_options: Options) { ) } - experimentalDtsTask(); + experimentalDtsTask() if (options.dts) { await new Promise((resolve, reject) => { @@ -236,7 +236,10 @@ export async function build(_options: Options) { configName: item?.name, options: { ...options, // functions cannot be cloned - injectStyle: typeof options.injectStyle === 'function' ? undefined : options.injectStyle, + injectStyle: + typeof options.injectStyle === 'function' + ? undefined + : options.injectStyle, banner: undefined, footer: undefined, esbuildPlugins: undefined, @@ -357,7 +360,7 @@ export async function build(_options: Options) { ]) experimentalDtsTask() - + if (options.onSuccess) { if (typeof options.onSuccess === 'function') { onSuccessCleanup = await options.onSuccess() diff --git a/src/options.ts b/src/options.ts index 50f44d55c..9f7f16435 100644 --- a/src/options.ts +++ b/src/options.ts @@ -86,7 +86,11 @@ export type EsTarget = | 'es2023' | 'esnext' -export type Target = BrowserTarget | BrowserTargetWithVersion | EsTarget | (string & {}) +export type Target = + | BrowserTarget + | BrowserTargetWithVersion + | EsTarget + | (string & {}) export type Entry = string[] | Record @@ -211,7 +215,9 @@ export type Options = { * Inject CSS as style tags to document head * @default {false} */ - injectStyle?: boolean | ((css: string, fileId: string) => string | Promise) + injectStyle?: + | boolean + | ((css: string, fileId: string) => string | Promise) /** * Inject cjs and esm shims if needed * @default false