index.test.ts — tailwindcss Source File
Architecture documentation for index.test.ts, a typescript file in the tailwindcss codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1356c93d_ba0c_4cd5_65c6_acc7f3390a93["index.test.ts"] 9c72d32d_a535_69d4_565b_b620ce2eaae1["node:fs"] 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 --> 9c72d32d_a535_69d4_565b_b620ce2eaae1 89aef3dd_1eed_c141_d425_b8949215a653["node:path"] 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 --> 89aef3dd_1eed_c141_d425_b8949215a653 7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"] 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1 c1a54fbc_832b_3231_fea8_2b19516c6781["postcss-import"] 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 --> c1a54fbc_832b_3231_fea8_2b19516c6781 f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3["vitest"] 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 --> f1e05e5f_c1b2_a3f5_b2e8_3317b9243ac3 4a833a47_de88_b79a_24ac_de077593f60a["."] 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 --> 4a833a47_de88_b79a_24ac_de077593f60a style 1356c93d_ba0c_4cd5_65c6_acc7f3390a93 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fs from 'node:fs'
import path from 'node:path'
import postcss from 'postcss'
import atImport from 'postcss-import'
import { describe, expect, test } from 'vitest'
import fixRelativePathsPlugin from '.'
describe('fixRelativePathsPlugin', () => {
test('rewrites @source and @plugin to be relative to the initial css file', async () => {
let cssPath = path.join(__dirname, 'fixtures', 'external-import', 'src', 'index.css')
let css = fs.readFileSync(cssPath, 'utf-8')
let processor = postcss([atImport(), fixRelativePathsPlugin()])
let result = await processor.process(css, { from: cssPath })
expect(result.css.trim()).toMatchInlineSnapshot(`
"@source "../../example-project/src/**/*.ts";
@source "!../../example-project/src/**/*.ts";
@plugin "../../example-project/src/plugin.js";
@plugin "../../example-project/src/what\\"s-this.js";"
`)
})
test('should not rewrite non-relative paths', async () => {
let cssPath = path.join(__dirname, 'fixtures', 'external-import', 'src', 'invalid.css')
let css = fs.readFileSync(cssPath, 'utf-8')
let processor = postcss([atImport(), fixRelativePathsPlugin()])
let result = await processor.process(css, { from: cssPath })
expect(result.css.trim()).toMatchInlineSnapshot(`
"@plugin "/absolute/paths";
@plugin "C:\\Program Files\\HAL 9000";
@plugin "\\\\Media\\Pictures\\Worth\\1000 words";
@plugin "some-node-dep";"
`)
})
test('should return relative paths even if the file is resolved in the same basedir as the root stylesheet', async () => {
let cssPath = path.join(__dirname, 'fixtures', 'external-import', 'src', 'plugins-in-root.css')
let css = fs.readFileSync(cssPath, 'utf-8')
let processor = postcss([atImport(), fixRelativePathsPlugin()])
let result = await processor.process(css, { from: cssPath })
expect(result.css.trim()).toMatchInlineSnapshot(`
"@plugin './plugin-in-sibling.ts';
@plugin '../plugin-in-sibling.ts';
@plugin 'plugin-in-sibling';
@plugin './plugin-in-root.ts';
@plugin '../plugin-in-root.ts';
@plugin 'plugin-in-root';"
`)
})
})
Dependencies
- .
- node:fs
- node:path
- postcss
- postcss-import
- vitest
Source
Frequently Asked Questions
What does index.test.ts do?
index.test.ts is a source file in the tailwindcss codebase, written in typescript.
What does index.test.ts depend on?
index.test.ts imports 6 module(s): ., node:fs, node:path, postcss, postcss-import, vitest.
Where is index.test.ts in the architecture?
index.test.ts is located at packages/@tailwindcss-postcss/src/postcss-fix-relative-paths/index.test.ts (directory: packages/@tailwindcss-postcss/src/postcss-fix-relative-paths).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free