mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* replace `env.OXIDE` with global `__OXIDE__` This will allow us to replace the `__OXIDE__` at build time, and fully remove the branches from the final code so that there is not even any reference to `@tailwindcss/oxide` on the stable engine. * update changelog * use `env.ENGINE` in integration tests * drop oxide branching for the PostCSS plugin for now This is currently a redirect to the same file, so doesn't hurt. * Enable better dead-code elimination * Update CLI tests Fix indentation * Fix indentation --------- Co-authored-by: Jordan Pittman <jordan@cryptica.me>
95 lines
2.1 KiB
JavaScript
95 lines
2.1 KiB
JavaScript
import path from 'path'
|
|
import postcss from 'postcss'
|
|
import tailwind from '../../src'
|
|
import { env } from '../../src/lib/sharedState'
|
|
|
|
export * from './strings'
|
|
export * from './defaults'
|
|
|
|
export let map = JSON.stringify({
|
|
version: 3,
|
|
file: null,
|
|
sources: [],
|
|
names: [],
|
|
mappings: '',
|
|
})
|
|
|
|
globalThis.__OXIDE__ = env.ENGINE === 'oxide'
|
|
|
|
export function run(input, config, plugin = tailwind) {
|
|
let { currentTestName } = expect.getState()
|
|
|
|
return postcss(plugin(config)).process(input, {
|
|
from: `${path.resolve(__filename)}?test=${currentTestName}`,
|
|
})
|
|
}
|
|
|
|
export function runWithSourceMaps(input, config, plugin = tailwind) {
|
|
let { currentTestName } = expect.getState()
|
|
|
|
return postcss(plugin(config)).process(input, {
|
|
from: `${path.resolve(__filename)}?test=${currentTestName}`,
|
|
map: {
|
|
prev: map,
|
|
},
|
|
})
|
|
}
|
|
|
|
let nullTest = Object.assign(function () {}, {
|
|
skip: () => {},
|
|
only: () => {},
|
|
each: () => () => {},
|
|
todo: () => {},
|
|
})
|
|
let nullProxy = new Proxy(
|
|
{
|
|
test: nullTest,
|
|
it: nullTest,
|
|
xit: nullTest.skip,
|
|
fit: nullTest.only,
|
|
xdescribe: nullTest.skip,
|
|
fdescribe: nullTest.only,
|
|
},
|
|
{
|
|
get(target, prop, _receiver) {
|
|
if (prop in target) {
|
|
return target[prop]
|
|
}
|
|
return Object.assign(() => {
|
|
return nullProxy
|
|
}, nullProxy)
|
|
},
|
|
}
|
|
)
|
|
|
|
/**
|
|
* @typedef {object} CrossCheck
|
|
* @property {typeof import('@jest/globals')} oxide
|
|
* @property {typeof import('@jest/globals')} stable
|
|
* @property {object} engine
|
|
* @property {boolean} engine.oxide
|
|
* @property {boolean} engine.stable
|
|
*/
|
|
|
|
/**
|
|
* @param {(data: CrossCheck) => void} fn
|
|
*/
|
|
export function crosscheck(fn) {
|
|
let engines =
|
|
env.ENGINE === 'oxide' ? [{ engine: 'Stable' }, { engine: 'Oxide' }] : [{ engine: 'Stable' }]
|
|
|
|
describe.each(engines)('$engine', ({ engine }) => {
|
|
let engines = {
|
|
oxide: engine === 'Oxide' ? globalThis : nullProxy,
|
|
stable: engine === 'Stable' ? globalThis : nullProxy,
|
|
engine: { oxide: engine === 'Oxide', stable: engine === 'Stable' },
|
|
}
|
|
|
|
beforeEach(() => {
|
|
globalThis.__OXIDE__ = engines.engine.oxide
|
|
})
|
|
|
|
fn(engines)
|
|
})
|
|
}
|