File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @tailwindcss-mangle/config ' : patch
3+ ---
4+
5+ Lazy-load ` c12 ` so CommonJS consumers avoid ESM require errors when loading the config helpers.
Original file line number Diff line number Diff line change 1+ import type { createDefineConfig , ResolvedConfig } from 'c12'
12import type { TailwindcssMangleConfig } from './types'
2- import { createDefineConfig , loadConfig } from 'c12'
33import fs from 'fs-extra'
44import path from 'pathe'
55import { CONFIG_NAME } from './constants'
66import { getDefaultUserConfig } from './defaults'
77
8- export function getConfig ( cwd ?: string ) {
8+ type DefineConfig = ReturnType < typeof createDefineConfig < TailwindcssMangleConfig > >
9+
10+ let c12Promise : Promise < typeof import ( 'c12' ) > | undefined
11+
12+ async function loadC12 ( ) {
13+ if ( ! c12Promise ) {
14+ c12Promise = import ( 'c12' )
15+ }
16+ return c12Promise
17+ }
18+
19+ export async function getConfig ( cwd ?: string ) : Promise < ResolvedConfig < TailwindcssMangleConfig > > {
20+ const { loadConfig } = await loadC12 ( )
921 return loadConfig < TailwindcssMangleConfig > ( {
1022 name : CONFIG_NAME ,
1123 defaults : {
@@ -15,7 +27,7 @@ export function getConfig(cwd?: string) {
1527 } )
1628}
1729
18- export const defineConfig = createDefineConfig < TailwindcssMangleConfig > ( )
30+ export const defineConfig : DefineConfig = config => config
1931
2032export function initConfig ( cwd : string ) {
2133 return fs . outputFile (
You can’t perform that action at this time.
0 commit comments