mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2026-01-25 16:44:12 +00:00
* remove all oxide related code * Update lightningcss to version 1.24.1 * update tests to match bumped Lightning CSS output --------- Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
541 lines
13 KiB
JavaScript
541 lines
13 KiB
JavaScript
import postcss from 'postcss'
|
|
import { parseSourceMaps } from './util/source-maps'
|
|
import { runWithSourceMaps as run, html, css, map } from './util/run'
|
|
|
|
test('apply generates source maps', async () => {
|
|
let config = {
|
|
content: [
|
|
{
|
|
raw: html`
|
|
<div class="with-declaration"></div>
|
|
<div class="with-comment"></div>
|
|
<div class="just-apply"></div>
|
|
`,
|
|
},
|
|
],
|
|
corePlugins: { preflight: false },
|
|
}
|
|
|
|
let input = css`
|
|
.with-declaration {
|
|
background-color: red;
|
|
@apply h-4 w-4 bg-green-500;
|
|
}
|
|
|
|
.with-comment {
|
|
/* sourcemap will work here too */
|
|
@apply h-4 w-4 bg-red-500;
|
|
}
|
|
|
|
.just-apply {
|
|
@apply h-4 w-4 bg-black;
|
|
}
|
|
`
|
|
|
|
let result = await run(input, config)
|
|
let { sources, annotations } = parseSourceMaps(result)
|
|
|
|
// All CSS generated by Tailwind CSS should be annotated with source maps
|
|
// And always be able to point to the original source file
|
|
expect(sources).not.toContain('<no source>')
|
|
expect(sources.length).toBe(1)
|
|
|
|
expect(annotations).toEqual([
|
|
'2:4 -> 2:4',
|
|
'3:6-27 -> 3:6-27',
|
|
'4:6-33 -> 4:6-18',
|
|
'4:6-33 -> 5:6-17',
|
|
'4:6-33 -> 6:6-24',
|
|
'4:6-33 -> 7:6-61',
|
|
'5:4 -> 8:4',
|
|
'7:4 -> 10:4',
|
|
'8:6-39 -> 11:6-39',
|
|
'9:6-31 -> 12:6-18',
|
|
'9:6-31 -> 13:6-17',
|
|
'9:6-31 -> 14:6-24',
|
|
'9:6-31 -> 15:6-61',
|
|
'10:4 -> 16:4',
|
|
'13:6 -> 18:4',
|
|
'13:6-29 -> 19:6-18',
|
|
'13:6-29 -> 20:6-17',
|
|
'13:6-29 -> 21:6-24',
|
|
'13:6 -> 22:6',
|
|
'13:29 -> 23:0',
|
|
])
|
|
})
|
|
|
|
test('preflight + base have source maps', async () => {
|
|
let config = {
|
|
content: [],
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind base;
|
|
`
|
|
|
|
let result = await run(input, config)
|
|
let { sources, annotations } = parseSourceMaps(result)
|
|
|
|
// All CSS generated by Tailwind CSS should be annotated with source maps
|
|
// And always be able to point to the original source file
|
|
expect(sources).not.toContain('<no source>')
|
|
expect(sources.length).toBe(1)
|
|
|
|
expect(annotations).toEqual([
|
|
'2:4 -> 1:0',
|
|
'2:18-4 -> 3:1-2',
|
|
'2:18 -> 6:1',
|
|
'2:4 -> 8:0',
|
|
'2:4-18 -> 11:2-32',
|
|
'2:4-18 -> 12:2-25',
|
|
'2:4-18 -> 13:2-29',
|
|
'2:4-18 -> 14:2-31',
|
|
'2:18 -> 15:0',
|
|
'2:4 -> 17:0',
|
|
'2:4-18 -> 19:2-18',
|
|
'2:18 -> 20:0',
|
|
'2:4 -> 22:0',
|
|
'2:18 -> 30:1',
|
|
'2:4 -> 32:0',
|
|
'2:4-18 -> 34:2-26',
|
|
'2:4-18 -> 35:2-40',
|
|
'2:4-18 -> 36:2-26',
|
|
'2:4-18 -> 37:2-21',
|
|
'2:4-18 -> 38:2-137',
|
|
'2:4-18 -> 39:2-39',
|
|
'2:4-18 -> 40:2-41',
|
|
'2:4-18 -> 41:2-50',
|
|
'2:18 -> 42:0',
|
|
'2:4 -> 44:0',
|
|
'2:18 -> 47:1',
|
|
'2:4 -> 49:0',
|
|
'2:4-18 -> 50:2-19',
|
|
'2:4-18 -> 51:2-30',
|
|
'2:18 -> 52:0',
|
|
'2:4 -> 54:0',
|
|
'2:18 -> 58:1',
|
|
'2:4 -> 60:0',
|
|
'2:4-18 -> 61:2-19',
|
|
'2:4-18 -> 62:2-24',
|
|
'2:4-18 -> 63:2-31',
|
|
'2:18 -> 64:0',
|
|
'2:4 -> 66:0',
|
|
'2:18 -> 68:1',
|
|
'2:4 -> 70:0',
|
|
'2:4-18 -> 71:2-35',
|
|
'2:18 -> 72:0',
|
|
'2:4 -> 74:0',
|
|
'2:18 -> 76:1',
|
|
'2:4 -> 78:0',
|
|
'2:4-18 -> 84:2-20',
|
|
'2:4-18 -> 85:2-22',
|
|
'2:18 -> 86:0',
|
|
'2:4 -> 88:0',
|
|
'2:18 -> 90:1',
|
|
'2:4 -> 92:0',
|
|
'2:4-18 -> 93:2-16',
|
|
'2:4-18 -> 94:2-26',
|
|
'2:18 -> 95:0',
|
|
'2:4 -> 97:0',
|
|
'2:18 -> 99:1',
|
|
'2:4 -> 101:0',
|
|
'2:4-18 -> 103:2-21',
|
|
'2:18 -> 104:0',
|
|
'2:4 -> 106:0',
|
|
'2:18 -> 111:1',
|
|
'2:4 -> 113:0',
|
|
'2:4-18 -> 117:2-121',
|
|
'2:4-18 -> 118:2-39',
|
|
'2:4-18 -> 119:2-41',
|
|
'2:4-18 -> 120:2-24',
|
|
'2:18 -> 121:0',
|
|
'2:4 -> 123:0',
|
|
'2:18 -> 125:1',
|
|
'2:4 -> 127:0',
|
|
'2:4-18 -> 128:2-16',
|
|
'2:18 -> 129:0',
|
|
'2:4 -> 131:0',
|
|
'2:18 -> 133:1',
|
|
'2:4 -> 135:0',
|
|
'2:4-18 -> 137:2-16',
|
|
'2:4-18 -> 138:2-16',
|
|
'2:4-18 -> 139:2-20',
|
|
'2:4-18 -> 140:2-26',
|
|
'2:18 -> 141:0',
|
|
'2:4 -> 143:0',
|
|
'2:4-18 -> 144:2-17',
|
|
'2:18 -> 145:0',
|
|
'2:4 -> 147:0',
|
|
'2:4-18 -> 148:2-13',
|
|
'2:18 -> 149:0',
|
|
'2:4 -> 151:0',
|
|
'2:18 -> 155:1',
|
|
'2:4 -> 157:0',
|
|
'2:4-18 -> 158:2-24',
|
|
'2:4-18 -> 159:2-31',
|
|
'2:4-18 -> 160:2-35',
|
|
'2:18 -> 161:0',
|
|
'2:4 -> 163:0',
|
|
'2:18 -> 167:1',
|
|
'2:4 -> 169:0',
|
|
'2:4-18 -> 174:2-30',
|
|
'2:4-18 -> 175:2-40',
|
|
'2:4-18 -> 176:2-42',
|
|
'2:4-18 -> 177:2-25',
|
|
'2:4-18 -> 178:2-30',
|
|
'2:4-18 -> 179:2-30',
|
|
'2:4-18 -> 180:2-24',
|
|
'2:4-18 -> 181:2-19',
|
|
'2:4-18 -> 182:2-20',
|
|
'2:18 -> 183:0',
|
|
'2:4 -> 185:0',
|
|
'2:18 -> 187:1',
|
|
'2:4 -> 189:0',
|
|
'2:4-18 -> 191:2-22',
|
|
'2:18 -> 192:0',
|
|
'2:4 -> 194:0',
|
|
'2:18 -> 197:1',
|
|
'2:4 -> 199:0',
|
|
'2:4-18 -> 203:2-36',
|
|
'2:4-18 -> 204:2-39',
|
|
'2:4-18 -> 205:2-32',
|
|
'2:18 -> 206:0',
|
|
'2:4 -> 208:0',
|
|
'2:18 -> 210:1',
|
|
'2:4 -> 212:0',
|
|
'2:4-18 -> 213:2-15',
|
|
'2:18 -> 214:0',
|
|
'2:4 -> 216:0',
|
|
'2:18 -> 218:1',
|
|
'2:4 -> 220:0',
|
|
'2:4-18 -> 221:2-18',
|
|
'2:18 -> 222:0',
|
|
'2:4 -> 224:0',
|
|
'2:18 -> 226:1',
|
|
'2:4 -> 228:0',
|
|
'2:4-18 -> 229:2-26',
|
|
'2:18 -> 230:0',
|
|
'2:4 -> 232:0',
|
|
'2:18 -> 234:1',
|
|
'2:4 -> 236:0',
|
|
'2:4-18 -> 238:2-14',
|
|
'2:18 -> 239:0',
|
|
'2:4 -> 241:0',
|
|
'2:18 -> 244:1',
|
|
'2:4 -> 246:0',
|
|
'2:4-18 -> 247:2-39',
|
|
'2:4-18 -> 248:2-30',
|
|
'2:18 -> 249:0',
|
|
'2:4 -> 251:0',
|
|
'2:18 -> 253:1',
|
|
'2:4 -> 255:0',
|
|
'2:4-18 -> 256:2-26',
|
|
'2:18 -> 257:0',
|
|
'2:4 -> 259:0',
|
|
'2:18 -> 262:1',
|
|
'2:4 -> 264:0',
|
|
'2:4-18 -> 265:2-36',
|
|
'2:4-18 -> 266:2-23',
|
|
'2:18 -> 267:0',
|
|
'2:4 -> 269:0',
|
|
'2:18 -> 271:1',
|
|
'2:4 -> 273:0',
|
|
'2:4-18 -> 274:2-20',
|
|
'2:18 -> 275:0',
|
|
'2:4 -> 277:0',
|
|
'2:18 -> 279:1',
|
|
'2:4 -> 281:0',
|
|
'2:4-18 -> 294:2-11',
|
|
'2:18 -> 295:0',
|
|
'2:4 -> 297:0',
|
|
'2:4-18 -> 298:2-11',
|
|
'2:4-18 -> 299:2-12',
|
|
'2:18 -> 300:0',
|
|
'2:4 -> 302:0',
|
|
'2:4-18 -> 303:2-12',
|
|
'2:18 -> 304:0',
|
|
'2:4 -> 306:0',
|
|
'2:4-18 -> 309:2-18',
|
|
'2:4-18 -> 310:2-11',
|
|
'2:4-18 -> 311:2-12',
|
|
'2:18 -> 312:0',
|
|
'2:4 -> 314:0',
|
|
'2:18 -> 316:1',
|
|
'2:4 -> 317:0',
|
|
'2:4-18 -> 318:2-12',
|
|
'2:18 -> 319:0',
|
|
'2:4 -> 321:0',
|
|
'2:18 -> 323:1',
|
|
'2:4 -> 325:0',
|
|
'2:4-18 -> 326:2-18',
|
|
'2:18 -> 327:0',
|
|
'2:4 -> 329:0',
|
|
'2:18 -> 332:1',
|
|
'2:4 -> 334:0',
|
|
'2:4-18 -> 336:2-20',
|
|
'2:4-18 -> 337:2-24',
|
|
'2:18 -> 338:0',
|
|
'2:4 -> 340:0',
|
|
'2:18 -> 342:1',
|
|
'2:4 -> 344:0',
|
|
'2:4-18 -> 346:2-17',
|
|
'2:18 -> 347:0',
|
|
'2:4 -> 349:0',
|
|
'2:18 -> 351:1',
|
|
'2:4 -> 352:0',
|
|
'2:4-18 -> 353:2-17',
|
|
'2:18 -> 354:0',
|
|
'2:4 -> 356:0',
|
|
'2:18 -> 360:1',
|
|
'2:4 -> 362:0',
|
|
'2:4-18 -> 370:2-24',
|
|
'2:4-18 -> 371:2-32',
|
|
'2:18 -> 372:0',
|
|
'2:4 -> 374:0',
|
|
'2:18 -> 376:1',
|
|
'2:4 -> 378:0',
|
|
'2:4-18 -> 380:2-17',
|
|
'2:4-18 -> 381:2-14',
|
|
'2:18 -> 382:0',
|
|
'2:4-18 -> 384:0-72',
|
|
'2:4 -> 385:0',
|
|
'2:4-18 -> 386:2-15',
|
|
'2:18 -> 387:0',
|
|
'2:4 -> 389:0',
|
|
'2:4-18 -> 390:2-26',
|
|
'2:4-18 -> 391:2-26',
|
|
'2:4-18 -> 392:2-21',
|
|
'2:4-18 -> 393:2-21',
|
|
'2:4-18 -> 394:2-16',
|
|
'2:4-18 -> 395:2-16',
|
|
'2:4-18 -> 396:2-16',
|
|
'2:4-18 -> 397:2-17',
|
|
'2:4-18 -> 398:2-17',
|
|
'2:4-18 -> 399:2-15',
|
|
'2:4-18 -> 400:2-15',
|
|
'2:4-18 -> 401:2-20',
|
|
'2:4-18 -> 402:2-40',
|
|
'2:4-18 -> 403:2-32',
|
|
'2:4-18 -> 404:2-31',
|
|
'2:4-18 -> 405:2-30',
|
|
'2:4-18 -> 406:2-17',
|
|
'2:4-18 -> 407:2-22',
|
|
'2:4-18 -> 408:2-24',
|
|
'2:4-18 -> 409:2-25',
|
|
'2:4-18 -> 410:2-26',
|
|
'2:4-18 -> 411:2-20',
|
|
'2:4-18 -> 412:2-29',
|
|
'2:4-18 -> 413:2-30',
|
|
'2:4-18 -> 414:2-40',
|
|
'2:4-18 -> 415:2-36',
|
|
'2:4-18 -> 416:2-29',
|
|
'2:4-18 -> 417:2-24',
|
|
'2:4-18 -> 418:2-32',
|
|
'2:4-18 -> 419:2-14',
|
|
'2:4-18 -> 420:2-20',
|
|
'2:4-18 -> 421:2-18',
|
|
'2:4-18 -> 422:2-19',
|
|
'2:4-18 -> 423:2-20',
|
|
'2:4-18 -> 424:2-16',
|
|
'2:4-18 -> 425:2-18',
|
|
'2:4-18 -> 426:2-15',
|
|
'2:4-18 -> 427:2-21',
|
|
'2:4-18 -> 428:2-23',
|
|
'2:4-18 -> 429:2-29',
|
|
'2:4-18 -> 430:2-27',
|
|
'2:4-18 -> 431:2-28',
|
|
'2:4-18 -> 432:2-29',
|
|
'2:4-18 -> 433:2-25',
|
|
'2:4-18 -> 434:2-26',
|
|
'2:4-18 -> 435:2-27',
|
|
'2:4-18 -> 436:2-24',
|
|
'2:4-18 -> 437:2-22',
|
|
'2:4-18 -> 438:2-24',
|
|
'2:4-18 -> 439:2-23',
|
|
'2:4 -> 440:2',
|
|
'2:18 -> 441:0',
|
|
'2:4 -> 443:0',
|
|
'2:4-18 -> 444:2-26',
|
|
'2:4-18 -> 445:2-26',
|
|
'2:4-18 -> 446:2-21',
|
|
'2:4-18 -> 447:2-21',
|
|
'2:4-18 -> 448:2-16',
|
|
'2:4-18 -> 449:2-16',
|
|
'2:4-18 -> 450:2-16',
|
|
'2:4-18 -> 451:2-17',
|
|
'2:4-18 -> 452:2-17',
|
|
'2:4-18 -> 453:2-15',
|
|
'2:4-18 -> 454:2-15',
|
|
'2:4-18 -> 455:2-20',
|
|
'2:4-18 -> 456:2-40',
|
|
'2:4-18 -> 457:2-32',
|
|
'2:4-18 -> 458:2-31',
|
|
'2:4-18 -> 459:2-30',
|
|
'2:4-18 -> 460:2-17',
|
|
'2:4-18 -> 461:2-22',
|
|
'2:4-18 -> 462:2-24',
|
|
'2:4-18 -> 463:2-25',
|
|
'2:4-18 -> 464:2-26',
|
|
'2:4-18 -> 465:2-20',
|
|
'2:4-18 -> 466:2-29',
|
|
'2:4-18 -> 467:2-30',
|
|
'2:4-18 -> 468:2-40',
|
|
'2:4-18 -> 469:2-36',
|
|
'2:4-18 -> 470:2-29',
|
|
'2:4-18 -> 471:2-24',
|
|
'2:4-18 -> 472:2-32',
|
|
'2:4-18 -> 473:2-14',
|
|
'2:4-18 -> 474:2-20',
|
|
'2:4-18 -> 475:2-18',
|
|
'2:4-18 -> 476:2-19',
|
|
'2:4-18 -> 477:2-20',
|
|
'2:4-18 -> 478:2-16',
|
|
'2:4-18 -> 479:2-18',
|
|
'2:4-18 -> 480:2-15',
|
|
'2:4-18 -> 481:2-21',
|
|
'2:4-18 -> 482:2-23',
|
|
'2:4-18 -> 483:2-29',
|
|
'2:4-18 -> 484:2-27',
|
|
'2:4-18 -> 485:2-28',
|
|
'2:4-18 -> 486:2-29',
|
|
'2:4-18 -> 487:2-25',
|
|
'2:4-18 -> 488:2-26',
|
|
'2:4-18 -> 489:2-27',
|
|
'2:4-18 -> 490:2-24',
|
|
'2:4-18 -> 491:2-22',
|
|
'2:4-18 -> 492:2-24',
|
|
'2:4-18 -> 493:2-23',
|
|
'2:4 -> 494:2',
|
|
'2:18 -> 495:0',
|
|
])
|
|
})
|
|
|
|
test('utilities have source maps', async () => {
|
|
let config = {
|
|
content: [{ raw: `text-red-500` }],
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind utilities;
|
|
`
|
|
|
|
let result = await run(input, config)
|
|
let { sources, annotations } = parseSourceMaps(result)
|
|
|
|
// All CSS generated by Tailwind CSS should be annotated with source maps
|
|
// And always be able to point to the original source file
|
|
expect(sources).not.toContain('<no source>')
|
|
expect(sources.length).toBe(1)
|
|
|
|
expect(annotations).toStrictEqual(['2:4 -> 1:0', '2:4-23 -> 2:4-24', '2:4 -> 3:4', '2:23 -> 4:0'])
|
|
})
|
|
|
|
test('components have source maps', async () => {
|
|
let config = {
|
|
content: [{ raw: `container` }],
|
|
}
|
|
|
|
let input = css`
|
|
@tailwind components;
|
|
`
|
|
|
|
let result = await run(input, config)
|
|
let { sources, annotations } = parseSourceMaps(result)
|
|
|
|
// All CSS generated by Tailwind CSS should be annotated with source maps
|
|
// And always be able to point to the original source file
|
|
expect(sources).not.toContain('<no source>')
|
|
expect(sources.length).toBe(1)
|
|
|
|
expect(annotations).toEqual([
|
|
'2:4 -> 1:0',
|
|
'2:4 -> 2:4',
|
|
'2:24 -> 3:0',
|
|
'2:4 -> 4:0',
|
|
'2:4 -> 5:4',
|
|
'2:4 -> 6:8',
|
|
'2:24 -> 7:4',
|
|
'2:24 -> 8:0',
|
|
'2:4 -> 9:0',
|
|
'2:4 -> 10:4',
|
|
'2:4 -> 11:8',
|
|
'2:24 -> 12:4',
|
|
'2:24 -> 13:0',
|
|
'2:4 -> 14:0',
|
|
'2:4 -> 15:4',
|
|
'2:4 -> 16:8',
|
|
'2:24 -> 17:4',
|
|
'2:24 -> 18:0',
|
|
'2:4 -> 19:0',
|
|
'2:4 -> 20:4',
|
|
'2:4 -> 21:8',
|
|
'2:24 -> 22:4',
|
|
'2:24 -> 23:0',
|
|
'2:4 -> 24:0',
|
|
'2:4 -> 25:4',
|
|
'2:4 -> 26:8',
|
|
'2:24 -> 27:4',
|
|
'2:24 -> 28:0',
|
|
])
|
|
})
|
|
|
|
test('source maps for layer rules are not rewritten to point to @tailwind directives', async () => {
|
|
let config = {
|
|
content: [{ raw: `font-normal foo hover:foo lg:foo` }],
|
|
}
|
|
|
|
let utilitiesFile = postcss.parse(
|
|
css`
|
|
@tailwind utilities;
|
|
`,
|
|
{ from: 'components.css', map: { prev: map } }
|
|
)
|
|
|
|
let mainCssFile = postcss.parse(
|
|
css`
|
|
@layer utilities {
|
|
.foo {
|
|
background-color: red;
|
|
}
|
|
}
|
|
`,
|
|
{ from: 'input.css', map: { prev: map } }
|
|
)
|
|
|
|
// Just pretend that there's an @import in `mainCssFile` that imports the nodes from `utilitiesFile`
|
|
let input = postcss.root({
|
|
nodes: [...utilitiesFile.nodes, ...mainCssFile.nodes],
|
|
source: mainCssFile.source,
|
|
})
|
|
|
|
let result = await run(input, config)
|
|
|
|
let { sources, annotations } = parseSourceMaps(result)
|
|
|
|
// All CSS generated by Tailwind CSS should be annotated with source maps
|
|
// And always be able to point to the original source file
|
|
expect(sources).not.toContain('<no source>')
|
|
|
|
// And we should see that the source map for the layer rule is not rewritten
|
|
// to point to the @tailwind directive but instead points to the original
|
|
expect(sources.length).toBe(2)
|
|
expect(sources).toEqual(['components.css', 'input.css'])
|
|
|
|
expect(annotations).toEqual([
|
|
'2:6 -> 1:0',
|
|
'2:6 -> 2:10',
|
|
'2:25 -> 3:0',
|
|
'3:8 -> 4:8',
|
|
'4:10-31 -> 5:10-31',
|
|
'5:8 -> 6:8',
|
|
'3:8 -> 7:8',
|
|
'4:10-31 -> 8:10-31',
|
|
'5:8 -> 9:8',
|
|
'1:0 -> 10:8',
|
|
'3:8 -> 11:8',
|
|
'4:10-31 -> 12:10-31',
|
|
'5:8 -> 13:8',
|
|
'1:0 -> 14:0',
|
|
])
|
|
})
|