Skip to content

Commit 0d47ffd

Browse files
authored
Fix cloning issues (tailwindlabs#4646)
* ensure postcss 7 is dropped from dev dependencies as well Drop incorrect "help" text * ensure we are cloning nodes This is an issue in postcss 7 and fixed in postcss 8. However the compat build still suffers form this issue.
1 parent 03eab31 commit 0d47ffd

2 files changed

Lines changed: 13 additions & 25 deletions

File tree

scripts/compat.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,23 @@ if (process.argv.includes('--prepare')) {
3737
// 5. Remove peerDependencies
3838
delete packageJson.peerDependencies
3939

40-
// 6. Use new name
40+
// 6. Cleanup devDependencies
41+
for (let key in packageJson.devDependencies) {
42+
if (key.includes('postcss')) delete packageJson.devDependencies[key]
43+
}
44+
45+
// 7. Use new name
4146
packageJson.name = '@tailwindcss/postcss7-compat'
4247

43-
// 7. Make sure you can publish
48+
// 8. Make sure you can publish
4449
packageJson.publishConfig = { access: 'public' }
4550

46-
// 8. Write package.json with the new contents
51+
// 9. Write package.json with the new contents
4752
fs.writeFileSync(fromRootPath('package.json'), JSON.stringify(packageJson, null, 2), 'utf8')
4853

49-
// 9. Print some useful information to make publishing easy
54+
// 10. Print some useful information to make publishing easy
5055
console.log()
5156
console.log('You can safely publish `tailwindcss` in PostCSS 7 compatibility mode:\n')
52-
console.log(
53-
[
54-
// Not necessary, but a quick 'hash', basically the current date/time
55-
`git checkout -b compat-${new Date()
56-
.toJSON()
57-
.replace(/[-:.TZ]/g, '') // Remove weird characters
58-
.slice(0, -3)}`, // Remove milliseconds precision
59-
'git add .',
60-
'git commit -m "compat"',
61-
'npm version',
62-
'npm publish --tag compat',
63-
'npm run compat:restore',
64-
]
65-
.map((v) => ` ${v}`)
66-
.join('\n')
67-
)
6857
console.log()
6958
} else if (process.argv.includes('--restore')) {
7059
if (

src/jit/lib/generateRules.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function applyPrefix(matches, context) {
5454
for (let match of matches) {
5555
let [meta] = match
5656
if (meta.options.respectPrefix) {
57-
let container = postcss.root({ nodes: [match[1]] })
57+
let container = postcss.root({ nodes: [match[1].clone()] })
5858
container.walkRules((r) => {
5959
r.selector = prefixSelector(context.tailwindConfig.prefix, r.selector)
6060
})
@@ -72,7 +72,7 @@ function applyImportant(matches) {
7272
let result = []
7373

7474
for (let [meta, rule] of matches) {
75-
let container = postcss.root({ nodes: [rule] })
75+
let container = postcss.root({ nodes: [rule.clone()] })
7676
container.walkRules((r) => {
7777
r.selector = updateAllClasses(r.selector, (className) => {
7878
return `!${className}`
@@ -109,8 +109,7 @@ function applyVariant(variant, matches, context) {
109109
continue
110110
}
111111

112-
let container = postcss.root()
113-
container.append(rule.clone())
112+
let container = postcss.root({ nodes: [rule.clone()] })
114113

115114
for (let [variantSort, variantFunction] of variantFunctionTuples) {
116115
let clone = container.clone()
@@ -297,7 +296,7 @@ function generateRules(candidates, context) {
297296
}
298297
})
299298
} else if (typeof context.tailwindConfig.important === 'string') {
300-
let container = postcss.root({ nodes: [rule] })
299+
let container = postcss.root({ nodes: [rule.clone()] })
301300
container.walkRules((r) => {
302301
if (inKeyframes(r)) {
303302
return

0 commit comments

Comments
 (0)