Skip to content

Commit 736823e

Browse files
Merge branch 'main' into main
2 parents e2f904c + 5916b34 commit 736823e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2787
-1560
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Format quotes in `@source`, `@plugin`, and `@config` ([#387](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/387))
1313
- Support sorting in callable template literals ([#367](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/367))
1414
- Support sorting in function calls mixed with property accesses ([#367](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/367))
15+
- Handle quote escapes in LESS when sorting `@apply` ([#392](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/392))
16+
- Improved monorepo support by loading Tailwind CSS relative to the input file instead of prettier config file ([#386](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/386))
17+
- Improved monorepo support by loading v3 configs relative to the input file instead of prettier config file ([#386](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/386))
18+
- Fix whitespace removal inside nested concat and template expressions ([#396](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/396))
19+
- Fallback to Tailwind CSS v4 instead of v3 by default ([#390](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/390))
1520
- Support sorting in function calls in Twig ([#358](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/358))
1621

1722
## [0.6.14] - 2025-07-09

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ This plugin uses Prettier APIs that can only be used by one plugin at a time, ma
230230
- `prettier-plugin-multiline-arrays`
231231
- `prettier-plugin-organize-attributes`
232232
- `prettier-plugin-organize-imports`
233-
- `prettier-plugin-style-order`
234233
- `prettier-plugin-svelte`
235234
- `prettier-plugin-sort-imports`
236235

build.mjs

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as fs from 'node:fs'
2+
import { readFile } from 'node:fs/promises'
23
import * as path from 'node:path'
34
import { fileURLToPath } from 'node:url'
45
import esbuild from 'esbuild'
@@ -30,6 +31,28 @@ function patchRecast() {
3031
}
3132
}
3233

34+
/**
35+
* @returns {import('esbuild').Plugin}
36+
*/
37+
function patchJiti() {
38+
return {
39+
name: 'patch-jiti',
40+
setup(build) {
41+
// TODO: Switch to rolldown and see if we can chunk split this instead?
42+
build.onLoad({ filter: /jiti\/lib\/jiti\.mjs$/ }, async (args) => {
43+
let original = await fs.promises.readFile(args.path, 'utf8')
44+
45+
return {
46+
contents: original.replace(
47+
'createRequire(import.meta.url)("../dist/babel.cjs")',
48+
'require("../dist/babel.cjs")',
49+
),
50+
}
51+
})
52+
},
53+
}
54+
}
55+
3356
/**
3457
* @returns {import('esbuild').Plugin}
3558
*/
@@ -46,11 +69,11 @@ function patchCjsInterop() {
4669
let code = [
4770
`import {createRequire as __global__createRequire__} from 'module'`,
4871
`import {dirname as __global__dirname__} from 'path'`,
49-
`import {fileURLToPath} from 'url'`,
72+
`import {fileURLToPath as __global__fileURLToPath__} from 'url'`,
5073

5174
// CJS interop fixes
5275
`const require=__global__createRequire__(import.meta.url)`,
53-
`const __filename=fileURLToPath(import.meta.url)`,
76+
`const __filename=__global__fileURLToPath__(import.meta.url)`,
5477
`const __dirname=__global__dirname__(__filename)`,
5578
]
5679

@@ -62,6 +85,47 @@ function patchCjsInterop() {
6285
}
6386
}
6487

88+
/**
89+
* @returns {import('esbuild').Plugin}
90+
*/
91+
function inlineCssImports() {
92+
return {
93+
name: 'inline-css-imports',
94+
setup(build) {
95+
// Inline CSS imports
96+
build.onLoad({ filter: /\.css$/ }, async (args) => {
97+
let content = await readFile(args.path, 'utf-8')
98+
99+
return {
100+
loader: 'js',
101+
contents: `export default ${JSON.stringify(content)}`,
102+
}
103+
})
104+
105+
// Inline preflight in v3
106+
// TODO: This needs a test
107+
build.onLoad({ filter: /corePlugins\.js$/ }, async (args) => {
108+
let preflightPath = path.resolve(path.dirname(args.path), './css/preflight.css')
109+
let preflightContent = await readFile(preflightPath, 'utf-8')
110+
111+
let content = await readFile(args.path, 'utf-8')
112+
113+
// This is a bit fragile but this is to inline preflight for the
114+
// *bundled* version which means a failing test should be enough
115+
content = content.replace(
116+
`_fs.default.readFileSync(_path.join(__dirname, "./css/preflight.css"), "utf8")`,
117+
JSON.stringify(preflightContent),
118+
)
119+
120+
return {
121+
loader: 'js',
122+
contents: content,
123+
}
124+
})
125+
},
126+
}
127+
}
128+
65129
const __dirname = path.dirname(fileURLToPath(import.meta.url))
66130

67131
let context = await esbuild.context({
@@ -73,7 +137,7 @@ let context = await esbuild.context({
73137
entryPoints: [path.resolve(__dirname, './src/index.js')],
74138
outfile: path.resolve(__dirname, './dist/index.mjs'),
75139
format: 'esm',
76-
plugins: [patchRecast(), patchCjsInterop()],
140+
plugins: [patchRecast(), patchJiti(), patchCjsInterop(), inlineCssImports()],
77141
})
78142

79143
await context.rebuild()

0 commit comments

Comments
 (0)