Skip to content

Commit 6a0d8ba

Browse files
committed
chore: bump version
1 parent 045c05f commit 6a0d8ba

35 files changed

+2070
-191
lines changed

packages/tailwindcss-patch/MIGRATION.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ This document describes the changes introduced by the full refactor of `tailwind
66
77
## 1. Package layout
88

9-
| Before | After |
10-
| --- | --- |
11-
| `src/core/**` mix of cache, patch and runtime helpers | Dedicated folders: `api/`, `cache/`, `patching/`, `runtime/`, `options/`, `extraction/` |
12-
| `CacheManager`, `InternalPatchOptions`, ad-hoc exports | `CacheStore`, `normalizeOptions`, typed helpers with explicit imports |
13-
| `processTailwindcss` | `runTailwindBuild` in `runtime/process-tailwindcss.ts` |
9+
| Before | After |
10+
| ------------------------------------------------------ | --------------------------------------------------------------------------------------- |
11+
| `src/core/**` mix of cache, patch and runtime helpers | Dedicated folders: `api/`, `cache/`, `patching/`, `runtime/`, `options/`, `extraction/` |
12+
| `CacheManager`, `InternalPatchOptions`, ad-hoc exports | `CacheStore`, `normalizeOptions`, typed helpers with explicit imports |
13+
| `processTailwindcss` | `runTailwindBuild` in `runtime/process-tailwindcss.ts` |
1414

1515
Imports such as `@/core/patcher` or `@/core/cache` must be updated. Use the new entry-points:
1616

@@ -25,7 +25,7 @@ import { applyTailwindPatches } from 'tailwindcss-patch/patching/patch-runner'
2525
### Previous shape
2626

2727
```ts
28-
new TailwindcssPatcher({
28+
const patcher = new TailwindcssPatcher({
2929
cache: { dir: '.cache', file: 'classes.json' },
3030
patch: {
3131
overwrite: true,
@@ -39,7 +39,7 @@ new TailwindcssPatcher({
3939
### New shape
4040

4141
```ts
42-
new TailwindcssPatcher({
42+
const patcher = new TailwindcssPatcher({
4343
overwrite: true,
4444
cache: {
4545
enabled: true,

packages/tailwindcss-patch/README-cn.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pnpm dlx tw-patch extract
3838

3939
### `extract` 常用参数
4040

41-
| 参数 | 说明 |
42-
| --- | --- |
43-
| `--cwd <dir>` | 指定读取配置的工作目录。 |
44-
| `--output <file>` | 覆盖输出文件路径。 |
45-
| `--format <json|lines>` | 切换 JSON(默认)或换行分隔的纯文本。 |
46-
| `--css <file>` | 使用 Tailwind v4 时指定 CSS 入口文件。 |
47-
| `--no-write` | 仅返回结果,不落盘。 |
41+
| 参数 | 说明 |
42+
| ------------------------ | -------------------------------------- |
43+
| `--cwd <dir>` | 指定读取配置的工作目录。 |
44+
| `--output <file>` | 覆盖输出文件路径。 |
45+
| `--format <json\|lines>` | 切换 JSON(默认)或换行分隔的纯文本。 |
46+
| `--css <file>` | 使用 Tailwind v4 时指定 CSS 入口文件。 |
47+
| `--no-write` | 仅返回结果,不落盘。 |
4848

4949
CLI 会通过 `@tailwindcss-mangle/config` 加载 `tailwindcss-patch.config.ts`。旧配置仍可使用,详情请参考 [迁移指南](./MIGRATION.md)
5050

@@ -111,9 +111,7 @@ export default defineConfig({
111111
version: 4,
112112
v4: {
113113
cssEntries: ['dist/tailwind.css'],
114-
sources: [
115-
{ base: 'src', pattern: '**/*.{html,tsx}', negated: false },
116-
],
114+
sources: [{ base: 'src', pattern: '**/*.{html,tsx}', negated: false }],
117115
},
118116
},
119117
applyPatches: {

packages/tailwindcss-patch/README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ pnpm dlx tw-patch extract
3838

3939
### Extract options
4040

41-
| Flag | Description |
42-
| --- | --- |
43-
| `--cwd <dir>` | Use a different working directory when loading configuration. |
44-
| `--output <file>` | Override the target file for the generated class list. |
45-
| `--format <json|lines>` | Switch between JSON output (default) and newline-delimited text. |
46-
| `--css <file>` | Provide a CSS entry file when working with Tailwind v4 projects. |
47-
| `--no-write` | Skip writing to disk and only return the collected classes. |
41+
| Flag | Description |
42+
| ------------------------ | ---------------------------------------------------------------- |
43+
| `--cwd <dir>` | Use a different working directory when loading configuration. |
44+
| `--output <file>` | Override the target file for the generated class list. |
45+
| `--format <json\|lines>` | Switch between JSON output (default) and newline-delimited text. |
46+
| `--css <file>` | Provide a CSS entry file when working with Tailwind v4 projects. |
47+
| `--no-write` | Skip writing to disk and only return the collected classes. |
4848

4949
The CLI loads `tailwindcss-patch.config.ts` via `@tailwindcss-mangle/config`. Legacy configs continue to work; see the [migration guide](./MIGRATION.md) for hints on the new fields.
5050

@@ -111,9 +111,7 @@ export default defineConfig({
111111
version: 4,
112112
v4: {
113113
cssEntries: ['dist/tailwind.css'],
114-
sources: [
115-
{ base: 'src', pattern: '**/*.{html,tsx}', negated: false },
116-
],
114+
sources: [{ base: 'src', pattern: '**/*.{html,tsx}', negated: false }],
117115
},
118116
},
119117
applyPatches: {

packages/tailwindcss-patch/how-it-works.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
id: 20230630
3-
title: 'How to get the context of tailwindcss at runtime?'
3+
title: "How to get the context of tailwindcss at runtime?"
44
date: 2023-06-30
5-
description: 'The core principle of `tailwindcss-patch`'
5+
description: "The core principle of `tailwindcss-patch`"
66
authors:
77
- icebreaker
88
tags:
9-
- 'tailwindcss'
10-
- 'context'
11-
- 'runtime'
12-
- 'plugin'
13-
- 'postcss'
9+
- "tailwindcss"
10+
- "context"
11+
- "runtime"
12+
- "plugin"
13+
- "postcss"
1414
---
1515

1616
# How to get the context of tailwindcss at runtime?
@@ -251,13 +251,13 @@ In this file, we create a `contextRef` object, `push` the context of `tailwindcs
251251

252252
At this point, we'll be able to create a method to get it
253253

254-
```js
254+
```ts
255255
function getContexts() {
256256
const twPath = require.resolve('tailwindcss')
257257

258258
const distPath = path.dirname(twPath)
259259

260-
let injectFilePath = path.join(distPath, 'plugin.js')
260+
const injectFilePath = path.join(distPath, 'plugin.js')
261261

262262
const mo = require(injectFilePath)
263263
if (mo.contextRef) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import type { PackageInfo } from 'local-pkg'
2+
import type { LegacyTailwindcssPatcherOptions } from '../options/legacy'
3+
import type { NormalizedTailwindcssPatchOptions } from '../options/types'
24
import type { ExtractResult, TailwindcssPatchOptions } from '../types'
35
import process from 'node:process'
4-
import { getPackageInfoSync } from 'local-pkg'
5-
import { coerce } from 'semver'
66
import fs from 'fs-extra'
7+
import { getPackageInfoSync } from 'local-pkg'
78
import path from 'pathe'
9+
import { coerce } from 'semver'
810
import { CacheStore } from '../cache/store'
9-
import { normalizeOptions } from '../options/normalize'
10-
import type { NormalizedTailwindcssPatchOptions } from '../options/types'
11-
import type { LegacyTailwindcssPatcherOptions } from '../options/legacy'
11+
import { extractValidCandidates as extractCandidates } from '../extraction/candidate-extractor'
12+
import logger from '../logger'
1213
import { fromLegacyOptions } from '../options/legacy'
14+
import { normalizeOptions } from '../options/normalize'
1315
import { applyTailwindPatches } from '../patching/patch-runner'
14-
import { loadRuntimeContexts } from '../runtime/context-registry'
1516
import { collectClassesFromContexts, collectClassesFromTailwindV4 } from '../runtime/class-collector'
17+
import { loadRuntimeContexts } from '../runtime/context-registry'
1618
import { runTailwindBuild } from '../runtime/process-tailwindcss'
17-
import logger from '../logger'
18-
import { extractValidCandidates as extractCandidates } from '../extraction/candidate-extractor'
1919

2020
type TailwindMajorVersion = 2 | 3 | 4
2121

packages/tailwindcss-patch/src/cli.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
import type { LegacyTailwindcssPatcherOptions } from './options/legacy'
12
import type { TailwindcssPatchOptions } from './types'
23
import process from 'node:process'
4+
35
import { CONFIG_NAME, getConfig, initConfig } from '@tailwindcss-mangle/config'
46
import { defu } from '@tailwindcss-mangle/shared'
57
import cac from 'cac'
6-
import logger from './logger'
8+
79
import { TailwindcssPatcher } from './api/tailwindcss-patcher'
10+
import logger from './logger'
811
import { fromLegacyOptions, fromUnifiedConfig } from './options/legacy'
912

1013
const cli = cac('tw-patch')
1114

1215
async function loadPatchOptions(cwd: string, overrides?: TailwindcssPatchOptions) {
1316
const { config } = await getConfig(cwd)
17+
const legacyConfig = config as (typeof config) & { patch?: LegacyTailwindcssPatcherOptions['patch'] }
1418
const base = config?.registry
1519
? fromUnifiedConfig(config.registry)
16-
: config?.patch
17-
? fromLegacyOptions({ patch: config.patch })
20+
: legacyConfig?.patch
21+
? fromLegacyOptions({ patch: legacyConfig.patch })
1822
: {}
1923
const merged = defu<TailwindcssPatchOptions, TailwindcssPatchOptions[]>(overrides ?? {}, base)
2024
return merged
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export { TailwindcssPatcher } from './api/tailwindcss-patcher'
2-
export { normalizeOptions } from './options/normalize'
32
export { CacheStore } from './cache/store'
43
export {
5-
extractValidCandidates,
64
extractRawCandidates,
75
extractRawCandidatesWithPositions,
6+
extractValidCandidates,
87
} from './extraction/candidate-extractor'
9-
export { loadRuntimeContexts } from './runtime/context-registry'
8+
export { default as logger } from './logger'
9+
export { normalizeOptions } from './options/normalize'
1010
export { collectClassesFromContexts, collectClassesFromTailwindV4 } from './runtime/class-collector'
11+
export { loadRuntimeContexts } from './runtime/context-registry'
1112
export { runTailwindBuild } from './runtime/process-tailwindcss'
12-
export { default as logger } from './logger'
1313
export * from './types'
1414
export { defineConfig } from '@tailwindcss-mangle/config'

packages/tailwindcss-patch/src/options/legacy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type {
44
TailwindNextOptions,
55
} from '@tailwindcss-mangle/config'
66
import type { PackageResolvingOptions } from 'local-pkg'
7-
import type { TailwindcssPatchOptions, ExtendLengthUnitsUserOptions } from './types'
87
import type { ILengthUnitsPatchOptions } from '../types'
8+
import type { ExtendLengthUnitsUserOptions, TailwindcssPatchOptions } from './types'
99

1010
export interface LegacyCacheOptions {
1111
dir?: string

packages/tailwindcss-patch/src/options/normalize.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import process from 'node:process'
2-
import path from 'pathe'
1+
import type { ILengthUnitsPatchOptions } from '../types'
32
import type {
3+
CacheStrategy,
4+
FeatureUserOptions,
45
NormalizedCacheOptions,
56
NormalizedFeatureOptions,
67
NormalizedOutputOptions,
78
NormalizedTailwindConfigOptions,
8-
NormalizedTailwindV4Options,
99
NormalizedTailwindcssPatchOptions,
10+
NormalizedTailwindV4Options,
11+
OutputUserOptions,
1012
TailwindcssPatchOptions,
1113
TailwindUserOptions,
1214
TailwindV4UserOptions,
1315
} from './types'
14-
import type { CacheStrategy, ExtendLengthUnitsUserOptions, FeatureUserOptions, OutputUserOptions } from './types'
15-
import type { ILengthUnitsPatchOptions } from '../types'
16+
import process from 'node:process'
17+
import path from 'pathe'
1618
import { pkgName } from '../constants'
1719

1820
function toPrettyValue(value: OutputUserOptions['pretty']): number | false {

packages/tailwindcss-patch/src/patching/operations/export-context/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import fs from 'fs-extra'
22
import path from 'pathe'
33
import logger from '../../../logger'
4-
import { transformPostcssPlugin, transformProcessTailwindFeaturesReturnContext } from './postcss-v3'
54
import { transformPostcssPluginV2, transformProcessTailwindFeaturesReturnContextV2 } from './postcss-v2'
5+
import { transformPostcssPlugin, transformProcessTailwindFeaturesReturnContext } from './postcss-v3'
66

77
export interface ExposeContextPatchParams {
88
rootDir: string

0 commit comments

Comments
 (0)