Skip to content

Commit

Permalink
style: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Sep 17, 2024
1 parent 1979b06 commit c52a4d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/esbuild/postcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -221,7 +221,7 @@ export async function build(_options: Options) {
)
}

experimentalDtsTask();
experimentalDtsTask()

if (options.dts) {
await new Promise<void>((resolve, reject) => {
Expand All @@ -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,
Expand Down Expand Up @@ -357,7 +360,7 @@ export async function build(_options: Options) {
])

experimentalDtsTask()

if (options.onSuccess) {
if (typeof options.onSuccess === 'function') {
onSuccessCleanup = await options.onSuccess()
Expand Down
10 changes: 8 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>

Expand Down Expand Up @@ -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<string>)
injectStyle?:
| boolean
| ((css: string, fileId: string) => string | Promise<string>)
/**
* Inject cjs and esm shims if needed
* @default false
Expand Down

0 comments on commit c52a4d6

Please sign in to comment.