Skip to content

Commit

Permalink
Merge branch 'next' into feat/improve-debug-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait authored Dec 6, 2024
2 parents ab99449 + 1238d07 commit 9c6a069
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Improve debug logs to get better insights ([#15303](https://github.com/tailwindlabs/tailwindcss/pull/15303))
- Skip creating a compiler for CSS files that should not be processed ([#15303](https://github.com/tailwindlabs/tailwindcss/pull/15303))
- Ensure `@import "…" reference` never generates utilities ([#15307](https://github.com/tailwindlabs/tailwindcss/pull/15307))
- Improve debug logs to get better insights ([#15303](https://github.com/tailwindlabs/tailwindcss/pull/15303))

## [4.0.0-beta.5] - 2024-12-04

Expand Down
11 changes: 4 additions & 7 deletions integrations/vite/svelte.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test(
target: document.body,
})
`,
'src/index.css': css`@import 'tailwindcss' reference;`,
'src/index.css': css`@import 'tailwindcss';`,
'src/App.svelte': html`
<script>
import './index.css'
Expand All @@ -58,7 +58,7 @@ test(
<h1 class="global local underline">Hello {name}!</h1>
<style>
@import 'tailwindcss/theme' theme(reference);
@import 'tailwindcss' reference;
@import './other.css';
</style>
`,
Expand Down Expand Up @@ -165,14 +165,11 @@ test(
<h1 class="local global underline">Hello {name}!</h1>
<style>
@import 'tailwindcss/theme' theme(reference);
@import 'tailwindcss' reference;
@import './other.css';
</style>
`,
'src/index.css': css`
@import 'tailwindcss/theme' theme(reference);
@import 'tailwindcss/utilities';
`,
'src/index.css': css` @import 'tailwindcss'; `,
'src/other.css': css`
.local {
@apply text-red-500;
Expand Down
2 changes: 1 addition & 1 deletion integrations/vite/vue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test(
`,
'src/App.vue': html`
<style>
@import 'tailwindcss' reference;
@import 'tailwindcss';
.foo {
@apply text-red-500;
}
Expand Down
30 changes: 30 additions & 0 deletions packages/tailwindcss/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,36 @@ describe('`@import "…" reference`', () => {
`)
})

test('does not generate utilities', async () => {
let loadStylesheet = async (id: string, base: string) => {
if (id === './foo/baz.css') {
return {
content: css`
@layer utilities {
@tailwind utilities;
}
`,
base: '/root/foo',
}
}
return {
content: css`
@import './foo/baz.css';
`,
base: '/root/foo',
}
}

let { build } = await compile(
css`
@import './foo/bar.css' reference;
`,
{ loadStylesheet },
)

expect(build(['text-underline', 'border']).trim()).toMatchInlineSnapshot(`"@layer utilities;"`)
})

test('removes styles when the import resolver was handled outside of Tailwind CSS', async () => {
await expect(
compileCss(
Expand Down
16 changes: 13 additions & 3 deletions packages/tailwindcss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,21 @@ async function parseCss(
return WalkAction.Skip
}

// Other at-rules, like `@media`, `@supports`, or `@layer` should
// be recursively traversed as these might be inserted by the
// `@import` resolution.
case '@media':
case '@supports':
case '@layer': {
// These rules should be recursively traversed as these might be
// inserted by the `@import` resolution.
return
}

default: {
replaceWith([])
return WalkAction.Skip
}
}
})

node.nodes = [contextNode({ reference: true }, node.nodes)]
}

Expand Down

0 comments on commit 9c6a069

Please sign in to comment.