diff --git a/.changeset/ten-emus-raise.md b/.changeset/ten-emus-raise.md new file mode 100644 index 000000000..c0bc48195 --- /dev/null +++ b/.changeset/ten-emus-raise.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix linked Astro library style HMR diff --git a/packages/astro/e2e/astro-component.test.js b/packages/astro/e2e/astro-component.test.js index 8ebbcd3a6..ac5531fbe 100644 --- a/packages/astro/e2e/astro-component.test.js +++ b/packages/astro/e2e/astro-component.test.js @@ -1,6 +1,5 @@ import { expect } from '@playwright/test'; -import os from 'os'; -import { testFactory } from './test-utils.js'; +import { getColor, testFactory } from './test-utils.js'; const test = testFactory({ root: './fixtures/astro-component/' }); @@ -79,4 +78,32 @@ test.describe('Astro component HMR', () => { await updatedLog; }); + + test('update linked dep Astro html', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + let h1 = page.locator('#astro-linked-lib'); + expect(await h1.textContent()).toBe('astro-linked-lib'); + await Promise.all([ + page.waitForLoadState('networkidle'), + await astro.editFile('../_deps/astro-linked-lib/Component.astro', (content) => + content.replace('>astro-linked-lib<', '>astro-linked-lib-update<') + ), + ]); + h1 = page.locator('#astro-linked-lib'); + expect(await h1.textContent()).toBe('astro-linked-lib-update'); + }); + + test('update linked dep Astro style', async ({ page, astro }) => { + await page.goto(astro.resolveUrl('/')); + let h1 = page.locator('#astro-linked-lib'); + expect(await getColor(h1)).toBe('rgb(255, 0, 0)'); + await Promise.all([ + page.waitForLoadState('networkidle'), + await astro.editFile('../_deps/astro-linked-lib/Component.astro', (content) => + content.replace('color: red', 'color: green') + ), + ]); + h1 = page.locator('#astro-linked-lib'); + expect(await getColor(h1)).toBe('rgb(0, 128, 0)'); + }); }); diff --git a/packages/astro/e2e/fixtures/_deps/astro-linked-lib/Component.astro b/packages/astro/e2e/fixtures/_deps/astro-linked-lib/Component.astro new file mode 100644 index 000000000..074ccbc9b --- /dev/null +++ b/packages/astro/e2e/fixtures/_deps/astro-linked-lib/Component.astro @@ -0,0 +1,9 @@ + + +