@@ -32,7 +32,7 @@ describe('babel plugin', () => {
3232 ` ;
3333
3434 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
35- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
35+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
3636 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
3737 import { style } from '@vanilla-extract/css';
3838 const one = style({
@@ -52,7 +52,7 @@ describe('babel plugin', () => {
5252 ` ;
5353
5454 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
55- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
55+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
5656 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
5757 import { mapToStyles } from '@vanilla-extract/css';
5858 const colors = mapToStyles({
@@ -74,7 +74,7 @@ describe('babel plugin', () => {
7474 ` ;
7575
7676 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
77- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
77+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
7878 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
7979 import { mapToStyles } from '@vanilla-extract/css';
8080 const colors = mapToStyles({
@@ -96,7 +96,7 @@ describe('babel plugin', () => {
9696 ` ;
9797
9898 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
99- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
99+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
100100 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
101101 import { style } from '@vanilla-extract/css';
102102 export default style({
@@ -120,7 +120,7 @@ describe('babel plugin', () => {
120120 ` ;
121121
122122 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
123- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
123+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
124124 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
125125 import { style } from '@vanilla-extract/css';
126126 const test = {
@@ -146,7 +146,7 @@ describe('babel plugin', () => {
146146 ` ;
147147
148148 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
149- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
149+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
150150 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
151151 import { style } from '@vanilla-extract/css';
152152
@@ -170,7 +170,7 @@ describe('babel plugin', () => {
170170 ` ;
171171
172172 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
173- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
173+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
174174 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
175175 import { style } from '@vanilla-extract/css';
176176
@@ -194,7 +194,7 @@ describe('babel plugin', () => {
194194 ` ;
195195
196196 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
197- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
197+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
198198 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
199199 import { style } from '@vanilla-extract/css';
200200
@@ -216,7 +216,7 @@ describe('babel plugin', () => {
216216 ` ;
217217
218218 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
219- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
219+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
220220 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
221221 import { globalStyle } from '@vanilla-extract/css';
222222 globalStyle('html, body', {
@@ -234,7 +234,7 @@ describe('babel plugin', () => {
234234 ` ;
235235
236236 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
237- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
237+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
238238 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
239239 import { createVar } from '@vanilla-extract/css';
240240 const myVar = createVar(\\"myVar\\");
@@ -252,7 +252,7 @@ describe('babel plugin', () => {
252252 ` ;
253253
254254 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
255- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
255+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
256256 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
257257 import { fontFace } from '@vanilla-extract/css';
258258 const myFont = fontFace({
@@ -272,7 +272,7 @@ describe('babel plugin', () => {
272272 ` ;
273273
274274 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
275- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
275+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
276276 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
277277 import { globalFontFace } from '@vanilla-extract/css';
278278 globalFontFace('myFont', {
@@ -293,7 +293,7 @@ describe('babel plugin', () => {
293293 ` ;
294294
295295 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
296- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
296+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
297297 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
298298 import { keyframes } from '@vanilla-extract/css';
299299 const myAnimation = keyframes({
@@ -319,7 +319,7 @@ describe('babel plugin', () => {
319319 ` ;
320320
321321 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
322- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
322+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
323323 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
324324 import { globalKeyframes } from '@vanilla-extract/css';
325325 globalKeyframes('myKeyframes', {
@@ -342,7 +342,7 @@ describe('babel plugin', () => {
342342 ` ;
343343
344344 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
345- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
345+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
346346 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
347347 import { createTheme } from '@vanilla-extract/css';
348348 const darkTheme = createTheme({}, {}, \\"darkTheme\\");
@@ -358,7 +358,7 @@ describe('babel plugin', () => {
358358 ` ;
359359
360360 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
361- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
361+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
362362 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
363363 import { createTheme } from '@vanilla-extract/css';
364364 const [theme, vars] = createTheme({}, {}, \\"theme\\");
@@ -374,7 +374,7 @@ describe('babel plugin', () => {
374374 ` ;
375375
376376 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
377- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
377+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
378378 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
379379 import { createGlobalTheme } from '@vanilla-extract/css';
380380 const themeVars = createGlobalTheme(':root', {
@@ -394,7 +394,7 @@ describe('babel plugin', () => {
394394 ` ;
395395
396396 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
397- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
397+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
398398 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
399399 import { createThemeVars } from '@vanilla-extract/css';
400400 const themeVars = createThemeVars({
@@ -420,7 +420,7 @@ describe('babel plugin', () => {
420420 ` ;
421421
422422 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
423- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
423+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
424424 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
425425 import { style, mapToStyles } from '@vanilla-extract/css';
426426 const three = style({
@@ -437,7 +437,7 @@ describe('babel plugin', () => {
437437 ` ) ;
438438 } ) ;
439439
440- it ( 'should only apply to functions imported from the relevant package' , ( ) => {
440+ it ( 'should only apply debug ids to functions imported from the relevant package' , ( ) => {
441441 const source = `
442442 import { style } from 'some-other-package';
443443
@@ -447,13 +447,57 @@ describe('babel plugin', () => {
447447 ` ;
448448
449449 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
450- "import { style } from 'some-other-package';
450+ "import { setFileScope, endFileScope } from '@vanilla-extract/css/fileScope';
451+ setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
452+ import { style } from 'some-other-package';
453+ const three = style({
454+ zIndex: 2
455+ });
456+ endFileScope()"
457+ ` ) ;
458+ } ) ;
459+
460+ it ( 'should only apply to .css.ts files' , ( ) => {
461+ const source = `
462+ import { style } from '@vanilla-extract/css';
463+
464+ const three = style({
465+ zIndex: 2,
466+ });
467+ ` ;
468+
469+ expect ( transform ( source , { } , './dir/mockFilename.ts' ) )
470+ . toMatchInlineSnapshot ( `
471+ "import { style } from '@vanilla-extract/css';
451472 const three = style({
452473 zIndex: 2
453474 });"
454475 ` ) ;
455476 } ) ;
456477
478+ it ( 'should ignore files that already have filescope information' , ( ) => {
479+ const source = `
480+ import { setFileScope, endFileScope } from '@vanilla-extract/css/fileScope';
481+ setFileScope('src/dir/someFileName.css.ts', 'some-package');
482+ import { style } from '@vanilla-extract/css';
483+
484+ const three = style({
485+ zIndex: 2,
486+ });
487+ endFileScope();
488+ ` ;
489+
490+ expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
491+ "import { setFileScope, endFileScope } from '@vanilla-extract/css/fileScope';
492+ setFileScope('src/dir/someFileName.css.ts', 'some-package');
493+ import { style } from '@vanilla-extract/css';
494+ const three = style({
495+ zIndex: 2
496+ });
497+ endFileScope();"
498+ ` ) ;
499+ } ) ;
500+
457501 it ( 'should handle renaming imports' , ( ) => {
458502 const source = `
459503 import { style as specialStyle } from '@vanilla-extract/css';
@@ -464,7 +508,7 @@ describe('babel plugin', () => {
464508 ` ;
465509
466510 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
467- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
511+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
468512 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
469513 import { style as specialStyle } from '@vanilla-extract/css';
470514 const four = specialStyle({
@@ -486,7 +530,7 @@ describe('babel plugin', () => {
486530 ` ;
487531
488532 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
489- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
533+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
490534 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
491535 import { style } from '@vanilla-extract/css';
492536 export const height = [style({
@@ -508,7 +552,7 @@ describe('babel plugin', () => {
508552 ` ;
509553
510554 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
511- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
555+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
512556 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
513557 import { style } from '@vanilla-extract/css';
514558 export const height = {
@@ -530,7 +574,7 @@ describe('babel plugin', () => {
530574 ` ;
531575
532576 expect ( transform ( source ) ) . toMatchInlineSnapshot ( `
533- "import { setFileScope, endFileScope } from \\" @vanilla-extract/css/fileScope\\" ;
577+ "import { setFileScope, endFileScope } from ' @vanilla-extract/css/fileScope' ;
534578 setFileScope(\\"src/dir/mockFilename.css.ts\\", \\"@vanilla-extract/babel-plugin\\");
535579 import * as css from '@vanilla-extract/css';
536580 const one = css.style({
0 commit comments