From 8444aacac9e9cd158eecf16d75af11300f2a7cd6 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 22 Sep 2025 13:50:53 -0400 Subject: [PATCH 1/4] Tweak test example --- tests/tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests.ts b/tests/tests.ts index 410e9c2..5c8daea 100644 --- a/tests/tests.ts +++ b/tests/tests.ts @@ -46,7 +46,7 @@ let css: TestEntry[] = [ [`@config "./file.js";`, `@config './file.js';`], [`@source "./file.js";`, `@source './file.js';`], [`@source not "./file.js";`, `@source not './file.js';`], - [`@source inline("./file.js");`, `@source inline('./file.js');`], + [`@source inline("flex");`, `@source inline('flex');`], ] export let javascript: TestEntry[] = [ From 728993002b5a6116acc48d5227729a13a34f4a6a Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 22 Sep 2025 13:50:59 -0400 Subject: [PATCH 2/4] Add failing test --- tests/tests.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/tests.ts b/tests/tests.ts index 5c8daea..3771391 100644 --- a/tests/tests.ts +++ b/tests/tests.ts @@ -47,6 +47,11 @@ let css: TestEntry[] = [ [`@source "./file.js";`, `@source './file.js';`], [`@source not "./file.js";`, `@source not './file.js';`], [`@source inline("flex");`, `@source inline('flex');`], + + [ + `@import "tailwindcss";\n\n@use "tailwindcss";\n\n@source "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@use 'tailwindcss';\n\n@source './file.js';\n\n.foo {\n color: red;\n}`, + ], ] export let javascript: TestEntry[] = [ From a790629d4ec34b399d902970f1f8ae40b7546695 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 22 Sep 2025 13:51:17 -0400 Subject: [PATCH 3/4] Pass in shallow copy of parse options when re-parsing at-rule params --- src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index fc1cbc0..391a572 100644 --- a/src/index.ts +++ b/src/index.ts @@ -735,7 +735,12 @@ function transformCss(ast: any, { env }: TransformerContext) { // based on postcss-value parser. try { let parser = base.parsers.css - let root = parser.parse(`@import ${params};`, env.options) + + let root = parser.parse(`@import ${params};`, { + // We can't pass env.options directly because css.parse overwrites + // options.originalText which is used during the printing phase + ...env.options, + }) return root.nodes[0].params } catch (err) { From 1371f14fb7da2ad0ecf07ffbcc130c806560ee53 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Mon, 22 Sep 2025 13:53:24 -0400 Subject: [PATCH 4/4] Update test case --- tests/tests.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/tests.ts b/tests/tests.ts index 3771391..b7db3df 100644 --- a/tests/tests.ts +++ b/tests/tests.ts @@ -49,8 +49,16 @@ let css: TestEntry[] = [ [`@source inline("flex");`, `@source inline('flex');`], [ - `@import "tailwindcss";\n\n@use "tailwindcss";\n\n@source "./file.js";\n\n.foo {\n color: red;\n}`, - `@import 'tailwindcss';\n\n@use 'tailwindcss';\n\n@source './file.js';\n\n.foo {\n color: red;\n}`, + `@import "tailwindcss";\n\n@import "./theme.css";\n\n@source "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@import './theme.css';\n\n@source './file.js';\n\n.foo {\n color: red;\n}`, + ], + [ + `@import "tailwindcss";\n\n@import "./theme.css";\n\n@plugin "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@import './theme.css';\n\n@plugin './file.js';\n\n.foo {\n color: red;\n}`, + ], + [ + `@import "tailwindcss";\n\n@import "./theme.css";\n\n@config "./file.js";\n\n.foo {\n color: red;\n}`, + `@import 'tailwindcss';\n\n@import './theme.css';\n\n@config './file.js';\n\n.foo {\n color: red;\n}`, ], ]