@@ -91,21 +91,23 @@ describe('addFile', () => {
9191 // - The check stage cache for files that indirectly import the added file should also be invalidated.
9292 const iff = await createIFF ( {
9393 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
94- 'src/b.module.css' : '@import "./a.module.css";' , // directly
95- 'src/c.module.css' : '@value a_1 from "./b.module.css";' , // indirectly
94+ 'src/a.module.css' : '' ,
95+ 'src/b.module.css' : '@value a_1 from "./a.module.css";' , // directly
96+ 'src/re-export.module.css' : '@import "./a.module.css";' ,
97+ 'src/c.module.css' : '@value a_1 from "./re-export.module.css";' , // indirectly
9698 } ) ;
9799 const project = createProject ( { project : iff . rootDir } ) ;
98100 expect ( formatDiagnostics ( project . getDiagnostics ( ) , iff . rootDir ) ) . toMatchInlineSnapshot ( `
99101 [
100102 {
101103 "category": "error",
102104 "fileName": "<rootDir>/src/b.module.css",
103- "length": 14 ,
105+ "length": 3 ,
104106 "start": {
105- "column": 10 ,
107+ "column": 8 ,
106108 "line": 1,
107109 },
108- "text": "Cannot import module './a.module.css'",
110+ "text": "Module './a.module.css' has no exported token 'a_1'. ",
109111 },
110112 {
111113 "category": "error",
@@ -115,12 +117,12 @@ describe('addFile', () => {
115117 "column": 8,
116118 "line": 1,
117119 },
118- "text": "Module './b .module.css' has no exported token 'a_1'.",
120+ "text": "Module './re-export .module.css' has no exported token 'a_1'.",
119121 },
120122 ]
121123 ` ) ;
122124 await writeFile ( iff . join ( 'src/a.module.css' ) , '@value a_1: red;' ) ;
123- project . addFile ( iff . join ( 'src/a.module.css' ) ) ;
125+ project . updateFile ( iff . join ( 'src/a.module.css' ) ) ;
124126 expect ( formatDiagnostics ( project . getDiagnostics ( ) , iff . rootDir ) ) . toMatchInlineSnapshot ( `[]` ) ;
125127 } ) ;
126128 test ( 'changes the resolution results of import specifiers in other files' , async ( ) => {
@@ -204,19 +206,19 @@ describe('updateFile', () => {
204206 ` ) ;
205207
206208 // New semantic diagnostics are reported
207- await writeFile ( iff . join ( 'src/a.module.css' ) , `@import './non-existent.module.css'; ` ) ;
209+ await writeFile ( iff . join ( 'src/a.module.css' ) , `.a-1 {} ` ) ;
208210 project . updateFile ( iff . join ( 'src/a.module.css' ) ) ;
209211 expect ( formatDiagnostics ( project . getDiagnostics ( ) , iff . rootDir ) ) . toMatchInlineSnapshot ( `
210212 [
211213 {
212214 "category": "error",
213215 "fileName": "<rootDir>/src/a.module.css",
214- "length": 25 ,
216+ "length": 3 ,
215217 "start": {
216- "column": 10 ,
218+ "column": 2 ,
217219 "line": 1,
218220 },
219- "text": "Cannot import module './non-existent.module.css' ",
221+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers. ",
220222 },
221223 ]
222224 ` ) ;
@@ -311,25 +313,16 @@ describe('removeFile', () => {
311313 const iff = await createIFF ( {
312314 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
313315 'src/a.module.css' : '@value a_1: red;' ,
314- 'src/b.module.css' : '@import "./a.module.css";' , // directly
315- 'src/c.module.css' : '@value a_1 from "./b.module.css";' , // indirectly
316+ 'src/b.module.css' : '@value a_1 from "./a.module.css";' , // directly
317+ 'src/re-export.module.css' : '@import "./a.module.css";' ,
318+ 'src/c.module.css' : '@value a_1 from "./re-export.module.css";' , // indirectly
316319 } ) ;
317320 const project = createProject ( { project : iff . rootDir } ) ;
318321 expect ( formatDiagnostics ( project . getDiagnostics ( ) , iff . rootDir ) ) . toMatchInlineSnapshot ( `[]` ) ;
319322 await rm ( iff . join ( 'src/a.module.css' ) ) ;
320323 project . removeFile ( iff . join ( 'src/a.module.css' ) ) ;
321324 expect ( formatDiagnostics ( project . getDiagnostics ( ) , iff . rootDir ) ) . toMatchInlineSnapshot ( `
322325 [
323- {
324- "category": "error",
325- "fileName": "<rootDir>/src/b.module.css",
326- "length": 14,
327- "start": {
328- "column": 10,
329- "line": 1,
330- },
331- "text": "Cannot import module './a.module.css'",
332- },
333326 {
334327 "category": "error",
335328 "fileName": "<rootDir>/src/c.module.css",
@@ -338,7 +331,7 @@ describe('removeFile', () => {
338331 "column": 8,
339332 "line": 1,
340333 },
341- "text": "Module './b .module.css' has no exported token 'a_1'.",
334+ "text": "Module './re-export .module.css' has no exported token 'a_1'.",
342335 },
343336 ]
344337 ` ) ;
@@ -466,8 +459,8 @@ describe('getDiagnostics', () => {
466459 test ( 'returns semantic diagnostics' , async ( ) => {
467460 const iff = await createIFF ( {
468461 'tsconfig.json' : '{ "cmkOptions": { "enabled": true } }' ,
469- 'src/a.module.css' : `@import './non-existent-1.module.css'; ` ,
470- 'src/b.module.css' : `@import './non-existent-2.module.css'; ` ,
462+ 'src/a.module.css' : `.a-1 {} ` ,
463+ 'src/b.module.css' : `.b-1 {} ` ,
471464 } ) ;
472465 const project = createProject ( { project : iff . rootDir } ) ;
473466 const diagnostics = project . getDiagnostics ( ) ;
@@ -476,22 +469,22 @@ describe('getDiagnostics', () => {
476469 {
477470 "category": "error",
478471 "fileName": "<rootDir>/src/a.module.css",
479- "length": 27 ,
472+ "length": 3 ,
480473 "start": {
481- "column": 10 ,
474+ "column": 2 ,
482475 "line": 1,
483476 },
484- "text": "Cannot import module './non-existent-1.module.css' ",
477+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers. ",
485478 },
486479 {
487480 "category": "error",
488481 "fileName": "<rootDir>/src/b.module.css",
489- "length": 27 ,
482+ "length": 3 ,
490483 "start": {
491- "column": 10 ,
484+ "column": 2 ,
492485 "line": 1,
493486 },
494- "text": "Cannot import module './non-existent-2.module.css' ",
487+ "text": "css-modules-kit does not support invalid names as JavaScript identifiers. ",
495488 },
496489 ]
497490 ` ) ;
0 commit comments