@@ -4,40 +4,132 @@ import { expect, test } from 'vitest';
4
4
5
5
test ( 'should extract css successfully in bundle' , async ( ) => {
6
6
const fixturePath = join ( __dirname , 'bundle' ) ;
7
- const { contents } = await buildAndGetResults ( { fixturePath, type : 'css' } ) ;
8
- const esmFiles = Object . keys ( contents . esm ) ;
9
- expect ( esmFiles ) . toMatchInlineSnapshot ( `
7
+ const { contents, files } = await buildAndGetResults ( {
8
+ fixturePath,
9
+ type : 'css' ,
10
+ } ) ;
11
+
12
+ expect ( files . esm ) . toMatchInlineSnapshot ( `
10
13
[
11
14
"<ROOT>/tests/integration/style/css/bundle/dist/esm/static/css/index.css",
12
15
]
13
16
` ) ;
14
17
15
- const cjsFiles = Object . keys ( contents . cjs ) ;
16
- expect ( cjsFiles ) . toMatchInlineSnapshot ( `
18
+ expect ( contents . esm ) . toMatchInlineSnapshot ( `
19
+ {
20
+ "<ROOT>/tests/integration/style/css/bundle/dist/esm/static/css/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
21
+ @import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css);
22
+ .lib1 {
23
+ color: red;
24
+ }
25
+
26
+ .lib2 {
27
+ color: green;
28
+ }
29
+
30
+ .import {
31
+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
32
+ }
33
+
34
+ ",
35
+ }
36
+ ` ) ;
37
+
38
+ expect ( files . cjs ) . toMatchInlineSnapshot ( `
17
39
[
18
40
"<ROOT>/tests/integration/style/css/bundle/dist/cjs/static/css/index.css",
19
41
]
20
42
` ) ;
43
+
44
+ expect ( contents . cjs ) . toMatchInlineSnapshot ( `
45
+ {
46
+ "<ROOT>/tests/integration/style/css/bundle/dist/cjs/static/css/index.css": "@import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css);
47
+ @import url(https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css);
48
+ .lib1 {
49
+ color: red;
50
+ }
51
+
52
+ .lib2 {
53
+ color: green;
54
+ }
55
+
56
+ .import {
57
+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
58
+ }
59
+
60
+ ",
61
+ }
62
+ ` ) ;
21
63
} ) ;
22
64
23
65
test ( 'should extract css successfully in bundle-false' , async ( ) => {
24
66
const fixturePath = join ( __dirname , 'bundle-false' ) ;
25
- const { contents } = await buildAndGetResults ( { fixturePath, type : 'css' } ) ;
26
- const esmFiles = Object . keys ( contents . esm ) ;
27
- expect ( esmFiles ) . toMatchInlineSnapshot ( `
67
+ const { contents, files } = await buildAndGetResults ( {
68
+ fixturePath,
69
+ type : 'css' ,
70
+ } ) ;
71
+
72
+ expect ( files . esm ) . toMatchInlineSnapshot ( `
28
73
[
29
74
"<ROOT>/tests/integration/style/css/bundle-false/dist/esm/import.css",
30
75
"<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib1.css",
31
76
"<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib2.css",
32
77
]
33
78
` ) ;
79
+ expect ( contents . esm ) . toMatchInlineSnapshot ( `
80
+ {
81
+ "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/import.css": "@import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css";
82
+ @import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css";
83
+ @import "lib1.css";
84
+ @import "lib2.css";
85
+
86
+ .import {
87
+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
88
+ }
89
+
90
+ ",
91
+ "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib1.css": ".lib1 {
92
+ color: red;
93
+ }
94
+
95
+ ",
96
+ "<ROOT>/tests/integration/style/css/bundle-false/dist/esm/lib2.css": ".lib2 {
97
+ color: green;
98
+ }
99
+
100
+ ",
101
+ }
102
+ ` ) ;
34
103
35
- const cjsFiles = Object . keys ( contents . cjs ) ;
36
- expect ( cjsFiles ) . toMatchInlineSnapshot ( `
104
+ expect ( files . cjs ) . toMatchInlineSnapshot ( `
37
105
[
38
106
"<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/import.css",
39
107
"<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib1.css",
40
108
"<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib2.css",
41
109
]
42
110
` ) ;
111
+ expect ( contents . cjs ) . toMatchInlineSnapshot ( `
112
+ {
113
+ "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/import.css": "@import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css";
114
+ @import "https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.0.0/modern-normalize.css";
115
+ @import "lib1.css";
116
+ @import "lib2.css";
117
+
118
+ .import {
119
+ background-image: url("https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.css");
120
+ }
121
+
122
+ ",
123
+ "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib1.css": ".lib1 {
124
+ color: red;
125
+ }
126
+
127
+ ",
128
+ "<ROOT>/tests/integration/style/css/bundle-false/dist/cjs/lib2.css": ".lib2 {
129
+ color: green;
130
+ }
131
+
132
+ ",
133
+ }
134
+ ` ) ;
43
135
} ) ;
0 commit comments