Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/tailwindcss/src/at-import.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ async function run(
candidates = [],
optimize = true,
}: {
loadStylesheet?: (id: string, base: string) => Promise<{ content: string; base: string }>
loadStylesheet?: (
id: string,
base: string,
) => Promise<{ content: string; base: string; path: string }>
loadModule?: (
id: string,
base: string,
resourceHint: 'plugin' | 'config',
) => Promise<{ module: Config | Plugin; base: string }>
) => Promise<{ module: Config | Plugin; base: string; path: string }>
candidates?: string[]
optimize?: boolean
},
Expand All @@ -41,6 +44,7 @@ test('can resolve relative @imports', async () => {
}
`,
base: '/root/foo',
path: '',
}
}

Expand All @@ -67,6 +71,7 @@ test('can recursively resolve relative @imports', async () => {
@import './bar/baz.css';
`,
base: '/root/foo',
path: '',
}
} else if (base === '/root/foo' && id === './bar/baz.css') {
return {
Expand All @@ -76,6 +81,7 @@ test('can recursively resolve relative @imports', async () => {
}
`,
base: '/root/foo/bar',
path: '',
}
}

Expand Down Expand Up @@ -107,6 +113,7 @@ let loadStylesheet = async (id: string) => {
return {
content: exampleCSS,
base: '/root',
path: '',
}
}

Expand Down Expand Up @@ -415,6 +422,7 @@ test('supports theme(reference) imports', async () => {
}
`,
base: '',
path: '',
}),
candidates: ['text-red-500'],
},
Expand All @@ -435,8 +443,9 @@ test('updates the base when loading modules inside nested files', async () => {
@plugin './nested-plugin.js';
`,
base: '/root/foo',
path: '',
})
let loadModule = vi.fn().mockResolvedValue({ base: '', module: () => {} })
let loadModule = vi.fn().mockResolvedValue({ base: '', path: '', module: () => {} })

expect(
(
Expand Down Expand Up @@ -464,6 +473,7 @@ test('emits the right base for @source directives inside nested files', async ()
@source './nested/**/*.css';
`,
base: '/root/foo',
path: '',
})

let compiler = await compile(
Expand All @@ -488,6 +498,7 @@ test('emits the right base for @source found inside JS configs and plugins from
@plugin './nested-plugin.js';
`,
base: '/root/foo',
path: '',
})
let loadModule = vi.fn().mockImplementation((id: string) => {
let base = id.includes('nested') ? '/root/foo' : '/root'
Expand All @@ -502,12 +513,14 @@ test('emits the right base for @source found inside JS configs and plugins from
plugins: [plugin(() => {}, { content: [pluginGlob] })],
} satisfies Config,
base: base + '-config',
path: '',
}
} else {
let glob = id.includes('nested') ? './nested-plugin/*.html' : './root-plugin/*.html'
return {
module: plugin(() => {}, { content: [glob] }),
base: base + '-plugin',
path: '',
}
}
})
Expand Down Expand Up @@ -540,6 +553,7 @@ test('it crashes when inside a cycle', async () => {
@import 'foo.css';
`,
base: '/root',
path: '',
})

await expect(
Expand Down Expand Up @@ -568,6 +582,7 @@ test('resolves @reference as `@import "…" reference`', async () => {
}
`,
base: '/root/foo',
path: '',
}
}

Expand Down Expand Up @@ -600,6 +615,7 @@ test('resolves `@variant` used as `@custom-variant` inside `@reference`', async
}
`,
base: '/root/foo',
path: '',
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/tailwindcss/src/compat/apply-compat-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function upgradeToFullPluginSupport({
// config would otherwise expand into namespaces like `background-color` which
// core utilities already read from.
applyConfigToTheme(designSystem, resolvedUserConfig, replacedThemeKeys)
applyKeyframesToTheme(designSystem, resolvedUserConfig, replacedThemeKeys)
applyKeyframesToTheme(designSystem, resolvedUserConfig)

registerThemeVariantOverrides(resolvedUserConfig, designSystem)
registerScreensConfig(resolvedUserConfig, designSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ test('config values can be merged into the theme', () => {
},
base: '/root',
reference: false,
src: undefined,
},
])
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
Expand Down Expand Up @@ -160,6 +161,8 @@ test('will reset default theme values with overwriting theme values', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
Expand Down Expand Up @@ -189,6 +192,8 @@ test('invalid keys are not merged into the theme', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])

Expand Down Expand Up @@ -227,6 +232,8 @@ test('converts opacity modifiers from decimal to percentage values', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
Expand Down Expand Up @@ -261,6 +268,7 @@ test('handles setting theme keys to null', async () => {
},
base: '/root',
reference: false,
src: undefined,
},
])
applyConfigToTheme(design, resolvedConfig, replacedThemeKeys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test('keyframes can be merged into the theme', () => {
let theme = new Theme()
let design = buildDesignSystem(theme)

let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [
let { resolvedConfig } = resolveConfig(design, [
{
config: {
theme: {
Expand All @@ -28,9 +28,11 @@ test('keyframes can be merged into the theme', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])
applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys)
applyKeyframesToTheme(design, resolvedConfig)

expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(`
"@keyframes fade-in {
Expand Down Expand Up @@ -70,7 +72,7 @@ test('will append to the default keyframes with new keyframes', () => {
]),
)

let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [
let { resolvedConfig } = resolveConfig(design, [
{
config: {
theme: {
Expand All @@ -91,9 +93,11 @@ test('will append to the default keyframes with new keyframes', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])
applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys)
applyKeyframesToTheme(design, resolvedConfig)

expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(`
"@keyframes slide-in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { objectToAst } from './plugin-api'
export function applyKeyframesToTheme(
designSystem: DesignSystem,
resolvedConfig: Pick<ResolvedConfig, 'theme'>,
replacedThemeKeys: Set<string>,
) {
for (let rule of keyframesToRules(resolvedConfig)) {
designSystem.theme.addKeyframes(rule)
Expand Down
20 changes: 20 additions & 0 deletions packages/tailwindcss/src/compat/config/resolve-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ test('top level theme keys are replaced', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
{
config: {
Expand All @@ -30,6 +32,8 @@ test('top level theme keys are replaced', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
{
config: {
Expand All @@ -40,6 +44,8 @@ test('top level theme keys are replaced', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])

Expand Down Expand Up @@ -73,6 +79,8 @@ test('theme can be extended', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
{
config: {
Expand All @@ -85,6 +93,8 @@ test('theme can be extended', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])

Expand Down Expand Up @@ -120,6 +130,8 @@ test('theme keys can reference other theme keys using the theme function regardl
},
},
base: '/root',
reference: false,
src: undefined,
},
{
config: {
Expand All @@ -133,6 +145,8 @@ test('theme keys can reference other theme keys using the theme function regardl
},
},
base: '/root',
reference: false,
src: undefined,
},
{
config: {
Expand All @@ -145,6 +159,8 @@ test('theme keys can reference other theme keys using the theme function regardl
},
},
base: '/root',
reference: false,
src: undefined,
},
])

Expand Down Expand Up @@ -212,6 +228,8 @@ test('theme keys can read from the CSS theme', () => {
},
},
base: '/root',
reference: false,
src: undefined,
},
])

Expand Down Expand Up @@ -274,6 +292,7 @@ test('handles null as theme values', () => {
},
base: '/root',
reference: false,
src: undefined,
},
{
config: {
Expand All @@ -287,6 +306,7 @@ test('handles null as theme values', () => {
},
base: '/root',
reference: false,
src: undefined,
},
])

Expand Down
8 changes: 8 additions & 0 deletions packages/tailwindcss/src/compat/container-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test('creates a custom utility to extend the built-in container', async () => {
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -85,6 +86,7 @@ test('allows padding to be defined at custom breakpoints', async () => {
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -146,6 +148,7 @@ test('allows breakpoints to be overwritten', async () => {
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -212,6 +215,7 @@ test('padding applies to custom `container` screens', async () => {
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -275,6 +279,7 @@ test("an empty `screen` config will undo all custom media screens and won't appl
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -340,6 +345,7 @@ test('legacy container component does not interfere with new --container variabl
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -386,6 +392,7 @@ test('combines custom padding and screen overwrites', async () => {
},
},
base: '/root',
path: '',
}),
})

Expand Down Expand Up @@ -498,6 +505,7 @@ test('filters out complex breakpoints', async () => {
},
},
base: '/root',
path: '',
}),
})

Expand Down
Loading