From dbf178dd0f6882425646d78812ce8c0d32da31c3 Mon Sep 17 00:00:00 2001 From: Remus Mate Date: Sun, 4 Feb 2024 13:55:40 +1100 Subject: [PATCH] code review feedback --- packages/integration/src/compiler.ts | 4 ++-- tests/compiler/compiler.test.ts | 6 +++--- tests/compiler/compiler.vitest.test.ts | 2 ++ tests/compiler/fixtures/tsconfig-paths/src/main.tsx | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/integration/src/compiler.ts b/packages/integration/src/compiler.ts index 33a87ac8..c2137571 100644 --- a/packages/integration/src/compiler.ts +++ b/packages/integration/src/compiler.ts @@ -22,11 +22,11 @@ const scanModule = (entryModule: ModuleNode) => { const watchFiles = new Set(); for (const moduleNode of queue) { - if (!moduleNode.id || moduleNode.id.includes('@vanilla-extract/')) { + if (moduleNode.id?.includes('@vanilla-extract/')) { continue; } - if (cssFileFilter.test(moduleNode.id)) { + if (moduleNode.id && cssFileFilter.test(moduleNode.id)) { cssDeps.add(moduleNode.id); } if (moduleNode.file) { diff --git a/tests/compiler/compiler.test.ts b/tests/compiler/compiler.test.ts index dab72690..1cd70474 100644 --- a/tests/compiler/compiler.test.ts +++ b/tests/compiler/compiler.test.ts @@ -225,7 +225,7 @@ describe('compiler', () => { test('throws on getCssForFile when file does not exist', async () => { const compiler = compilers.default; - let error: Error | undefined; + let error: Error; try { compiler.getCssForFile('does-not-exist.css.ts'); @@ -234,8 +234,8 @@ describe('compiler', () => { } expect( - // We know `error.message` is defined, and we want make the snapshot consistent across machines - normalizePath(error!.message!.replace(__dirname, '{{__dirname}}')), + // We know `error.message` is defined here + normalizePath(error!.message), ).toMatchInlineSnapshot( `No CSS for file: {{__dirname}}/does-not-exist.css.ts`, ); diff --git a/tests/compiler/compiler.vitest.test.ts b/tests/compiler/compiler.vitest.test.ts index 60ad4d09..a8529fdd 100644 --- a/tests/compiler/compiler.vitest.test.ts +++ b/tests/compiler/compiler.vitest.test.ts @@ -15,6 +15,8 @@ expect.addSnapshotSerializer({ '"', }); +// ! These tests are to ensure that the compiler works correctly in Vitest. +// ! Please add tests to `compiler.test.ts` going forward. describe('compiler running in Vitest', () => { let compilers: Record< 'default' | 'vitePlugins' | 'viteResolve', diff --git a/tests/compiler/fixtures/tsconfig-paths/src/main.tsx b/tests/compiler/fixtures/tsconfig-paths/src/main.tsx index d37e3782..3f304bd1 100644 --- a/tests/compiler/fixtures/tsconfig-paths/src/main.tsx +++ b/tests/compiler/fixtures/tsconfig-paths/src/main.tsx @@ -1,5 +1,5 @@ import { box } from 'main.css'; document.getElementById('root')!.innerHTML = ` -
hello world
+
hello world
`;