Merge branch 'main' into test/e2e-hydration

This commit is contained in:
Tony Sullivan 2022-05-17 11:01:32 -05:00
commit 254cf94bec
64 changed files with 892 additions and 632 deletions

View file

@ -1,5 +0,0 @@
---
'@astrojs/netlify': minor
---
Updating out directories for Netlify Functions

View file

@ -1,5 +0,0 @@
---
'@astrojs/netlify': minor
---
Change out directories on dist and serverEntry

View file

@ -1,5 +0,0 @@
---
'@astrojs/lit': patch
---
Added tests and fix a small edge case for when you call render with no props/attrs

View file

@ -1,5 +0,0 @@
---
'@astrojs/partytown': patch
---
Add config options for integration

View file

@ -1,5 +0,0 @@
---
'@astrojs/vercel': patch
---
Remove `nodeVersion` option for `serverless` target. Now it is inferred from Vercel

View file

@ -1,5 +0,0 @@
---
'@astrojs/turbolinks': patch
---
The @astrojs/turbolinks integration has been deprecated

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Fixes issue with loading md pages in project with a space in folder name

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Allow using aliases for hydrated scripts

View file

@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.1.2",
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"sass": "^1.51.0"
},
"dependencies": {

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.1.2",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"preact": "^10.7.2"

View file

@ -10,6 +10,6 @@
},
"devDependencies": {
"@example/my-component": "workspace:*",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -8,6 +8,6 @@
"serve": "astro --root demo preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -20,6 +20,6 @@
"devDependencies": {
"@astrojs/preact": "^0.1.2",
"@astrojs/react": "^0.1.2",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -9,7 +9,7 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"alpinejs": "^3.10.2"

View file

@ -9,8 +9,8 @@
"preview": "astro preview"
},
"devDependencies": {
"@astrojs/lit": "^0.1.2",
"astro": "^1.0.0-beta.28"
"@astrojs/lit": "^0.1.3",
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",

View file

@ -9,13 +9,13 @@
"preview": "astro preview"
},
"devDependencies": {
"@astrojs/lit": "^0.1.2",
"@astrojs/lit": "^0.1.3",
"@astrojs/preact": "^0.1.2",
"@astrojs/react": "^0.1.2",
"@astrojs/solid-js": "^0.1.2",
"@astrojs/svelte": "^0.1.3",
"@astrojs/vue": "^0.1.4",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"@webcomponents/template-shadowroot": "^0.1.0",

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.1.2",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"preact": "^10.7.2"

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/react": "^0.1.2",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"@types/react": "^18.0.9",

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/solid-js": "^0.1.2",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"solid-js": "^1.4.1"

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/svelte": "^0.1.3",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"svelte": "^3.48.0"

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/vue": "^0.1.4",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"vue": "^3.2.33"

View file

@ -9,14 +9,14 @@
"preview": "astro preview"
},
"devDependencies": {
"@astrojs/lit": "^0.1.2",
"@astrojs/partytown": "^0.1.2",
"@astrojs/lit": "^0.1.3",
"@astrojs/partytown": "^0.1.3",
"@astrojs/react": "^0.1.2",
"@astrojs/sitemap": "^0.1.0",
"@astrojs/solid-js": "0.1.2",
"@astrojs/tailwind": "^0.2.1",
"@astrojs/turbolinks": "^0.1.2",
"astro": "^1.0.0-beta.28",
"@astrojs/turbolinks": "^0.1.3",
"astro": "^1.0.0-beta.29",
"solid-js": "^1.4.1"
},
"dependencies": {

View file

@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/preact": "^0.1.2",
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"sass": "^1.51.0"
},
"dependencies": {

View file

@ -11,7 +11,7 @@
"devDependencies": {
"@astrojs/node": "^0.1.1",
"@astrojs/svelte": "^0.1.3",
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"concurrently": "^7.2.0",
"lightcookie": "^1.0.25",
"unocss": "^0.15.6",

View file

@ -9,6 +9,6 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/react": "^0.1.2",
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"sass": "^1.51.0"
},
"dependencies": {

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/markdown-remark": "^0.9.4",
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"hast-util-select": "5.0.1",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.0.1",

View file

@ -10,6 +10,6 @@
},
"devDependencies": {
"@astrojs/markdown-remark": "^0.9.4",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -14,7 +14,7 @@
"@astrojs/react": "^0.1.2",
"@astrojs/svelte": "^0.1.3",
"@astrojs/vue": "^0.1.4",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
},
"dependencies": {
"preact": "^10.7.2",

View file

@ -25,6 +25,6 @@
"@astrojs/solid-js": "^0.1.2",
"@astrojs/svelte": "^0.1.3",
"@astrojs/vue": "^0.1.4",
"astro": "^1.0.0-beta.28"
"astro": "^1.0.0-beta.29"
}
}

View file

@ -10,7 +10,7 @@
},
"devDependencies": {
"@astrojs/tailwind": "^0.2.1",
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"autoprefixer": "^10.4.7",
"canvas-confetti": "^1.5.1",
"postcss": "^8.4.13",

View file

@ -9,7 +9,7 @@
"preview": "astro preview"
},
"devDependencies": {
"astro": "^1.0.0-beta.28",
"astro": "^1.0.0-beta.29",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.3"
}

View file

@ -60,8 +60,8 @@
"@changesets/changelog-github": "0.4.4",
"@changesets/cli": "2.22.0",
"@octokit/action": "^3.18.1",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"@typescript-eslint/eslint-plugin": "^5.24.0",
"@typescript-eslint/parser": "^5.24.0",
"del": "^6.1.0",
"esbuild": "^0.14.39",
"eslint": "^8.15.0",

View file

@ -1,5 +1,15 @@
# astro
## 1.0.0-beta.29
### Patch Changes
- [#3388](https://github.com/withastro/astro/pull/3388) [`4d00473d`](https://github.com/withastro/astro/commit/4d00473dbd20e673b5c9857d500dee072bb20f99) Thanks [@matthewp](https://github.com/matthewp)! - Fixes nested style bug causing initial styles to be off
* [#3379](https://github.com/withastro/astro/pull/3379) [`0259d765`](https://github.com/withastro/astro/commit/0259d7658be82a4a5e09fb703498571d958a0569) Thanks [@matthewp](https://github.com/matthewp)! - Fixes issue with loading md pages in project with a space in folder name
- [#3376](https://github.com/withastro/astro/pull/3376) [`b1230152`](https://github.com/withastro/astro/commit/b1230152ff67ca9c184b24023651f4f8739097b8) Thanks [@matthewp](https://github.com/matthewp)! - Allow using aliases for hydrated scripts
## 1.0.0-beta.28
### Patch Changes

View file

@ -0,0 +1,8 @@
{
"name": "@test/nested-style-bug-e22e",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
}
}

View file

@ -0,0 +1,75 @@
---
export interface Props {
title: string,
body: string,
href: string,
}
const {href, title, body} = Astro.props;
---
<li class="link-card">
<a href={href}>
<h2>
{title}
<span>&rarr;</span>
</h2>
<p>
{body}
<slot name="icon" />
</p>
</a>
</li>
<style>
:root {
--link-gradient: linear-gradient(45deg, #4F39FA, #DA62C4 30%, var(--color-border) 60%);
}
.link-card {
list-style: none;
display: flex;
padding: 0.15rem;
background-image: var(--link-gradient);
background-size: 400%;
border-radius: 0.5rem;
background-position: 100%;
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.link-card > a {
width: 100%;
text-decoration: none;
line-height: 1.4;
padding: 1em 1.3em;
border-radius: 0.35rem;
color: var(--text-color);
background-color: white;
opacity: 0.8;
}
h2 {
margin: 0;
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
p {
margin-top: 0.75rem;
margin-bottom: 0;
}
h2 span {
display: inline-block;
transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.link-card:is(:hover, :focus-within) {
background-position: 0;
}
.link-card:is(:hover, :focus-within) h2 {
color: #4F39FA;
}
.link-card:is(:hover, :focus-within) h2 span {
transform: translateX(2px);
}
</style>

View file

@ -0,0 +1,24 @@
<style>
header {
display: flex;
position: relative;
align-items: center;
justify-content: space-between;
padding: 20px;
background: darkblue;
color: white;
}
.title {
display: block;
width: 180px;
}
</style>
<header>
<a class="title" href="/">
<span>My Website</span>
</a>
</header>

View file

@ -0,0 +1,18 @@
---
import Header from '../Header/index.astro'
import '../../../styles/global.css'
---
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no" />
</head>
<body>
<Header />
<main>
<slot />
</main>
</body>
</html>

View file

@ -0,0 +1,13 @@
---
import Layout from '../components/partials/Layout/index.astro';
const content = {
title: 'My Website'
}
---
<Layout content={content}>
<h1 class="title">My Website</h1>
<p>This is my website</p>
</Layout>

View file

@ -0,0 +1,19 @@
body {
font-family: sans-serif;
font-size: 16px;
font-weight: 300;
line-height: 1.12;
}
a {
color: inherit;
text-decoration: underline;
}
h1,
h2,
h3,
h4,
h5 {
font-weight: 700;
}

View file

@ -0,0 +1,32 @@
import { test as base, expect } from '@playwright/test';
import { loadFixture } from './test-utils.js';
const test = base.extend({
astro: async ({}, use) => {
const fixture = await loadFixture({ root: './fixtures/nested-styles/' });
await use(fixture);
},
});
let devServer;
test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
});
test.afterAll(async ({ astro }) => {
await devServer.stop();
});
test('Loading styles that are nested', async ({ page, astro }) => {
await page.goto(astro.resolveUrl('/'));
await test.step('header', async () => {
const header = page.locator('header');
await expect(header, 'should have background color').toHaveCSS(
'background-color',
'rgb(0, 0, 139)' // darkblue
);
});
});

View file

@ -1,6 +1,6 @@
{
"name": "astro",
"version": "1.0.0-beta.28",
"version": "1.0.0-beta.29",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
@ -83,10 +83,10 @@
"@astrojs/prism": "0.4.1",
"@astrojs/telemetry": "^0.1.2",
"@astrojs/webapi": "^0.11.1",
"@babel/core": "^7.17.10",
"@babel/generator": "^7.17.10",
"@babel/parser": "^7.17.10",
"@babel/traverse": "^7.17.10",
"@babel/core": "^7.17.12",
"@babel/generator": "^7.17.12",
"@babel/parser": "^7.17.12",
"@babel/traverse": "^7.17.12",
"@proload/core": "^0.3.2",
"@proload/plugin-tsm": "^0.2.1",
"ast-types": "^0.14.2",
@ -136,8 +136,8 @@
"zod": "^3.16.0"
},
"devDependencies": {
"@babel/types": "^7.17.10",
"@playwright/test": "^1.22.0",
"@babel/types": "^7.17.12",
"@playwright/test": "^1.22.1",
"@types/babel__core": "^7.1.19",
"@types/babel__generator": "^7.6.4",
"@types/babel__traverse": "^7.17.1",

View file

@ -23,6 +23,7 @@ export interface DevOptions {
export interface DevServer {
address: AddressInfo;
watcher: vite.FSWatcher;
stop(): Promise<void>;
}
@ -69,6 +70,9 @@ export default async function dev(config: AstroConfig, options: DevOptions): Pro
return {
address: devServerAddressInfo,
get watcher() {
return viteServer.watcher;
},
stop: async () => {
await viteServer.close();
await runHookServerDone({ config });

View file

@ -316,7 +316,6 @@ async function handleRequest(
return await writeSSRResult(result, res, statusCode);
}
} catch (_err) {
debugger;
const err = fixViteErrorMessage(createSafeError(_err), viteServer);
error(logging, null, msg.formatErrorMessage(err));
handle500Response(viteServer, origin, req, res, err);

View file

@ -198,16 +198,9 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
i++;
}
// We only need to define deps if there are any
if (deps.size > 1) {
SUFFIX += `\nif(import.meta.hot) import.meta.hot.accept(["${id}", "${Array.from(
deps
).join('","')}"], (...mods) => mods);`;
} else {
SUFFIX += `\nif (import.meta.hot) {
import.meta.hot.accept(mod => mod);
}`;
}
SUFFIX += `\nif (import.meta.hot) {
import.meta.hot.accept(mod => mod);
}`;
}
// Add handling to inject scripts into each page JS bundle, if needed.
if (isPage) {

View file

@ -1,5 +1,6 @@
import { isWindows, loadFixture } from './test-utils.js';
import { expect } from 'chai';
import * as cheerio from 'cheerio';
describe('Error display', () => {
if (isWindows) return;
@ -30,4 +31,34 @@ describe('Error display', () => {
expect(res.status).to.equal(500, `Successfully responded with 500 Error for invalid file`);
});
});
describe('Framework components', () => {
let devServer;
before(async () => {
devServer = await fixture.startDevServer();
});
after(async () => {
await devServer.stop();
});
it('Errors recover when fixed', async () => {
let html = await fixture.fetch('/svelte-syntax-error').then((res) => res.text());
// 1. Verify an error message is being shown.
let $ = cheerio.load(html);
expect($('.statusMessage').text()).to.equal('Internal Error');
// 2. Edit the file, fixing the error
let changeOccured = fixture.onNextChange();
await fixture.editFile('./src/components/SvelteSyntaxError.svelte', `<h1>No mismatch</h1>`);
await changeOccured;
// 3. Verify that the file is fixed.
html = await fixture.fetch('/svelte-syntax-error').then((res) => res.text());
$ = cheerio.load(html);
expect($('h1').text()).to.equal('No mismatch');
});
});
});

View file

@ -108,13 +108,32 @@ export async function loadFixture(inlineConfig) {
cleanupCallbacks.push(() => fs.promises.writeFile(pathname, initial, 'utf-8'));
}
// A map of files that have been editted.
let fileEdits = new Map();
const resetAllFiles = () => {
for (const [, reset] of fileEdits) {
reset();
}
fileEdits.clear();
};
// After each test, reset each of the edits to their original contents.
if (typeof afterEach === 'function') {
afterEach(resetAllFiles);
}
// Also do it on process exit, just in case.
process.on('exit', resetAllFiles);
let devServer;
return {
build: (opts = {}) => build(config, { mode: 'development', logging, telemetry, ...opts }),
startDevServer: async (opts = {}) => {
const devResult = await dev(config, { logging, telemetry, ...opts });
config.server.port = devResult.address.port; // update port
return devResult;
devServer = await dev(config, { logging, telemetry, ...opts });
config.server.port = devServer.address.port; // update port
return devServer;
},
config,
resolveUrl,
@ -136,6 +155,22 @@ export async function loadFixture(inlineConfig) {
const { createApp } = await import(url);
return createApp();
},
editFile: async (filePath, newContents) => {
const fileUrl = new URL(filePath.replace(/^\//, ''), config.root);
const contents = await fs.promises.readFile(fileUrl, 'utf-8');
const reset = () => fs.writeFileSync(fileUrl, contents);
// Only save this reset if not already in the map, in case multiple edits happen
// to the same file.
if (!fileEdits.has(fileUrl.toString())) {
fileEdits.set(fileUrl.toString(), reset);
}
await fs.promises.writeFile(fileUrl, newContents);
return reset;
},
onNextChange: () =>
devServer
? new Promise((resolve) => devServer.watcher.once('change', resolve))
: Promise.reject(new Error('No dev server running')),
};
}

View file

@ -1,5 +1,11 @@
# @astrojs/lit
## 0.1.3
### Patch Changes
- [#3375](https://github.com/withastro/astro/pull/3375) [`fe61e469`](https://github.com/withastro/astro/commit/fe61e469b243c27781112499f151782baf9004a4) Thanks [@jdvivar](https://github.com/jdvivar)! - Added tests and fix a small edge case for when you call render with no props/attrs
## 0.1.2
### Patch Changes

View file

@ -1,6 +1,6 @@
{
"name": "@astrojs/lit",
"version": "0.1.2",
"version": "0.1.3",
"description": "Use Lit components within Astro",
"type": "module",
"types": "./dist/index.d.ts",

View file

@ -1,5 +1,13 @@
# @astrojs/netlify
## 0.4.0
### Minor Changes
- [#3381](https://github.com/withastro/astro/pull/3381) [`43d92227`](https://github.com/withastro/astro/commit/43d922277afaeca9c90364fbf0b19477fd2c6566) Thanks [@sarahetter](https://github.com/sarahetter)! - Updating out directories for Netlify Functions
* [#3377](https://github.com/withastro/astro/pull/3377) [`e1294c42`](https://github.com/withastro/astro/commit/e1294c422b3d3e98ccc745fe95d5672c9a17fe1f) Thanks [@sarahetter](https://github.com/sarahetter)! - Change out directories on dist and serverEntry
## 0.3.4
### Patch Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/netlify",
"description": "Deploy your site to Netlify",
"version": "0.3.4",
"version": "0.4.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -1,5 +1,11 @@
# @astrojs/partytown
## 0.1.3
### Patch Changes
- [#3380](https://github.com/withastro/astro/pull/3380) [`31b0bc87`](https://github.com/withastro/astro/commit/31b0bc87a4f6f652d9007810026e99756a32cc46) Thanks [@rotate-mark](https://github.com/rotate-mark)! - Add config options for integration
## 0.1.2
### Patch Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/partytown",
"description": "Astro + Partytown integration",
"version": "0.1.2",
"version": "0.1.3",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -30,7 +30,7 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.17.3",
"@babel/plugin-transform-react-jsx": "^7.17.12",
"preact-render-to-string": "^5.2.0"
},
"devDependencies": {

View file

@ -33,7 +33,7 @@
"dev": "astro-scripts dev \"src/**/*.ts\""
},
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.17.3"
"@babel/plugin-transform-react-jsx": "^7.17.12"
},
"devDependencies": {
"@types/react": "^17.0.45",

View file

@ -1,5 +1,11 @@
# @astrojs/turbolinks
## 0.1.3
### Patch Changes
- [#3383](https://github.com/withastro/astro/pull/3383) [`387ed0cf`](https://github.com/withastro/astro/commit/387ed0cfa1ed73e0025dd81f221ea7c95d724a59) Thanks [@tony-sull](https://github.com/tony-sull)! - The @astrojs/turbolinks integration has been deprecated
## 0.1.2
### Patch Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/turbolinks",
"description": "Turbolinks + Astro Integrations",
"version": "0.1.2",
"version": "0.1.3",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -1,5 +1,11 @@
# @astrojs/vercel
## 0.2.2
### Patch Changes
- [#3368](https://github.com/withastro/astro/pull/3368) [`9d01f93b`](https://github.com/withastro/astro/commit/9d01f93b1c7db5d4afc4041e6ee73fb52f24d2d1) Thanks [@JuanM04](https://github.com/JuanM04)! - Remove `nodeVersion` option for `serverless` target. Now it is inferred from Vercel
## 0.2.1
### Patch Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/vercel",
"description": "Deploy your site to Vercel",
"version": "0.2.1",
"version": "0.2.2",
"type": "module",
"author": "withastro",
"license": "MIT",

File diff suppressed because it is too large Load diff