From cef3a44f5ba065bb5cef2e559fdb92592b1de7ce Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 22 Jun 2023 14:16:11 -0400 Subject: [PATCH] Fix test on windows --- packages/astro/src/core/render/dev/vite.ts | 2 +- packages/astro/test/units/dev/styles.test.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/core/render/dev/vite.ts b/packages/astro/src/core/render/dev/vite.ts index f358e667e502..5cfea6e49fd9 100644 --- a/packages/astro/src/core/render/dev/vite.ts +++ b/packages/astro/src/core/render/dev/vite.ts @@ -104,7 +104,7 @@ export async function* crawlGraph( // Virtual modules URL should start with /@id/ but do not function urlId(url: string) { - if(url[0] !== '/') { + if (url.startsWith('astro:scripts')) { return '/@id/' + url; } return url; diff --git a/packages/astro/test/units/dev/styles.test.js b/packages/astro/test/units/dev/styles.test.js index 68bf07a23bab..44dbc3be5fde 100644 --- a/packages/astro/test/units/dev/styles.test.js +++ b/packages/astro/test/units/dev/styles.test.js @@ -4,6 +4,7 @@ import { fileURLToPath } from 'url'; import { getStylesForURL } from '../../../dist/core/render/dev/css.js'; +import { viteID } from '../../../dist/core/util.js'; const root = new URL('../../fixtures/alias/', import.meta.url); @@ -22,8 +23,8 @@ class TestLoader { describe('Crawling graph for CSS', () => { let loader; before(() => { - const indexId = fileURLToPath(new URL('./src/pages/index.astro', root)); - const aboutId = fileURLToPath(new URL('./src/pages/about.astro', root)); + const indexId = viteID(new URL('./src/pages/index.astro', root)); + const aboutId = viteID(new URL('./src/pages/about.astro', root)); loader = new TestLoader([ { id: indexId,