Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cloning issues #4646

Merged
merged 2 commits into from Jun 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 9 additions & 20 deletions scripts/compat.js
Expand Up @@ -37,34 +37,23 @@ if (process.argv.includes('--prepare')) {
// 5. Remove peerDependencies
delete packageJson.peerDependencies

// 6. Use new name
// 6. Cleanup devDependencies
for (let key in packageJson.devDependencies) {
if (key.includes('postcss')) delete packageJson.devDependencies[key]
}

// 7. Use new name
packageJson.name = '@tailwindcss/postcss7-compat'

// 7. Make sure you can publish
// 8. Make sure you can publish
packageJson.publishConfig = { access: 'public' }

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

// 9. Print some useful information to make publishing easy
// 10. Print some useful information to make publishing easy
console.log()
console.log('You can safely publish `tailwindcss` in PostCSS 7 compatibility mode:\n')
console.log(
[
// Not necessary, but a quick 'hash', basically the current date/time
`git checkout -b compat-${new Date()
.toJSON()
.replace(/[-:.TZ]/g, '') // Remove weird characters
.slice(0, -3)}`, // Remove milliseconds precision
'git add .',
'git commit -m "compat"',
'npm version',
'npm publish --tag compat',
'npm run compat:restore',
]
.map((v) => ` ${v}`)
.join('\n')
)
console.log()
} else if (process.argv.includes('--restore')) {
if (
Expand Down
9 changes: 4 additions & 5 deletions src/jit/lib/generateRules.js
Expand Up @@ -54,7 +54,7 @@ function applyPrefix(matches, context) {
for (let match of matches) {
let [meta] = match
if (meta.options.respectPrefix) {
let container = postcss.root({ nodes: [match[1]] })
let container = postcss.root({ nodes: [match[1].clone()] })
container.walkRules((r) => {
r.selector = prefixSelector(context.tailwindConfig.prefix, r.selector)
})
Expand All @@ -72,7 +72,7 @@ function applyImportant(matches) {
let result = []

for (let [meta, rule] of matches) {
let container = postcss.root({ nodes: [rule] })
let container = postcss.root({ nodes: [rule.clone()] })
container.walkRules((r) => {
r.selector = updateAllClasses(r.selector, (className) => {
return `!${className}`
Expand Down Expand Up @@ -109,8 +109,7 @@ function applyVariant(variant, matches, context) {
continue
}

let container = postcss.root()
container.append(rule.clone())
let container = postcss.root({ nodes: [rule.clone()] })

for (let [variantSort, variantFunction] of variantFunctionTuples) {
let clone = container.clone()
Expand Down Expand Up @@ -297,7 +296,7 @@ function generateRules(candidates, context) {
}
})
} else if (typeof context.tailwindConfig.important === 'string') {
let container = postcss.root({ nodes: [rule] })
let container = postcss.root({ nodes: [rule.clone()] })
container.walkRules((r) => {
if (inKeyframes(r)) {
return
Expand Down