Skip to content

Commit 3742d5d

Browse files
Move base into compiler options
1 parent 2f1dbcc commit 3742d5d

File tree

13 files changed

+317
-444
lines changed

13 files changed

+317
-444
lines changed

packages/@tailwindcss-node/src/compile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export async function compile(
1111
css: string,
1212
{ base, onDependency }: { base: string; onDependency: (path: string) => void },
1313
) {
14-
return await _compile(css, base, {
14+
return await _compile(css, {
15+
base,
1516
async loadModule(id, base) {
1617
if (id[0] !== '.') {
1718
let resolvedPath = await resolveJsId(id, base)

packages/tailwindcss/src/at-import.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function run(
1717
Promise.reject(new Error('Unexpected module')),
1818
candidates: string[] = [],
1919
) {
20-
let compiler = await compile(css, '/root', { loadStylesheet, loadModule })
20+
let compiler = await compile(css, { base: '/root', loadStylesheet, loadModule })
2121
return optimizeCss(compiler.build(candidates))
2222
}
2323

@@ -362,8 +362,7 @@ test('emits the right base for @source directives inside nested files', async ()
362362
@import './foo/bar.css';
363363
@source './root/**/*.css';
364364
`,
365-
'/root',
366-
{ loadStylesheet },
365+
{ base: '/root', loadStylesheet },
367366
)
368367

369368
expect(compiler.globs).toEqual([
@@ -411,8 +410,7 @@ test('emits the right base for @source found inside JS configs and plugins from
411410
@config './root-config.js';
412411
@plugin './root-plugin.js';
413412
`,
414-
'/root',
415-
{ loadStylesheet, loadModule },
413+
{ base: '/root', loadStylesheet, loadModule },
416414
)
417415

418416
expect(compiler.globs).toEqual([

packages/tailwindcss/src/compat/config.test.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('Config files can add content', async () => {
1111
@config "./config.js";
1212
`
1313

14-
let compiler = await compile(input, '/root', {
14+
let compiler = await compile(input, {
1515
loadModule: async () => ({ module: { content: ['./file.txt'] }, base: '/root' }),
1616
})
1717

@@ -24,7 +24,7 @@ test('Config files can change dark mode (media)', async () => {
2424
@config "./config.js";
2525
`
2626

27-
let compiler = await compile(input, '/root', {
27+
let compiler = await compile(input, {
2828
loadModule: async () => ({ module: { darkMode: 'media' }, base: '/root' }),
2929
})
3030

@@ -44,7 +44,7 @@ test('Config files can change dark mode (selector)', async () => {
4444
@config "./config.js";
4545
`
4646

47-
let compiler = await compile(input, '/root', {
47+
let compiler = await compile(input, {
4848
loadModule: async () => ({ module: { darkMode: 'selector' }, base: '/root' }),
4949
})
5050

@@ -64,7 +64,7 @@ test('Config files can change dark mode (variant)', async () => {
6464
@config "./config.js";
6565
`
6666

67-
let compiler = await compile(input, '/root', {
67+
let compiler = await compile(input, {
6868
loadModule: async () => ({
6969
module: { darkMode: ['variant', '&:where(:not(.light))'] },
7070
base: '/root',
@@ -87,7 +87,7 @@ test('Config files can add plugins', async () => {
8787
@config "./config.js";
8888
`
8989

90-
let compiler = await compile(input, '/root', {
90+
let compiler = await compile(input, {
9191
loadModule: async () => ({
9292
module: {
9393
plugins: [
@@ -118,7 +118,7 @@ test('Plugins loaded from config files can contribute to the config', async () =
118118
@config "./config.js";
119119
`
120120

121-
let compiler = await compile(input, '/root', {
121+
let compiler = await compile(input, {
122122
loadModule: async () => ({
123123
module: {
124124
plugins: [
@@ -147,7 +147,7 @@ test('Config file presets can contribute to the config', async () => {
147147
@config "./config.js";
148148
`
149149

150-
let compiler = await compile(input, '/root', {
150+
let compiler = await compile(input, {
151151
loadModule: async () => ({
152152
module: {
153153
presets: [
@@ -176,7 +176,7 @@ test('Config files can affect the theme', async () => {
176176
@config "./config.js";
177177
`
178178

179-
let compiler = await compile(input, '/root', {
179+
let compiler = await compile(input, {
180180
loadModule: async () => ({
181181
module: {
182182
theme: {
@@ -220,7 +220,7 @@ test('Variants in CSS overwrite variants from plugins', async () => {
220220
@variant light (&:is(.my-light));
221221
`
222222

223-
let compiler = await compile(input, '/root', {
223+
let compiler = await compile(input, {
224224
loadModule: async () => ({
225225
module: {
226226
darkMode: ['variant', '&:is(.dark)'],
@@ -270,7 +270,7 @@ describe('theme callbacks', () => {
270270
@config "./config.js";
271271
`
272272

273-
let compiler = await compile(input, '/root', {
273+
let compiler = await compile(input, {
274274
loadModule: async () => ({
275275
module: {
276276
theme: {
@@ -381,7 +381,7 @@ describe('theme overrides order', () => {
381381
@config "./config.js";
382382
`
383383

384-
let compiler = await compile(input, '/root', {
384+
let compiler = await compile(input, {
385385
loadModule: async () => ({
386386
module: {
387387
theme: {
@@ -427,7 +427,7 @@ describe('theme overrides order', () => {
427427
@plugin "./plugin.js";
428428
`
429429

430-
let compiler = await compile(input, '/root', {
430+
let compiler = await compile(input, {
431431
loadModule: async (id) => {
432432
if (id.includes('config.js')) {
433433
return {
@@ -555,7 +555,7 @@ describe('default font family compatibility', () => {
555555
@tailwind utilities;
556556
`
557557

558-
let compiler = await compile(input, '/root', {
558+
let compiler = await compile(input, {
559559
loadModule: async () => ({
560560
module: {
561561
theme: {
@@ -594,7 +594,7 @@ describe('default font family compatibility', () => {
594594
@tailwind utilities;
595595
`
596596

597-
let compiler = await compile(input, '/root', {
597+
let compiler = await compile(input, {
598598
loadModule: async () => ({
599599
module: {
600600
theme: {
@@ -634,7 +634,7 @@ describe('default font family compatibility', () => {
634634
@tailwind utilities;
635635
`
636636

637-
let compiler = await compile(input, '/root', {
637+
let compiler = await compile(input, {
638638
loadModule: async () => ({
639639
module: {
640640
theme: {
@@ -674,7 +674,7 @@ describe('default font family compatibility', () => {
674674
@tailwind utilities;
675675
`
676676

677-
let compiler = await compile(input, '/root', {
677+
let compiler = await compile(input, {
678678
loadModule: async () => ({
679679
module: {
680680
theme: {
@@ -721,7 +721,7 @@ describe('default font family compatibility', () => {
721721
@tailwind utilities;
722722
`
723723

724-
let compiler = await compile(input, '/root', {
724+
let compiler = await compile(input, {
725725
loadModule: async () => ({
726726
module: {
727727
theme: {
@@ -761,7 +761,7 @@ describe('default font family compatibility', () => {
761761
@tailwind utilities;
762762
`
763763

764-
let compiler = await compile(input, '/root', {
764+
let compiler = await compile(input, {
765765
loadModule: async () => ({
766766
module: {
767767
theme: {
@@ -800,7 +800,7 @@ describe('default font family compatibility', () => {
800800
@tailwind utilities;
801801
`
802802

803-
let compiler = await compile(input, '/root', {
803+
let compiler = await compile(input, {
804804
loadModule: async () => ({
805805
module: {
806806
theme: {
@@ -834,7 +834,7 @@ describe('default font family compatibility', () => {
834834
@tailwind utilities;
835835
`
836836

837-
let compiler = await compile(input, '/root', {
837+
let compiler = await compile(input, {
838838
loadModule: async () => ({
839839
module: {
840840
theme: {
@@ -873,7 +873,7 @@ describe('default font family compatibility', () => {
873873
@tailwind utilities;
874874
`
875875

876-
let compiler = await compile(input, '/root', {
876+
let compiler = await compile(input, {
877877
loadModule: async () => ({
878878
module: {
879879
theme: {
@@ -913,7 +913,7 @@ describe('default font family compatibility', () => {
913913
@tailwind utilities;
914914
`
915915

916-
let compiler = await compile(input, '/root', {
916+
let compiler = await compile(input, {
917917
loadModule: async () => ({
918918
module: {
919919
theme: {
@@ -953,7 +953,7 @@ describe('default font family compatibility', () => {
953953
@tailwind utilities;
954954
`
955955

956-
let compiler = await compile(input, '/root', {
956+
let compiler = await compile(input, {
957957
loadModule: async () => ({
958958
module: {
959959
theme: {
@@ -1000,7 +1000,7 @@ describe('default font family compatibility', () => {
10001000
@tailwind utilities;
10011001
`
10021002

1003-
let compiler = await compile(input, '/root', {
1003+
let compiler = await compile(input, {
10041004
loadModule: async () => ({
10051005
module: {
10061006
theme: {
@@ -1040,7 +1040,7 @@ describe('default font family compatibility', () => {
10401040
@tailwind utilities;
10411041
`
10421042

1043-
let compiler = await compile(input, '/root', {
1043+
let compiler = await compile(input, {
10441044
loadModule: async () => ({
10451045
module: {
10461046
theme: {
@@ -1070,7 +1070,7 @@ test('creates variants for `data`, `supports`, and `aria` theme options at the s
10701070
@config "./config.js";
10711071
`
10721072

1073-
let compiler = await compile(input, '/root', {
1073+
let compiler = await compile(input, {
10741074
loadModule: async () => ({
10751075
module: {
10761076
theme: {
@@ -1169,7 +1169,7 @@ test('merges css breakpoints with js config screens', async () => {
11691169
@tailwind utilities;
11701170
`
11711171

1172-
let compiler = await compile(input, '/root', {
1172+
let compiler = await compile(input, {
11731173
loadModule: async () => ({
11741174
module: {
11751175
theme: {

0 commit comments

Comments
 (0)