Skip to content

Commit

Permalink
Merge branch 'main' into remove-static-slots
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored May 17, 2023
2 parents 4b95be0 + 763ff2d commit ef1d4da
Show file tree
Hide file tree
Showing 180 changed files with 2,943 additions and 985 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-goats-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix image services not being usable on Edge runtimes
5 changes: 5 additions & 0 deletions .changeset/long-starfishes-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix middleware for API endpoints that use `Response`, and log a warning for endpoints that don't use `Response`.
39 changes: 39 additions & 0 deletions .changeset/mighty-shoes-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
'astro': minor
'@astrojs/cloudflare': patch
'@astrojs/netlify': patch
'@astrojs/vercel': patch
'@astrojs/image': patch
'@astrojs/deno': patch
'@astrojs/node': patch
---

Enable experimental support for hybrid SSR with pre-rendering enabled by default

__astro.config.mjs__
```js
import { defineConfig } from 'astro/config';
export defaultdefineConfig({
output: 'hybrid',
experimental: {
hybridOutput: true,
},
})
```
Then add `export const prerender = false` to any page or endpoint you want to opt-out of pre-rendering.

__src/pages/contact.astro__
```astro
---
export const prerender = false
if (Astro.request.method === 'POST') {
// handle form submission
}
---
<form method="POST">
<input type="text" name="name" />
<input type="email" name="email" />
<button type="submit">Submit</button>
</form>
```
5 changes: 5 additions & 0 deletions .changeset/pretty-planets-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': minor
---

Add `edge-light` and `worker` import condition for worker bundling
6 changes: 6 additions & 0 deletions .changeset/pretty-students-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@astrojs/markdoc': minor
'astro': patch
---

Generate heading `id`s and populate the `headings` property for all Markdoc files
5 changes: 5 additions & 0 deletions .changeset/quiet-gifts-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---

Add missing esbuild dependency
5 changes: 5 additions & 0 deletions .changeset/rich-crews-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': minor
---

Add `worked` and `worker` import condition for worker bundling
7 changes: 7 additions & 0 deletions .changeset/silver-ties-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astrojs/cloudflare': patch
'@astrojs/vercel': patch
'@astrojs/solid-js': patch
---

Always build edge/worker runtime with Vite `webworker` SSR target
51 changes: 51 additions & 0 deletions .changeset/tall-eyes-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
'astro': minor
---

Integrations can add new `client:` directives through the `astro:config:setup` hook's `addClientDirective()` API. To enable this API, the user needs to set `experimental.customClientDirectives` to `true` in their config.

```js
import { defineConfig } from 'astro/config';
import onClickDirective from 'astro-click-directive';

export default defineConfig({
integrations: [onClickDirective()],
experimental: {
customClientDirectives: true
}
});
```

```js
export default function onClickDirective() {
return {
hooks: {
'astro:config:setup': ({ addClientDirective }) => {
addClientDirective({
name: 'click',
entrypoint: 'astro-click-directive/click.js'
});
},
}
}
}
```

```astro
<Counter client:click />
```

The client directive file (e.g. `astro-click-directive/click.js`) should export a function of type `ClientDirective`:

```ts
import type { ClientDirective } from 'astro'

const clickDirective: ClientDirective = (load, opts, el) => {
window.addEventListener('click', async () => {
const hydrate = await load()
await hydrate()
}, { once: true })
}

export default clickDirective
```
17 changes: 17 additions & 0 deletions .changeset/tiny-snails-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'astro': minor
---

Adds an opt-in way to minify the HTML output.

Using the `compressHTML` option Astro will remove whitespace from Astro components. This only applies to components written in `.astro` format and happens in the compiler to maximize performance. You can enable with:

```js
import { defineConfig } from 'astro/config';

export default defineConfig({
compressHTML: true
});
```

Compression occurs both in development mode and in the final build.
26 changes: 26 additions & 0 deletions .changeset/young-impalas-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@astrojs/cloudflare': patch
'@astrojs/turbolinks': patch
'@astrojs/partytown': patch
'@astrojs/alpinejs': patch
'@astrojs/prefetch': patch
'@astrojs/tailwind': patch
'@astrojs/markdoc': patch
'@astrojs/netlify': patch
'@astrojs/preact': patch
'@astrojs/svelte': patch
'@astrojs/vercel': patch
'@astrojs/react': patch
'@astrojs/solid-js': patch
'@astrojs/markdown-component': patch
'@astrojs/deno': patch
'@astrojs/node': patch
'@astrojs/lit': patch
'@astrojs/mdx': patch
'@astrojs/vue': patch
'@astrojs/markdown-remark': patch
'@astrojs/prism': patch
'@astrojs/rss': patch
---

Specify `"files"` field to only publish necessary files
14 changes: 10 additions & 4 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ name: "Nightly"

on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: "0 12 * * *"
# Run every Monday at 12:00 UTC
- cron: "0 12 * * 1"
workflow_dispatch:

jobs:
stat:
if: github.repository_owner == 'withastro'
# Temporarily disable since stat collection hasn't work for a while
if: false
runs-on: ubuntu-latest
steps:
- name: Check out code using Git
Expand Down Expand Up @@ -59,17 +60,22 @@ jobs:
- name: Delete the existing pnpm-lock.yaml file
run: rm pnpm-lock.yaml

# https://github.com/pnpm/pnpm/issues/6463
- name: Update .npmrc to update packages to latest
run: echo "resolution-mode=highest" >> .npmrc

- name: Create a fresh pnpm lockfile (no install)
run: pnpm install --lockfile-only

- name: Create Pull Request
id: createpr
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
branch: ci/lockfile
# Access token is needed to trigger CI on this PR
token: ${{ secrets.FREDKBOT_GITHUB_TOKEN }}
commit-message: "[ci] update lockfile"
add-paths: pnpm-lock.yaml
title: "[ci] update lockfile"
body: >
This PR is auto-generated by a nightly GitHub action.
Expand Down
1 change: 1 addition & 0 deletions examples/basics/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { title } = Astro.props;
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="description" content="Astro description">
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
Expand Down
4 changes: 4 additions & 0 deletions packages/astro-prism/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"./Prism.astro": "./Prism.astro",
"./dist/highlighter": "./dist/highlighter.js"
},
"files": [
"dist",
"Prism.astro"
],
"keywords": [
"astro",
"astro-component"
Expand Down
3 changes: 3 additions & 0 deletions packages/astro-rss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
".": "./dist/index.js",
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
Expand Down
6 changes: 5 additions & 1 deletion packages/astro/astro-jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ declare namespace astroHTML.JSX {
children: {};
}

interface IntrinsicAttributes extends AstroBuiltinProps, AstroBuiltinAttributes {
interface IntrinsicAttributes
extends AstroBuiltinProps,
AstroBuiltinAttributes,
AstroClientDirectives {
slot?: string;
children?: Children;
}

type AstroBuiltinProps = import('./dist/@types/astro.js').AstroBuiltinProps;
type AstroClientDirectives = import('./dist/@types/astro.js').AstroClientDirectives;
type AstroBuiltinAttributes = import('./dist/@types/astro.js').AstroBuiltinAttributes;
type AstroDefineVarsAttribute = import('./dist/@types/astro.js').AstroDefineVarsAttribute;
type AstroScriptAttributes = import('./dist/@types/astro.js').AstroScriptAttributes &
Expand Down
92 changes: 92 additions & 0 deletions packages/astro/e2e/custom-client-directives.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { expect } from '@playwright/test';
import { testFactory, waitForHydrate } from './test-utils.js';
import testAdapter from '../test/test-adapter.js';

const test = testFactory({
root: './fixtures/custom-client-directives/',
});

test.describe('Custom Client Directives - dev', () => {
let devServer;

test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});

test.afterAll(async () => {
await devServer.stop();
});

testClientDirectivesShared();
});

test.describe('Custom Client Directives - build static', () => {
let previewServer;

test.beforeAll(async ({ astro }) => {
await astro.build();
previewServer = await astro.preview();
});

test.afterAll(async () => {
await previewServer.stop();
});

testClientDirectivesShared();
});

test.describe('Custom Client Directives - build server', () => {
let previewServer;

test.beforeAll(async ({ astro }) => {
await astro.build({
adapter: testAdapter(),
});
previewServer = await astro.preview();
});

test.afterAll(async () => {
await previewServer.stop();
});

testClientDirectivesShared();
});

function testClientDirectivesShared() {
test('client:click should work', async ({ astro, page }) => {
await page.goto(astro.resolveUrl('/'));

const incrementBtn = page.locator('#client-click .increment');
const counterValue = page.locator('#client-click pre');

await expect(counterValue).toHaveText('0');

// Component only hydrates on first click
await Promise.all([waitForHydrate(page, counterValue), incrementBtn.click()]);

// Since first click only triggers hydration, this should stay 0
await expect(counterValue).toHaveText('0');
await incrementBtn.click();
// Hydrated, this should be 1
await expect(counterValue).toHaveText('1');
});

test('client:password should work', async ({ astro, page }) => {
await page.goto(astro.resolveUrl('/'));

const incrementBtn = page.locator('#client-password .increment');
const counterValue = page.locator('#client-password pre');

await expect(counterValue).toHaveText('0');
await incrementBtn.click();
// Not hydrated, so this should stay 0
await expect(counterValue).toHaveText('0');

// Type super cool password to activate password!
await Promise.all([waitForHydrate(page, counterValue), page.keyboard.type('hunter2')]);

await incrementBtn.click();
// Hydrated, this should be 1
await expect(counterValue).toHaveText('1');
});
}
Loading

0 comments on commit ef1d4da

Please sign in to comment.