Skip to content

Commit e87d048

Browse files
committed
chore: bump version
1 parent b0cb866 commit e87d048

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

.changeset/new-flowers-hug.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tailwindcss-patch": patch
3+
"@tailwindcss-mangle/config": patch
4+
---
5+
6+
fix: tw-patch extract error

packages/config/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { FilterPattern } from '@rollup/pluginutils'
22
import type { IClassGeneratorOptions } from '@tailwindcss-mangle/shared'
33
import type { PackageResolvingOptions } from 'local-pkg'
4+
45
export interface ClassMapOutputOptions {
56
enable?: boolean
67
filename?: string

packages/tailwindcss-patch/src/cli.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import process from 'node:process'
22
import { CONFIG_NAME, getConfig, initConfig } from '@tailwindcss-mangle/config'
3+
import { defuOverrideArray } from '@tailwindcss-mangle/shared'
34
import cac from 'cac'
45
import { TailwindcssPatcher } from './core'
56
import { getPatchOptions } from './defaults'
@@ -27,9 +28,17 @@ cli.command('init').action(async () => {
2728
cli.command('extract').action(async () => {
2829
const { config } = await getConfig()
2930
if (config) {
30-
const twPatcher = new TailwindcssPatcher()
31-
const p = await twPatcher.extract(config.patch)
32-
logger.success(`✨ tailwindcss-patch extract success! file path: ${p}`)
31+
const twPatcher = new TailwindcssPatcher(
32+
{
33+
patch: defuOverrideArray(config.patch!, {
34+
resolve: {
35+
paths: [import.meta.url],
36+
},
37+
}),
38+
},
39+
)
40+
const p = await twPatcher.extract()
41+
p && logger.success(`✨ tailwindcss-patch extract success! file path: ${p.filename}, classList length: ${p.classList.length}`)
3342
}
3443
})
3544

packages/tailwindcss-patch/src/core/patcher.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { PatchUserConfig } from '@tailwindcss-mangle/config'
21
import type { InternalCacheOptions, InternalPatchOptions, PackageInfo, TailwindcssClassCache, TailwindcssPatcherOptions, TailwindcssRuntimeContext } from '../types'
32
import { createRequire } from 'node:module'
43
import process from 'node:process'
@@ -193,8 +192,8 @@ export class TailwindcssPatcher {
193192
return set
194193
}
195194

196-
async extract(options?: PatchUserConfig) {
197-
const { output, tailwindcss } = options ?? {}
195+
async extract() {
196+
const { output, tailwindcss } = this.patchOptions
198197
if (output && tailwindcss) {
199198
const { filename, loose } = output
200199

@@ -211,7 +210,10 @@ export class TailwindcssPatcher {
211210
await fs.outputJSON(filename, classList, {
212211
spaces: loose ? 2 : undefined,
213212
})
214-
return filename
213+
return {
214+
filename,
215+
classList,
216+
}
215217
}
216218
}
217219
}

packages/tailwindcss-patch/test/cache.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { pkgName } from '@/constants'
22
import { CacheManager, TailwindcssPatcher } from '@/core'
33
import { getCacheOptions } from '@/core/cache'
4+
import { isCI } from 'ci-info'
45
import fs from 'fs-extra'
56
import path from 'pathe'
67
import { getCss } from './utils'
@@ -70,7 +71,7 @@ describe('cache', () => {
7071
expect(fs.existsSync(filepath)).toBe(false)
7172
})
7273

73-
it('multiple tw context merge cache', async () => {
74+
it.skipIf(isCI)('multiple tw context merge cache', async () => {
7475
const dir = path.resolve(__dirname, './fixtures/cache')
7576
const twPatcher = new TailwindcssPatcher({
7677
cache: {

0 commit comments

Comments
 (0)