Skip to content

Commit

Permalink
Merge branch 'main' into chore/prettier-v3
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re authored Sep 5, 2023
2 parents 4fe62d5 + 923a443 commit f03273e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/twelve-cars-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix markdown page HMR
5 changes: 2 additions & 3 deletions packages/astro/src/vite-plugin-markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
}

const code = escapeViteEnvReferences(`
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent } from ${JSON.stringify(
import { unescapeHTML, spreadAttributes, createComponent, render, renderComponent, maybeRenderHead } from ${JSON.stringify(
astroServerRuntimeModulePath
)};
import { AstroError, AstroErrorData } from ${JSON.stringify(astroErrorModulePath)};
Expand Down Expand Up @@ -180,10 +180,9 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
}, {
'default': () => render\`\${unescapeHTML(html)}\`
})}\`;`
: `render\`\${unescapeHTML(html)}\`;`
: `render\`\${maybeRenderHead(result)}\${unescapeHTML(html)}\`;`
}
});
Content[Symbol.for('astro.needsHeadRendering')] = ${layout ? 'false' : 'true'};
export default Content;
`);

Expand Down
5 changes: 5 additions & 0 deletions packages/astro/test/astro-pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ describe('Pages', () => {

expect($('#testing').length).to.be.greaterThan(0);
});

it('should have Vite client in dev', async () => {
const html = await fixture.fetch('/').then((res) => res.text());
expect(html).to.include('/@vite/client', 'Markdown page does not have Vite client for HMR');
});
});
});
8 changes: 6 additions & 2 deletions packages/integrations/cloudflare/test/basics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ describe('Basic app', () => {
/** @type {import('./test-utils').WranglerCLI} */
let cli;

before(async () => {
before(async function () {
fixture = await loadFixture({
root: './fixtures/basics/',
});
await fixture.build();

cli = await runCLI('./fixtures/basics/', { silent: true, port: 8789 });
await cli.ready;
await cli.ready.catch((e) => {
console.log(e);
// if fail to start, skip for now as it's very flaky
this.skip();
});
});

after(async () => {
Expand Down
12 changes: 8 additions & 4 deletions packages/integrations/cloudflare/test/cf.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ describe('Cf metadata and caches', () => {
/** @type {import('./test-utils').WranglerCLI} */
let cli;

before(async () => {
before(async function () {
fixture = await loadFixture({
root: './fixtures/cf/',
output: 'server',
adapter: cloudflare(),
});
await fixture.build();

cli = await runCLI('./fixtures/cf/', { silent: false, port: 8788 });
await cli.ready;
cli = await runCLI('./fixtures/cf/', { silent: true, port: 8786 });
await cli.ready.catch((e) => {
console.log(e);
// if fail to start, skip for now as it's very flaky
this.skip();
});
});

after(async () => {
await cli.stop();
});

it('Load cf and caches API', async () => {
let res = await fetch(`http://127.0.0.1:8788/`);
let res = await fetch(`http://127.0.0.1:8786/`);
expect(res.status).to.equal(200);
let html = await res.text();
let $ = cheerio.load(html);
Expand Down
8 changes: 6 additions & 2 deletions packages/integrations/cloudflare/test/runtime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Runtime Locals', () => {
/** @type {import('./test-utils.js').WranglerCLI} */
let cli;

before(async () => {
before(async function () {
fixture = await loadFixture({
root: './fixtures/runtime/',
output: 'server',
Expand All @@ -18,7 +18,11 @@ describe('Runtime Locals', () => {
await fixture.build();

cli = await runCLI('./fixtures/runtime/', { silent: true, port: 8793 });
await cli.ready;
await cli.ready.catch((e) => {
console.log(e);
// if fail to start, skip for now as it's very flaky
this.skip();
});
});

after(async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/integrations/cloudflare/test/with-solid-js.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ describe('With SolidJS', () => {
/** @type {import('./test-utils').WranglerCLI} */
let cli;

before(async () => {
before(async function () {
fixture = await loadFixture({
root: './fixtures/with-solid-js/',
});
await fixture.build();

cli = await runCLI('./fixtures/with-solid-js/', { silent: true, port: 8790 });
await cli.ready;
await cli.ready.catch((e) => {
console.log(e);
// if fail to start, skip for now as it's very flaky
this.skip();
});
});

after(async () => {
Expand Down

0 comments on commit f03273e

Please sign in to comment.