Skip to content

Commit df4d4ae

Browse files
Don't change structure of ResolvedConfig
1 parent cbfb848 commit df4d4ae

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

packages/tailwindcss/src/compat/apply-compat-hooks.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ function upgradeToFullPluginSupport({
259259
},
260260
})
261261

262-
for (let {
263-
plugin: { handler },
264-
reference,
265-
} of resolvedConfig.plugins) {
262+
for (let { handler, reference } of resolvedConfig.plugins) {
266263
handler(reference ? { ...pluginApi, addBase: () => {} } : pluginApi)
267264
}
268265

packages/tailwindcss/src/compat/config/resolve-config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface ConfigFile {
2121
interface ResolutionContext {
2222
design: DesignSystem
2323
configs: UserConfig[]
24-
plugins: { plugin: PluginWithConfig; reference: boolean }[]
24+
plugins: PluginWithConfig[]
2525
content: ResolvedContentConfig
2626
theme: Record<string, ThemeValue>
2727
extend: Record<string, ThemeValue[]>
@@ -133,24 +133,24 @@ function extractConfigs(
133133
ctx: ResolutionContext,
134134
{ config, base, path, reference }: ConfigFile,
135135
): void {
136-
let plugins: { plugin: PluginWithConfig; reference: boolean }[] = []
136+
let plugins: PluginWithConfig[] = []
137137

138138
// Normalize plugins so they share the same shape
139139
for (let plugin of config.plugins ?? []) {
140140
if ('__isOptionsFunction' in plugin) {
141141
// Happens with `plugin.withOptions()` when no options were passed:
142142
// e.g. `require("my-plugin")` instead of `require("my-plugin")(options)`
143-
plugins.push({ plugin: plugin(), reference })
143+
plugins.push({ ...plugin(), reference })
144144
} else if ('handler' in plugin) {
145145
// Happens with `plugin(…)`:
146146
// e.g. `require("my-plugin")`
147147
//
148148
// or with `plugin.withOptions()` when the user passed options:
149149
// e.g. `require("my-plugin")(options)`
150-
plugins.push({ plugin, reference })
150+
plugins.push({ ...plugin, reference })
151151
} else {
152152
// Just a plain function without using the plugin(…) API
153-
plugins.push({ plugin: { handler: plugin }, reference })
153+
plugins.push({ handler: plugin, reference })
154154
}
155155
}
156156

@@ -169,8 +169,8 @@ function extractConfigs(
169169
for (let plugin of plugins) {
170170
ctx.plugins.push(plugin)
171171

172-
if (plugin.plugin.config) {
173-
extractConfigs(ctx, { path, base, config: plugin.plugin.config, reference })
172+
if (plugin.config) {
173+
extractConfigs(ctx, { path, base, config: plugin.config, reference: plugin.reference })
174174
}
175175
}
176176

packages/tailwindcss/src/compat/config/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type ThemeConfig = Record<string, ThemeValue> & {
1818

1919
export interface ResolvedConfig {
2020
theme: Record<string, Record<string, unknown>>
21-
plugins: { plugin: PluginWithConfig; reference: boolean }[]
21+
plugins: PluginWithConfig[]
2222
}
2323

2424
// Content support

packages/tailwindcss/src/compat/plugin-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import * as SelectorParser from './selector-parser'
1717

1818
export type Config = UserConfig
1919
export type PluginFn = (api: PluginAPI) => void
20-
export type PluginWithConfig = { handler: PluginFn; config?: UserConfig }
20+
export type PluginWithConfig = { handler: PluginFn; config?: UserConfig; reference: boolean }
2121
export type PluginWithOptions<T> = {
2222
(options?: T): PluginWithConfig
2323
__isOptionsFunction: true

0 commit comments

Comments
 (0)