Remove AOT (#5340)

* make `jit` mode the default when no mode is specified

* unify JIT and AOT codepaths

* ensure `Object.entries` on undefined doesn't break

It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.

* drop AOT specific tests

These tests are all covered by JIT mode already and were AOT specific.

* simplify tests, and add a few

Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.

* add some todo's to make sure we warn in a few cases

* make `darkMode: 'media'`, the default

This also includes moving dark mode tests to its own dedicated file.

* remove PostCSS 7 compat mode

* update CLI to be JIT-first

* fix integration tests

This is not a _real_ fix, but it does solve the broken test for now.

* warn when using @responsive or @variants

* remove the JIT preview warning

* remove AOT-only code paths

* remove all `mode: 'jit'` blocks

Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.

* drop unused dependencies

* rename `purge` to `content`

* remove static CDN builds

* mark `--purge` as deprecated in the CLI

This will still work, but a warning will be printed and it won't show up
in the `--help` output.

* cleanup nesting plugin

We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.

* make sure integration tests run in band

* cleanup folder structure

* make sure nesting folder is available

* simplify resolving of purge/content information
This commit is contained in:
Robin Malfait 2021-09-01 17:13:59 +02:00 • committed by GitHub
parent 911e755056
commit 691ed02f63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
141 changed files with 1991 additions and 10609 deletions

View file

@ -1,47 +0,0 @@
let fs = require('fs')
let path = require('path')
let plugins = fs.readdirSync(fromRootPath('plugins'))
for (let plugin of plugins) {
// Cleanup
let pluginDest = fromRootPath(plugin)
if (fs.existsSync(pluginDest)) {
fs.rmdirSync(pluginDest, { recursive: true })
}
// Copy plugin over
copyFolder(fromRootPath('plugins', plugin), pluginDest, (file) => {
// Ignore test files
if (file.endsWith('.test.js')) return false
// Ignore postcss7 files
if (file.endsWith('.postcss7.js')) return false
// Ignore postcss8 files
if (file.endsWith('.postcss8.js')) return false
return true
})
}
// ---
function fromRootPath(...paths) {
return path.resolve(process.cwd(), ...paths)
}
function copy(fromPath, toPath) {
fs.mkdirSync(path.dirname(toPath), { recursive: true }) // Ensure folder exists
fs.copyFileSync(fromPath, toPath)
}
function copyFolder(fromPath, toPath, shouldCopy = () => true) {
let stats = fs.statSync(fromPath)
if (stats.isDirectory()) {
let filesAndFolders = fs.readdirSync(fromPath)
for (let file of filesAndFolders) {
copyFolder(path.resolve(fromPath, file), path.resolve(toPath, file), shouldCopy)
}
} else if (shouldCopy(fromPath)) {
copy(fromPath, toPath)
}
}

View file

@ -1,46 +0,0 @@
import fs from 'fs'
import postcss from 'postcss'
import tailwind from '..'
import CleanCSS from 'clean-css'
function buildDistFile(filename, config = {}, outFilename = filename) {
return new Promise((resolve, reject) => {
console.log(`Processing ./${filename}.css...`)
fs.readFile(`./${filename}.css`, (err, css) => {
if (err) throw err
return postcss([tailwind(config), require('autoprefixer')])
.process(css, {
from: `./${filename}.css`,
to: `./dist/${outFilename}.css`,
})
.then((result) => {
fs.writeFileSync(`./dist/${outFilename}.css`, result.css)
return result
})
.then((result) => {
const minified = new CleanCSS().minify(result.css)
fs.writeFileSync(`./dist/${outFilename}.min.css`, minified.styles)
})
.then(resolve)
.catch((error) => {
console.log(error)
reject()
})
})
})
}
console.info('Building Tailwind!')
Promise.all([
buildDistFile('base'),
buildDistFile('components'),
buildDistFile('utilities'),
buildDistFile('tailwind'),
buildDistFile('tailwind', { darkMode: 'class' }, 'tailwind-dark'),
buildDistFile('tailwind', { future: 'all', experimental: 'all' }, 'tailwind-experimental'),
]).then(() => {
console.log('Finished Building Tailwind!')
})

View file

@ -1,85 +0,0 @@
let fs = require('fs')
let path = require('path')
let merge = require('lodash/merge')
let fastGlob = require('fast-glob')
let postcss7 = fastGlob.sync(['./**/*.postcss7.*']).filter((file) => !file.startsWith('lib/'))
let postcss8 = fastGlob.sync(['./**/*.postcss8.*']).filter((file) => !file.startsWith('lib/'))
if (process.argv.includes('--prepare')) {
if (postcss8.length > 0) {
console.error('\n\n[ABORT] Already in PostCSS 7 compatibility mode!\n\n')
process.exit(1)
}
let mainPackageJson = require('../package.json')
let compatPackageJson = require('../package.postcss7.json')
// Use postcss7 files
for (let file of postcss7) {
let bareFile = file.replace('.postcss7', '')
let postcss8File = file.replace('.postcss7', '.postcss8')
// Backup
copy(fromRootPath(bareFile), fromRootPath(postcss8File))
// Swap
copy(fromRootPath(file), fromRootPath(bareFile))
}
// Deep merge package.json contents
let packageJson = merge({}, mainPackageJson, compatPackageJson)
// Remove peerDependencies
delete packageJson.peerDependencies
// Cleanup devDependencies
for (let key in packageJson.devDependencies) {
if (key.includes('postcss')) delete packageJson.devDependencies[key]
}
// Use new name
packageJson.name = '@tailwindcss/postcss7-compat'
// Make sure you can publish
packageJson.publishConfig = { access: 'public' }
// Write package.json with the new contents
fs.writeFileSync(fromRootPath('package.json'), JSON.stringify(packageJson, null, 2), 'utf8')
// 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()
} else if (process.argv.includes('--restore')) {
if (postcss8.length === 0) {
console.error('\n\n[ABORT] Already in latest PostCSS mode!\n\n')
process.exit(1)
}
// Use postcss8 files
for (let file of postcss8) {
let bareFile = file.replace('.postcss8', '')
// Restore
copy(fromRootPath(file), fromRootPath(bareFile))
// Remove
fs.unlinkSync(fromRootPath(file))
}
// Done
console.log()
console.log('Restored from PostCSS 7 mode to latest PostCSS mode!')
console.log()
}
// ---
function fromRootPath(...paths) {
return path.resolve(process.cwd(), ...paths)
}
function copy(fromPath, toPath) {
fs.copyFileSync(fromPath, toPath)
}