@@ -18,7 +18,7 @@ it('avoids importer when canonicalize() returns null', () =>
18
18
sandbox ( dir => {
19
19
dir . write ( { 'dir/_other.scss' : 'a {from: dir}' } ) ;
20
20
21
- const result = compileString ( '@import "other";' , {
21
+ const result = compileString ( '@use "other";' , {
22
22
importers : [
23
23
{
24
24
canonicalize : ( ) => null ,
@@ -37,7 +37,7 @@ it('fails to import when load() returns null', () =>
37
37
dir . write ( { 'dir/_other.scss' : 'a {from: dir}' } ) ;
38
38
39
39
expect ( ( ) => {
40
- compileString ( '@import "other";' , {
40
+ compileString ( '@use "other";' , {
41
41
importers : [
42
42
{
43
43
canonicalize : ( url : string ) => new URL ( `u:${ url } ` ) ,
@@ -52,7 +52,7 @@ it('fails to import when load() returns null', () =>
52
52
it ( 'prefers a relative file load to an importer' , ( ) =>
53
53
sandbox ( dir => {
54
54
dir . write ( {
55
- 'input.scss' : '@import "other"' ,
55
+ 'input.scss' : '@use "other"' ,
56
56
'_other.scss' : 'a {from: relative}' ,
57
57
} ) ;
58
58
@@ -74,7 +74,7 @@ it('prefers a relative file load to an importer', () =>
74
74
it ( 'prefers an importer to a load path' , ( ) =>
75
75
sandbox ( dir => {
76
76
dir . write ( {
77
- 'input.scss' : '@import "other"' ,
77
+ 'input.scss' : '@use "other"' ,
78
78
'dir/_other.scss' : 'a {from: load-path}' ,
79
79
} ) ;
80
80
@@ -95,7 +95,7 @@ describe('FileImporter', () => {
95
95
sandbox ( dir => {
96
96
dir . write ( { '_other.scss' : 'a {b: c}' } ) ;
97
97
98
- const result = compileString ( '@import "other";' , {
98
+ const result = compileString ( '@use "other";' , {
99
99
importers : [ { findFileUrl : ( ) => dir . url ( '_other.scss' ) } ] ,
100
100
} ) ;
101
101
expect ( result . css ) . toBe ( 'a {\n b: c;\n}' ) ;
@@ -105,7 +105,7 @@ describe('FileImporter', () => {
105
105
sandbox ( dir => {
106
106
dir . write ( { 'other/_index.scss' : 'a {b: c}' } ) ;
107
107
108
- const result = compileString ( '@import "other";' , {
108
+ const result = compileString ( '@use "other";' , {
109
109
importers : [ { findFileUrl : ( ) => dir . url ( 'other' ) } ] ,
110
110
} ) ;
111
111
expect ( result . css ) . toBe ( 'a {\n b: c;\n}' ) ;
@@ -115,7 +115,7 @@ describe('FileImporter', () => {
115
115
sandbox ( dir => {
116
116
dir . write ( { '_other.scss' : 'a {from: dir}' } ) ;
117
117
118
- const result = compileString ( '@import "other";' , {
118
+ const result = compileString ( '@use "other";' , {
119
119
importers : [ { findFileUrl : ( ) => null } ] ,
120
120
loadPaths : [ dir . root ] ,
121
121
} ) ;
@@ -126,7 +126,7 @@ describe('FileImporter', () => {
126
126
sandbox ( dir => {
127
127
dir . write ( { '_other.scss' : 'a {from: dir}' } ) ;
128
128
129
- const result = compileString ( '@import "other";' , {
129
+ const result = compileString ( '@use "other";' , {
130
130
importers : [ { findFileUrl : ( ) => dir . url ( 'nonexistent/other' ) } ] ,
131
131
loadPaths : [ dir . root ] ,
132
132
} ) ;
@@ -137,7 +137,7 @@ describe('FileImporter', () => {
137
137
sandbox ( dir => {
138
138
dir . write ( { 'dir/_other.scss' : 'a {b: c}' } ) ;
139
139
140
- const result = compileString ( '@import "u:other";' , {
140
+ const result = compileString ( '@use "u:other";' , {
141
141
importers : [
142
142
{
143
143
findFileUrl ( url : string ) {
@@ -154,7 +154,7 @@ describe('FileImporter', () => {
154
154
sandbox ( dir => {
155
155
dir . write ( { '_other.scss' : 'a {b: c}' } ) ;
156
156
157
- const result = compileString ( `@import "${ dir . url ( 'other' ) } ";` , {
157
+ const result = compileString ( `@use "${ dir . url ( 'other' ) } ";` , {
158
158
importers : [
159
159
{
160
160
findFileUrl ( ) {
@@ -168,11 +168,11 @@ describe('FileImporter', () => {
168
168
169
169
it ( "doesn't pass relative loads to the importer" , ( ) =>
170
170
sandbox ( dir => {
171
- dir . write ( { '_midstream.scss' : '@import "upstream"' } ) ;
171
+ dir . write ( { '_midstream.scss' : '@use "upstream"' } ) ;
172
172
dir . write ( { '_upstream.scss' : 'a {b: c}' } ) ;
173
173
174
174
let count = 0 ;
175
- const result = compileString ( '@import "midstream";' , {
175
+ const result = compileString ( '@use "midstream";' , {
176
176
importers : [
177
177
{
178
178
findFileUrl ( ) {
@@ -191,7 +191,7 @@ describe('FileImporter', () => {
191
191
192
192
it ( 'wraps an error' , ( ) => {
193
193
expect ( ( ) => {
194
- compileString ( '@import "other";' , {
194
+ compileString ( '@use "other";' , {
195
195
importers : [
196
196
{
197
197
findFileUrl ( ) {
@@ -205,7 +205,7 @@ describe('FileImporter', () => {
205
205
206
206
it ( 'rejects a non-file URL' , ( ) => {
207
207
expect ( ( ) => {
208
- compileString ( '@import "other";' , {
208
+ compileString ( '@use "other";' , {
209
209
importers : [ { findFileUrl : ( ) => new URL ( 'u:other.scss' ) } ] ,
210
210
} ) ;
211
211
} ) . toThrowSassException ( { line : 0 } ) ;
@@ -215,7 +215,7 @@ describe('FileImporter', () => {
215
215
it ( '.scss, parses it as SCSS' , ( ) =>
216
216
sandbox ( dir => {
217
217
dir . write ( { '_other.scss' : '$a: value; b {c: $a}' } ) ;
218
- const result = compileString ( '@import "other";' , {
218
+ const result = compileString ( '@use "other";' , {
219
219
importers : [ { findFileUrl : ( ) => dir . url ( 'other' ) } ] ,
220
220
} ) ;
221
221
expect ( result . css ) . toBe ( 'b {\n c: value;\n}' ) ;
@@ -224,7 +224,7 @@ describe('FileImporter', () => {
224
224
it ( '.sass, parses it as the indented syntax' , ( ) =>
225
225
sandbox ( dir => {
226
226
dir . write ( { '_other.sass' : '$a: value\nb\n c: $a' } ) ;
227
- const result = compileString ( '@import "other";' , {
227
+ const result = compileString ( '@use "other";' , {
228
228
importers : [ { findFileUrl : ( ) => dir . url ( 'other' ) } ] ,
229
229
} ) ;
230
230
expect ( result . css ) . toBe ( 'b {\n c: value;\n}' ) ;
@@ -233,7 +233,7 @@ describe('FileImporter', () => {
233
233
it ( '.css, allows plain CSS' , ( ) =>
234
234
sandbox ( dir => {
235
235
dir . write ( { '_other.css' : 'a {b: c}' } ) ;
236
- const result = compileString ( '@import "other";' , {
236
+ const result = compileString ( '@use "other";' , {
237
237
importers : [ { findFileUrl : ( ) => dir . url ( 'other' ) } ] ,
238
238
} ) ;
239
239
expect ( result . css ) . toBe ( 'a {\n b: c;\n}' ) ;
@@ -243,7 +243,7 @@ describe('FileImporter', () => {
243
243
sandbox ( dir => {
244
244
dir . write ( { '_other.css' : '$a: value; b {c: $a}' } ) ;
245
245
expect ( ( ) => {
246
- compileString ( '@import "other";' , {
246
+ compileString ( '@use "other";' , {
247
247
importers : [ { findFileUrl : ( ) => dir . url ( 'other' ) } ] ,
248
248
} ) ;
249
249
} ) . toThrowSassException ( {
@@ -266,6 +266,8 @@ describe('FileImporter', () => {
266
266
} ,
267
267
} ,
268
268
] ,
269
+ // TODO(jathak): Add this once import deprecation is active
270
+ // silenceDeprecations: ['import'],
269
271
} ) ;
270
272
} ) ) ;
271
273
@@ -289,7 +291,7 @@ describe('FileImporter', () => {
289
291
it ( 'set for a relative URL' , ( ) =>
290
292
sandbox ( dir => {
291
293
dir . write ( { '_other.css' : 'a {b: c}' } ) ;
292
- const result = compileString ( '@import "other";' , {
294
+ const result = compileString ( '@use "other";' , {
293
295
importers : [
294
296
{
295
297
findFileUrl : ( url : string , context : CanonicalizeContext ) => {
@@ -308,7 +310,7 @@ describe('FileImporter', () => {
308
310
it ( 'set for an absolute URL' , ( ) =>
309
311
sandbox ( dir => {
310
312
dir . write ( { '_other.css' : 'a {b: c}' } ) ;
311
- const result = compileString ( '@import "u:other";' , {
313
+ const result = compileString ( '@use "u:other";' , {
312
314
importers : [
313
315
{
314
316
findFileUrl : ( url : string , context : CanonicalizeContext ) => {
@@ -327,7 +329,7 @@ describe('FileImporter', () => {
327
329
it ( 'unset when the URL is unavailable' , ( ) =>
328
330
sandbox ( dir => {
329
331
dir . write ( { '_other.css' : 'a {b: c}' } ) ;
330
- const result = compileString ( '@import "u:other";' , {
332
+ const result = compileString ( '@use "u:other";' , {
331
333
importers : [
332
334
{
333
335
findFileUrl : ( url : string , context : CanonicalizeContext ) => {
@@ -342,7 +344,7 @@ describe('FileImporter', () => {
342
344
} ) ;
343
345
344
346
describe ( 'async' , ( ) => {
345
- it ( 'resolves an @import ' , async ( ) =>
347
+ it ( 'resolves an @use ' , async ( ) =>
346
348
sandbox ( async dir => {
347
349
dir . write ( { '_other.scss' : 'a {b: c}' } ) ;
348
350
const result = await compileStringAsync ( '@use "other"' , {
@@ -357,7 +359,7 @@ describe('FileImporter', () => {
357
359
358
360
it ( 'wraps an error' , async ( ) => {
359
361
await expectAsync ( ( ) =>
360
- compileStringAsync ( '@import "other";' , {
362
+ compileStringAsync ( '@use "other";' , {
361
363
importers : [
362
364
{
363
365
findFileUrl : ( ) => Promise . reject ( 'this import is bad actually' ) ,
@@ -376,10 +378,10 @@ describe('FileImporter', () => {
376
378
} ) ;
377
379
378
380
dir . write ( {
379
- 'main.scss' : '@import "sub1/test"; @import "sub1/sub2/test"' ,
380
- 'sub1/test.scss' : '@import "y"' ,
381
+ 'main.scss' : '@use "sub1/test"; @use "sub1/sub2/test" as test2 ' ,
382
+ 'sub1/test.scss' : '@use "y"' ,
381
383
'sub1/x.scss' : 'x { from: sub1; }' ,
382
- 'sub1/sub2/test.scss' : '@import "y"' ,
384
+ 'sub1/sub2/test.scss' : '@use "y"' ,
383
385
'sub1/sub2/x.scss' : 'x { from: sub2; }' ,
384
386
} ) ;
385
387
0 commit comments