Skip to content

Commit

Permalink
Merge branch 'plt-223-custom-client-directives' of https://github.com…
Browse files Browse the repository at this point in the history
…/withastro/astro into plt-223-custom-client-directives
  • Loading branch information
bluwy committed May 17, 2023
2 parents 8769d3c + eebad63 commit f2644e9
Show file tree
Hide file tree
Showing 55 changed files with 693 additions and 641 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/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
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
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
23 changes: 20 additions & 3 deletions packages/astro/e2e/lit-component.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test';
import { testFactory } from './test-utils.js';
import { testFactory, waitForHydrate } from './test-utils.js';

const test = testFactory({
root: './fixtures/lit-component/',
Expand Down Expand Up @@ -30,6 +30,8 @@ test.describe('Lit components', () => {
const count = counter.locator('p');
await expect(count, 'initial count is 10').toHaveText('Count: 10');

await waitForHydrate(page, counter);

const inc = counter.locator('button');
await inc.click();

Expand All @@ -43,6 +45,8 @@ test.describe('Lit components', () => {
const count = counter.locator('p');
await expect(count, 'initial count is 10').toHaveText('Count: 10');

await waitForHydrate(page, counter);

const inc = counter.locator('button');
await inc.click();

Expand All @@ -58,6 +62,8 @@ test.describe('Lit components', () => {
const count = counter.locator('p');
await expect(count, 'initial count is 10').toHaveText('Count: 10');

await waitForHydrate(page, counter);

const inc = counter.locator('button');
await inc.click();

Expand All @@ -75,6 +81,8 @@ test.describe('Lit components', () => {
const count = counter.locator('p');
await expect(count, 'initial count is 10').toHaveText('Count: 10');

await waitForHydrate(page, counter);

const inc = counter.locator('button');
await inc.click();

Expand All @@ -97,12 +105,13 @@ test.describe('Lit components', () => {

// Reset the viewport to hydrate the component (max-width: 50rem)
await page.setViewportSize({ width: 414, height: 1124 });
await waitForHydrate(page, counter);

await inc.click();
await expect(count, 'count incremented by 1').toHaveText('Count: 11');
});

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

const label = page.locator('#client-only');
Expand Down Expand Up @@ -157,7 +166,15 @@ test.describe('Lit components', () => {
// Playwright's Node version doesn't have these functions, so stub them.
process.stdout.clearLine = () => {};
process.stdout.cursorTo = () => {};
await astro.build();
try {
await astro.build();
} catch (err) {
// There's this strange error on build since the dev server already defined `my-counter`,
// however the tests still pass with this error, so swallow it.
if (!err.message.includes(`Failed to execute 'define' on 'CustomElementRegistry'`)) {
throw err;
}
}
});

t.beforeAll(async ({ astro }) => {
Expand Down
42 changes: 25 additions & 17 deletions packages/astro/e2e/namespaced-component.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test';
import { testFactory } from './test-utils.js';
import { testFactory, waitForHydrate } from './test-utils.js';

const test = testFactory({
root: './fixtures/namespaced-component/',
Expand All @@ -20,31 +20,35 @@ test.describe('Hydrating namespaced components', () => {
await page.goto('/');

// Counter declared with: <ns.components.PreactCounter id="preact-counter-namespace" client:load>
const namespacedCounter = await page.locator('#preact-counter-namespace');
const namespacedCounter = page.locator('#preact-counter-namespace');
await expect(namespacedCounter, 'component is visible').toBeVisible();

const namespacedCount = await namespacedCounter.locator('pre');
const namespacedCount = namespacedCounter.locator('pre');
await expect(namespacedCount, 'initial count is 0').toHaveText('0');

const namespacedChildren = await namespacedCounter.locator('.children');
const namespacedChildren = namespacedCounter.locator('.children');
await expect(namespacedChildren, 'children exist').toHaveText('preact (namespace import)');

const namespacedIncrement = await namespacedCounter.locator('.increment');
await waitForHydrate(page, namespacedCounter);

const namespacedIncrement = namespacedCounter.locator('.increment');
await namespacedIncrement.click();

await expect(namespacedCount, 'count incremented by 1').toHaveText('1');

// Counter declared with: <components.PreactCounterTwo id="preact-counter-named" client:load>
const namedCounter = await page.locator('#preact-counter-named');
const namedCounter = page.locator('#preact-counter-named');
await expect(namedCounter, 'component is visible').toBeVisible();

const namedCount = await namedCounter.locator('pre');
const namedCount = namedCounter.locator('pre');
await expect(namedCount, 'initial count is 0').toHaveText('0');

const namedChildren = await namedCounter.locator('.children');
const namedChildren = namedCounter.locator('.children');
await expect(namedChildren, 'children exist').toHaveText('preact (named import)');

const namedIncrement = await namedCounter.locator('.increment');
await waitForHydrate(page, namedCounter);

const namedIncrement = namedCounter.locator('.increment');
await namedIncrement.click();

await expect(namedCount, 'count incremented by 1').toHaveText('1');
Expand All @@ -54,31 +58,35 @@ test.describe('Hydrating namespaced components', () => {
await page.goto('/mdx');

// Counter declared with: <ns.components.PreactCounter id="preact-counter-namespace" client:load>
const namespacedCounter = await page.locator('#preact-counter-namespace');
const namespacedCounter = page.locator('#preact-counter-namespace');
await expect(namespacedCounter, 'component is visible').toBeVisible();

const namespacedCount = await namespacedCounter.locator('pre');
const namespacedCount = namespacedCounter.locator('pre');
await expect(namespacedCount, 'initial count is 0').toHaveText('0');

const namespacedChildren = await namespacedCounter.locator('.children');
const namespacedChildren = namespacedCounter.locator('.children');
await expect(namespacedChildren, 'children exist').toHaveText('preact (namespace import)');

const namespacedIncrement = await namespacedCounter.locator('.increment');
await waitForHydrate(page, namespacedCounter);

const namespacedIncrement = namespacedCounter.locator('.increment');
await namespacedIncrement.click();

await expect(namespacedCount, 'count incremented by 1').toHaveText('1');

// Counter declared with: <components.PreactCounterTwo id="preact-counter-named" client:load>
const namedCounter = await page.locator('#preact-counter-named');
const namedCounter = page.locator('#preact-counter-named');
await expect(namedCounter, 'component is visible').toBeVisible();

const namedCount = await namedCounter.locator('pre');
const namedCount = namedCounter.locator('pre');
await expect(namedCount, 'initial count is 0').toHaveText('0');

const namedChildren = await namedCounter.locator('.children');
const namedChildren = namedCounter.locator('.children');
await expect(namedChildren, 'children exist').toHaveText('preact (named import)');

const namedIncrement = await namedCounter.locator('.increment');
await waitForHydrate(page, namedCounter);

const namedIncrement = namedCounter.locator('.increment');
await namedIncrement.click();

await expect(namedCount, 'count incremented by 1').toHaveText('1');
Expand Down
42 changes: 26 additions & 16 deletions packages/astro/e2e/nested-in-preact.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test';
import { testFactory } from './test-utils.js';
import { testFactory, waitForHydrate } from './test-utils.js';

const test = testFactory({ root: './fixtures/nested-in-preact/' });

Expand All @@ -17,13 +17,15 @@ test.describe('Nested Frameworks in Preact', () => {
test('React counter', async ({ astro, page }) => {
await page.goto('/');

const counter = await page.locator('#react-counter');
const counter = page.locator('#react-counter');
await expect(counter, 'component is visible').toBeVisible();

const count = await counter.locator('#react-counter-count');
const count = counter.locator('#react-counter-count');
await expect(count, 'initial count is 0').toHaveText('0');

const increment = await counter.locator('#react-counter-increment');
await waitForHydrate(page, counter);

const increment = counter.locator('#react-counter-increment');
await increment.click();

await expect(count, 'count incremented by 1').toHaveText('1');
Expand All @@ -32,13 +34,15 @@ test.describe('Nested Frameworks in Preact', () => {
test('Preact counter', async ({ astro, page }) => {
await page.goto('/');

const counter = await page.locator('#preact-counter');
const counter = page.locator('#preact-counter');
await expect(counter, 'component is visible').toBeVisible();

const count = await counter.locator('#preact-counter-count');
const count = counter.locator('#preact-counter-count');
await expect(count, 'initial count is 0').toHaveText('0');

const increment = await counter.locator('#preact-counter-increment');
await waitForHydrate(page, counter);

const increment = counter.locator('#preact-counter-increment');
await increment.click();

await expect(count, 'count incremented by 1').toHaveText('1');
Expand All @@ -47,13 +51,15 @@ test.describe('Nested Frameworks in Preact', () => {
test('Solid counter', async ({ astro, page }) => {
await page.goto('/');

const counter = await page.locator('#solid-counter');
const counter = page.locator('#solid-counter');
await expect(counter, 'component is visible').toBeVisible();

const count = await counter.locator('#solid-counter-count');
const count = counter.locator('#solid-counter-count');
await expect(count, 'initial count is 0').toHaveText('0');

const increment = await counter.locator('#solid-counter-increment');
await waitForHydrate(page, counter);

const increment = counter.locator('#solid-counter-increment');
await increment.click();

await expect(count, 'count incremented by 1').toHaveText('1');
Expand All @@ -62,13 +68,15 @@ test.describe('Nested Frameworks in Preact', () => {
test('Vue counter', async ({ astro, page }) => {
await page.goto('/');

const counter = await page.locator('#vue-counter');
const counter = page.locator('#vue-counter');
await expect(counter, 'component is visible').toBeVisible();

const count = await counter.locator('#vue-counter-count');
const count = counter.locator('#vue-counter-count');
await expect(count, 'initial count is 0').toHaveText('0');

const increment = await counter.locator('#vue-counter-increment');
await waitForHydrate(page, counter);

const increment = counter.locator('#vue-counter-increment');
await increment.click();

await expect(count, 'count incremented by 1').toHaveText('1');
Expand All @@ -77,13 +85,15 @@ test.describe('Nested Frameworks in Preact', () => {
test('Svelte counter', async ({ astro, page }) => {
await page.goto('/');

const counter = await page.locator('#svelte-counter');
const counter = page.locator('#svelte-counter');
await expect(counter, 'component is visible').toBeVisible();

const count = await counter.locator('#svelte-counter-count');
const count = counter.locator('#svelte-counter-count');
await expect(count, 'initial count is 0').toHaveText('0');

const increment = await counter.locator('#svelte-counter-increment');
await waitForHydrate(page, counter);

const increment = counter.locator('#svelte-counter-increment');
await increment.click();

await expect(count, 'count incremented by 1').toHaveText('1');
Expand Down
Loading

0 comments on commit f2644e9

Please sign in to comment.