Merge branch 'main' into feat/squoosh-lib

This commit is contained in:
Tony Sullivan 2022-09-06 10:49:04 -05:00
commit c8158400ac
104 changed files with 1394 additions and 1300 deletions
.changeset
.github
examples
packages

View file

@ -0,0 +1,5 @@
---
'@astrojs/vue': patch
---
Mark vueperslides as a default noExternal

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Move ast-types as dev dependency

View file

@ -1,5 +0,0 @@
---
'@astrojs/image': minor
---
feat: throw if alt text is missing

View file

@ -0,0 +1,5 @@
---
'@astrojs/image': patch
---
Parallelize image transforms

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Correctly escape paths in file names

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Ensure SSR module is loaded before testing if it's CSS in dev

View file

@ -1,5 +0,0 @@
---
'astro': patch
---
Add docs link to "missing adapter" error msg

View file

@ -0,0 +1,5 @@
---
'@astrojs/alpinejs': patch
---
Update homepage link

View file

@ -1,5 +0,0 @@
---
'@astrojs/image': patch
---
Fixes a bug that broke support for local images with spaces in the filename

View file

@ -1,5 +0,0 @@
---
'@astrojs/mdx': patch
---
Fix: Add GFM and Smartypants to MDX by default

3
.github/CODEOWNERS vendored
View file

@ -1 +1,2 @@
* @snowpackjs/maintainers
README.md @withastro/maintainers-docs
packages/astro/src/@types/astro.ts @withastro/maintainers-docs

View file

@ -12,6 +12,9 @@
## Docs
<!-- Is this a visible change? You probably need to update docs! -->
<!-- Could this affect a users behavior? We probably need to update docs! -->
<!-- If docs will be needed or youre not sure, uncomment the next line: -->
<!-- /cc @withastro/maintainers-docs for feedback! -->
<!-- DON'T DELETE THIS SECTION! If no docs added, explain why.-->
<!-- https://github.com/withastro/docs -->
<!-- https://github.com/withastro/docs -->

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -10,8 +10,8 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"@astrojs/mdx": "^0.11.0",
"astro": "^1.1.5",
"@astrojs/mdx": "^0.11.1",
"@astrojs/rss": "^1.0.0",
"@astrojs/sitemap": "^1.0.0"
}

View file

@ -18,7 +18,7 @@ const {
} = Astro.props;
---
<html>
<html lang="en">
<head>
<BaseHead title={title} description={description} />
<style>

View file

@ -11,7 +11,7 @@ const posts = (await Astro.glob('./blog/*.{md,mdx}')).sort(
---
<!DOCTYPE html>
<html lang="en-us">
<html lang="en">
<head>
<BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
<style>
@ -51,7 +51,7 @@ const posts = (await Astro.glob('./blog/*.{md,mdx}')).sort(
))}
</ul>
</section>
<Footer />
</main>
<Footer />
</body>
</html>

View file

@ -6,7 +6,7 @@ import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
---
<!DOCTYPE html>
<html lang="en-us">
<html lang="en">
<head>
<BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
</head>

View file

@ -11,6 +11,6 @@
},
"devDependencies": {
"@example/my-component": "workspace:*",
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -8,6 +8,6 @@
"serve": "astro --root demo preview"
},
"dependencies": {
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"preact": "^10.7.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",

View file

@ -36,7 +36,7 @@ const LanguageSelect: FunctionComponent<{ lang: string }> = ({ lang }) => {
>
{Object.entries(KNOWN_LANGUAGES).map(([key, value]) => {
return (
<option value={value}>
<option value={value} key={value}>
<span>{key}</span>
</option>
);

View file

@ -1,2 +0,0 @@
DB_PASSWORD=foobar
PUBLIC_SOME_KEY=123

View file

@ -1,19 +0,0 @@
# build output
dist/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store

View file

@ -1,2 +0,0 @@
# Expose Astro dependencies for `pnpm` users
shamefully-hoist=true

View file

@ -1,6 +0,0 @@
{
"startCommand": "npm start",
"env": {
"ENABLE_CJS_IMPORTS": true
}
}

View file

@ -1,4 +0,0 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

View file

@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

View file

@ -1,9 +0,0 @@
# Astro Starter Kit: Environment Variables
```
npm init astro -- --template env-vars
```
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/env-vars)
This example showcases Astro's support for Environment Variables. Please see Vite's [Env Variables and Modes](https://vitejs.dev/guide/env-and-mode.html) guide for more information.

View file

@ -1,4 +0,0 @@
import { defineConfig } from 'astro/config';
// https://astro.build/config
export default defineConfig({});

View file

@ -1,15 +0,0 @@
{
"name": "@example/env-vars",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3"
}
}

View file

@ -1,13 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 36 36">
<path fill="#000" d="M22.25 4h-8.5a1 1 0 0 0-.96.73l-5.54 19.4a.5.5 0 0 0 .62.62l5.05-1.44a2 2 0 0 0 1.38-1.4l3.22-11.66a.5.5 0 0 1 .96 0l3.22 11.67a2 2 0 0 0 1.38 1.39l5.05 1.44a.5.5 0 0 0 .62-.62l-5.54-19.4a1 1 0 0 0-.96-.73Z"/>
<path fill="url(#gradient)" d="M18 28a7.63 7.63 0 0 1-5-2c-1.4 2.1-.35 4.35.6 5.55.14.17.41.07.47-.15.44-1.8 2.93-1.22 2.93.6 0 2.28.87 3.4 1.72 3.81.34.16.59-.2.49-.56-.31-1.05-.29-2.46 1.29-3.25 3-1.5 3.17-4.83 2.5-6-.67.67-2.6 2-5 2Z"/>
<defs>
<linearGradient id="gradient" x1="16" x2="16" y1="32" y2="24" gradientUnits="userSpaceOnUse">
<stop stop-color="#000"/>
<stop offset="1" stop-color="#000" stop-opacity="0"/>
</linearGradient>
</defs>
<style>
@media (prefers-color-scheme:dark){:root{filter:invert(100%)}}
</style>
</svg>

Before

(image error) Size: 873 B

View file

@ -1,11 +0,0 @@
{
"infiniteLoopProtection": true,
"hardReloadOnChange": false,
"view": "browser",
"template": "node",
"container": {
"port": 3000,
"startScript": "start",
"node": "14"
}
}

View file

@ -1,13 +0,0 @@
/// <reference types="astro/client" />
// Use this file to type your environment variables!
// See https://docs.astro.build/en/guides/environment-variables/#intellisense-for-typescript for more information
interface ImportMetaEnv {
readonly DB_PASSWORD: string;
readonly PUBLIC_SOME_KEY: string;
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

View file

@ -1,24 +0,0 @@
---
const { SSR, DB_PASSWORD, PUBLIC_SOME_KEY } = import.meta.env;
// DB_PASSWORD is available because we're running on the server
console.log({ SSR, DB_PASSWORD });
// PUBLIC_SOME_KEY is available everywhere
console.log({ SSR, PUBLIC_SOME_KEY });
---
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Hello, Environment Variables!</h1>
<script src="/src/scripts/client.ts">
</script>
</body>
</html>

View file

@ -1,9 +0,0 @@
(() => {
const { SSR, DB_PASSWORD, PUBLIC_SOME_KEY } = import.meta.env;
// DB_PASSWORD is NOT available because we're running on the client
console.log({ SSR, DB_PASSWORD });
// PUBLIC_SOME_KEY is available everywhere
console.log({ SSR, PUBLIC_SOME_KEY });
})();

View file

@ -1,3 +0,0 @@
{
"extends": "astro/tsconfigs/base"
}

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"alpinejs": "^3.10.2",
"@astrojs/alpinejs": "^0.1.1",
"@types/alpinejs": "^3.7.0"

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"lit": "^2.2.5",
"@astrojs/lit": "^1.0.0",
"@webcomponents/template-shadowroot": "^0.1.0"

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"preact": "^10.7.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"preact": "^10.7.3",
"@astrojs/preact": "^1.0.2"
}

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"@astrojs/react": "^1.1.0",

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"solid-js": "^1.4.3",
"@astrojs/solid-js": "^1.1.0"
}

View file

@ -12,6 +12,6 @@
"dependencies": {
"svelte": "^3.48.0",
"@astrojs/svelte": "^1.0.0",
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"vue": "^3.2.37",
"@astrojs/vue": "^1.0.0"
}

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -12,7 +12,7 @@
"dependencies": {
"preact": "^10.7.3",
"@astrojs/preact": "^1.0.2",
"astro": "^1.1.3",
"astro": "^1.1.5",
"sass": "^1.52.2"
}
}

View file

@ -12,7 +12,7 @@
},
"devDependencies": {},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"svelte": "^3.48.0",
"@astrojs/svelte": "^1.0.0",
"@astrojs/node": "^1.0.1",

View file

@ -14,7 +14,7 @@ const user = { name: 'test' }; // getUser?
const cart = await getCart(Astro.request);
---
<html>
<html lang="en">
<head>
<title>Cart | Online Store</title>
<style>

View file

@ -8,7 +8,7 @@ import '../styles/common.css';
const products = await getProducts(Astro.request);
---
<html>
<html lang="en">
<head>
<title>Online Store</title>
<style>

View file

@ -3,7 +3,7 @@ import Header from '../components/Header.astro';
import Container from '../components/Container.astro';
---
<html>
<html lang="en">
<head>
<title>Online Store</title>
<style>

View file

@ -1,19 +0,0 @@
# build output
dist/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store

View file

@ -1,2 +0,0 @@
# Expose Astro dependencies for `pnpm` users
shamefully-hoist=true

View file

@ -1,6 +0,0 @@
{
"startCommand": "npm start",
"env": {
"ENABLE_CJS_IMPORTS": true
}
}

View file

@ -1,47 +0,0 @@
# Astro Starter Kit: A site deployed to a subpath
```
npm init astro -- --template subpath
```
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/subpath?initialPath=/blog/)
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
## 🚀 Project Structure
Inside of your Astro project, you'll see the following folders and files:
```
/
├── public/
├── src/
│ └── components/
│ └── Time.jsx
│ └── pages/
│ └── index.astro
└── package.json
```
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
Any static assets, like images, can be placed in the `public/` directory.
## 🧞 Commands
All commands are run from the root of the project, from a terminal:
| Command | Action |
| :--------------------- | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:3000` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro --help` | Get help using the Astro CLI |
## 👀 Want to learn more?
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).

View file

@ -1,9 +0,0 @@
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
// https://astro.build/config
export default defineConfig({
integrations: [react()],
site: 'http://example.com',
base: '/blog',
});

View file

@ -1,18 +0,0 @@
{
"name": "@example/subpath",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"@astrojs/react": "^1.1.0"
}
}

View file

@ -1,13 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 36 36">
<path fill="#000" d="M22.25 4h-8.5a1 1 0 0 0-.96.73l-5.54 19.4a.5.5 0 0 0 .62.62l5.05-1.44a2 2 0 0 0 1.38-1.4l3.22-11.66a.5.5 0 0 1 .96 0l3.22 11.67a2 2 0 0 0 1.38 1.39l5.05 1.44a.5.5 0 0 0 .62-.62l-5.54-19.4a1 1 0 0 0-.96-.73Z"/>
<path fill="url(#gradient)" d="M18 28a7.63 7.63 0 0 1-5-2c-1.4 2.1-.35 4.35.6 5.55.14.17.41.07.47-.15.44-1.8 2.93-1.22 2.93.6 0 2.28.87 3.4 1.72 3.81.34.16.59-.2.49-.56-.31-1.05-.29-2.46 1.29-3.25 3-1.5 3.17-4.83 2.5-6-.67.67-2.6 2-5 2Z"/>
<defs>
<linearGradient id="gradient" x1="16" x2="16" y1="32" y2="24" gradientUnits="userSpaceOnUse">
<stop stop-color="#000"/>
<stop offset="1" stop-color="#000" stop-opacity="0"/>
</linearGradient>
</defs>
<style>
@media (prefers-color-scheme:dark){:root{filter:invert(100%)}}
</style>
</svg>

Before

(image error) Size: 873 B

Binary file not shown.

Before

(image error) Size: 76 KiB

View file

@ -1,11 +0,0 @@
{
"infiniteLoopProtection": true,
"hardReloadOnChange": false,
"view": "browser",
"template": "node",
"container": {
"port": 3000,
"startScript": "start",
"node": "14"
}
}

View file

@ -1,7 +0,0 @@
import React from 'react';
export default function () {
const date = new Date();
const format = new Intl.DateTimeFormat('en-US');
return <time>{format.format(date)}</time>;
}

View file

@ -1 +0,0 @@
/// <reference types="astro/client" />

View file

@ -1,34 +0,0 @@
---
import '../styles/main.css';
import Time from '../components/Time.jsx';
// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
---
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Welcome to Astro</title>
</head>
<body>
<h1>Welcome to <a href="https://astro.build/">Astro</a></h1>
<main id="app">
Today: <Time client:idle />
</main>
<article>
<h2>Animals</h2>
<figure>
<img src="/blog/images/penguin.png" />
<figcaption>A penguin</figcaption>
</figure>
</article>
</body>
</html>

View file

@ -1,3 +0,0 @@
#app {
color: tomato;
}

View file

@ -1,3 +0,0 @@
{
"extends": "astro/tsconfigs/base"
}

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"@astrojs/markdown-remark": "^1.1.0",
"hast-util-select": "5.0.1",
"rehype-autolink-headings": "^6.1.1",

View file

@ -10,6 +10,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3"
"astro": "^1.1.5"
}
}

View file

@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"preact": "^10.6.5",
"@astrojs/preact": "^1.0.2",
"@astrojs/mdx": "^0.11.0"
"@astrojs/mdx": "^0.11.1"
}
}

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"preact": "^10.7.3",
"@astrojs/preact": "^1.0.2",
"nanostores": "^0.5.12",

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"@astrojs/tailwind": "^1.0.0",
"autoprefixer": "^10.4.7",
"canvas-confetti": "^1.5.1",

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.3"
}

View file

@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^1.1.3",
"astro": "^1.1.5",
"vitest": "^0.20.3"
}
}

View file

@ -1,5 +1,19 @@
# astro
## 1.1.5
### Patch Changes
- [#4603](https://github.com/withastro/astro/pull/4603) [`36dee7169`](https://github.com/withastro/astro/commit/36dee7169be7f595825d3dfecb04e61cea1b2fe4) Thanks [@matthewp](https://github.com/matthewp)! - Fix error when no JSX renderer configured
## 1.1.4
### Patch Changes
- [#4586](https://github.com/withastro/astro/pull/4586) [`16814dc71`](https://github.com/withastro/astro/commit/16814dc718614c0cce46b788470c1bc40b5cc981) Thanks [@bluwy](https://github.com/bluwy)! - Move ast-types as dev dependency
- [#4585](https://github.com/withastro/astro/pull/4585) [`f018e365c`](https://github.com/withastro/astro/commit/f018e365cf22bd6b7235fe956e33b5d80fa059a1) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Add docs link to "missing adapter" error msg
## 1.1.3
### Patch Changes

View file

@ -1,6 +1,6 @@
{
"name": "astro",
"version": "1.1.3",
"version": "1.1.5",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",

View file

@ -1,7 +1,7 @@
import type { OutputChunk, RenderedChunk } from 'rollup';
import type { PageBuildData, ViteID } from './types';
import { prependForwardSlash } from '../path.js';
import { prependForwardSlash, removeFileExtension } from '../path.js';
import { viteID } from '../util.js';
export interface BuildInternals {
@ -136,8 +136,15 @@ export function* getPageDatasByClientOnlyID(
): Generator<PageBuildData, void, unknown> {
const pagesByClientOnly = internals.pagesByClientOnly;
if (pagesByClientOnly.size) {
const pathname = `/@fs${prependForwardSlash(viteid)}`;
const pageBuildDatas = pagesByClientOnly.get(pathname);
let pathname = `/@fs${prependForwardSlash(viteid)}`;
let pageBuildDatas = pagesByClientOnly.get(viteid);
// BUG! The compiler partially resolves .jsx to remove the file extension so we have to check again.
// We should probably get rid of all `@fs` usage and always fully resolve via Vite,
// but this would be a bigger change.
if (!pageBuildDatas) {
pathname = `/@fs${prependForwardSlash(removeFileExtension(viteid))}`;
pageBuildDatas = pagesByClientOnly.get(pathname);
}
if (pageBuildDatas) {
for (const pageData of pageBuildDatas) {
yield pageData;

View file

@ -4,7 +4,6 @@ import type { BuildInternals } from '../../core/build/internal.js';
import type { PluginMetadata as AstroPluginMetadata } from '../../vite-plugin-astro/types';
import { prependForwardSlash } from '../../core/path.js';
import { resolveClientDevPath } from '../../core/render/dev/resolve.js';
import { getTopLevelPages } from './graph.js';
import { getPageDataByViteID, trackClientOnlyPageDatas } from './internal.js';
@ -82,7 +81,7 @@ export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin {
const astro = info.meta.astro as AstroPluginMetadata['astro'];
for (const c of astro.hydratedComponents) {
const rid = c.resolvedPath ? resolveClientDevPath(c.resolvedPath) : c.specifier;
const rid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
internals.discoveredHydratedComponents.add(rid);
}
@ -93,7 +92,7 @@ export function vitePluginAnalyzer(internals: BuildInternals): VitePlugin {
const clientOnlys: string[] = [];
for (const c of astro.clientOnlyComponents) {
const cid = c.resolvedPath ? resolveClientDevPath(c.resolvedPath) : c.specifier;
const cid = c.resolvedPath ? decodeURI(c.resolvedPath) : c.specifier;
internals.discoveredClientOnlyComponents.add(cid);
clientOnlys.push(cid);
}

View file

@ -46,3 +46,8 @@ function isString(path: unknown): path is string {
export function joinPaths(...paths: (string | undefined)[]) {
return paths.filter(isString).map(trimSlashes).join('/');
}
export function removeFileExtension(path: string) {
let idx = path.lastIndexOf('.');
return idx === -1 ? path : path.slice(0, idx);
}

View file

@ -18,11 +18,14 @@ export async function getStylesForURL(
for await (const importedModule of crawlGraph(viteServer, viteID(filePath), true)) {
const ext = path.extname(importedModule.url).toLowerCase();
if (STYLE_EXTENSIONS.has(ext)) {
// The SSR module is possibly not loaded. Load it if it's null.
const ssrModule =
importedModule.ssrModule ?? (await viteServer.ssrLoadModule(importedModule.url));
if (
mode === 'development' && // only inline in development
typeof importedModule.ssrModule?.default === 'string' // ignore JS module styles
typeof ssrModule?.default === 'string' // ignore JS module styles
) {
importedStylesMap.set(importedModule.url, importedModule.ssrModule.default);
importedStylesMap.set(importedModule.url, ssrModule.default);
} else {
// NOTE: We use the `url` property here. `id` would break Windows.
importedCssUrls.add(importedModule.url);

View file

@ -1,6 +1,7 @@
import type { PluginObj } from '@babel/core';
import * as t from '@babel/types';
import { pathToFileURL } from 'node:url';
import { resolveClientDevPath } from '../core/render/dev/resolve.js';
import { HydrationDirectiveProps } from '../runtime/server/hydration.js';
import type { PluginMetadata } from '../vite-plugin-astro/types';
@ -217,10 +218,7 @@ export default function astroJSX(): PluginObj {
let resolvedPath: string;
if (meta.path.startsWith('.')) {
const fileURL = pathToFileURL(state.filename!);
resolvedPath = `/@fs${new URL(meta.path, fileURL).pathname}`;
if (resolvedPath.endsWith('.jsx')) {
resolvedPath = resolvedPath.slice(0, -4);
}
resolvedPath = resolveClientDevPath(`/@fs${new URL(meta.path, fileURL).pathname}`);
} else {
resolvedPath = meta.path;
}
@ -300,10 +298,7 @@ export default function astroJSX(): PluginObj {
let resolvedPath: string;
if (meta.path.startsWith('.')) {
const fileURL = pathToFileURL(state.filename!);
resolvedPath = `/@fs${new URL(meta.path, fileURL).pathname}`;
if (resolvedPath.endsWith('.jsx')) {
resolvedPath = resolvedPath.slice(0, -4);
}
resolvedPath = resolveClientDevPath(`/@fs${new URL(meta.path, fileURL).pathname}`);
} else {
resolvedPath = meta.path;
}

View file

@ -140,12 +140,12 @@ export async function generateHydrateScript(
}
// Add component url
island.props['component-url'] = await result.resolve(componentUrl);
island.props['component-url'] = await result.resolve(decodeURI(componentUrl));
// Add renderer url
if (renderer.clientEntrypoint) {
island.props['component-export'] = componentExport.value;
island.props['renderer-url'] = await result.resolve(renderer.clientEntrypoint);
island.props['renderer-url'] = await result.resolve(decodeURI(renderer.clientEntrypoint));
island.props['props'] = escapeHTML(serializeProps(props));
}

View file

@ -160,14 +160,14 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
let astroJSXRenderer: AstroRenderer;
// The first JSX renderer provided is considered the default renderer.
// This is a useful reference for when the user only gives a single render.
let defaultJSXRendererEntry: [string, AstroRenderer];
let defaultJSXRendererEntry: [string, AstroRenderer] | undefined;
return {
name: 'astro:jsx',
enforce: 'pre', // run transforms before other plugins
async configResolved(resolvedConfig) {
viteConfig = resolvedConfig;
const possibleRenderers = await collectJSXRenderers(config._ctx.renderers);
const possibleRenderers = collectJSXRenderers(config._ctx.renderers);
for (const [importSource, renderer] of possibleRenderers) {
jsxRenderers.set(importSource, renderer);
if (importSource === 'astro') {
@ -224,8 +224,8 @@ export default function jsx({ config, logging }: AstroPluginJSXOptions): Plugin
}
// if we still cant tell the import source, now is the time to throw an error.
if (!importSource) {
const [defaultRendererName] = defaultJSXRendererEntry[0];
if (!importSource && defaultJSXRendererEntry) {
const [defaultRendererName] = defaultJSXRendererEntry;
error(
logging,
'renderer',
@ -234,6 +234,16 @@ Unable to resolve a renderer that handles this file! With more than one renderer
Add ${colors.cyan(
IMPORT_STATEMENTS[defaultRendererName] || `import '${defaultRendererName}';`
)} or ${colors.cyan(`/* jsxImportSource: ${defaultRendererName} */`)} to this file.
`
);
return null;
} else if (!importSource) {
error(
logging,
'renderer',
`${colors.yellow(id)}
Unable to find a renderer for JSX. Do you have one configured in your Astro config? See this page to learn how:
https://docs.astro.build/en/core-concepts/framework-components/#installing-integrations
`
);
return null;

View file

@ -33,6 +33,12 @@ describe('Client only components', () => {
expect(css).to.match(/yellowgreen/, 'Svelte styles are added');
expect(css).to.match(/Courier New/, 'Global styles are added');
});
it('Includes CSS from components that use CSS modules', async () => {
const html = await fixture.readFile('/css-modules/index.html');
const $ = cheerioLoad(html);
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1);
});
});
describe('Client only components subpath', () => {

View file

@ -0,0 +1,11 @@
import Styles from './styles.module.scss';
const ClientApp = () => {
return (
<div>
<h2 className={Styles.red}>This text should be red</h2>
</div>
);
};
export default ClientApp;

View file

@ -0,0 +1,3 @@
.red {
color: red;
}

View file

@ -0,0 +1,11 @@
---
import UsingCSSModules from '../components/UsingCSSModules.jsx';
---
<html>
<head>
<title>Using CSS modules</title>
</head>
<body>
<UsingCSSModules client:only="react" />
</body>
</html>

View file

@ -1,17 +1,21 @@
---
import CaretCounter from '../components/^--with-carets/Counter';
import RocketCounter from '../components/and-rockets-🚀/Counter';
import PercentCounter from '../components/now-100%-better/Counter';
// Not supported in Vite
// import PercentCounter from '../components/now-100%-better/Counter';
import SpaceCounter from '../components/with some spaces/Counter';
import RoundBracketCounter from '../components/with-(round-brackets)/Counter';
import SquareBracketCounter from '../components/with-[square-brackets]/Counter';
---
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<h1>Special chars in component import paths from an .astro file</h1>
<CaretCounter id="caret" client:visible />
<RocketCounter id="rocket" client:visible />
<PercentCounter id="percent" client:visible />
<!-- <PercentCounter id="percent" client:visible /> -->
<SpaceCounter id="space" client:visible />
<RoundBracketCounter id="round-bracket" client:visible />
<SquareBracketCounter id="square-bracket" client:visible />

View file

@ -1,6 +1,7 @@
import CaretCounter from '../components/^--with-carets/Counter'
import RocketCounter from '../components/and-rockets-🚀/Counter'
import PercentCounter from '../components/now-100%-better/Counter'
// Not supported in Vite
// import PercentCounter from '../components/now-100%-better/Counter'
import SpaceCounter from '../components/with some spaces/Counter'
import RoundBracketCounter from '../components/with-(round-brackets)/Counter'
import SquareBracketCounter from '../components/with-[square-brackets]/Counter'
@ -9,7 +10,7 @@ import SquareBracketCounter from '../components/with-[square-brackets]/Counter'
<CaretCounter id="caret" client:visible />
<RocketCounter id="rocket" client:visible />
<PercentCounter id="percent" client:visible />
{/* <PercentCounter id="percent" client:visible /> */}
<SpaceCounter id="space" client:visible />
<RoundBracketCounter id="round-bracket" client:visible />
<SquareBracketCounter id="square-bracket" client:visible />

View file

@ -2,11 +2,19 @@ import { expect } from 'chai';
import { load as cheerioLoad } from 'cheerio';
import { isWindows, loadFixture } from './test-utils.js';
describe.skip('Special chars in component import paths', () => {
describe('Special chars in component import paths', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
const componentIds = ['caret', 'rocket', 'percent', 'space', 'round-bracket', 'square-bracket'];
const componentIds = [
'caret',
'rocket',
// Not supported as import identifier in Vite
// 'percent',
'space',
'round-bracket',
'square-bracket',
];
before(async () => {
fixture = await loadFixture({

View file

@ -116,9 +116,8 @@ export async function main() {
const hash = args.commit ? `#${args.commit}` : '';
// Don't touch the template name if a GitHub repo was provided, ex: `--template cassidoo/shopify-react-astro`
const isThirdParty = options.template.includes('/');
const templateTarget = options.template.includes('/')
const templateTarget = isThirdParty
? options.template
: `withastro/astro/examples/${options.template}#latest`;

View file

@ -64,7 +64,7 @@ Check our [Astro Integration Documentation][astro-integration] for more on integ
## Limitations
The Apline.js integration does not give you control over how the script is loaded or initialized. If you require this control, consider [installing and using Alpine.js manually](https://alpinejs.dev/essentials/installation). Astro supports all officially documented Alpine.js manual setup instructions, using `<script>` tags inside of an Astro component.
The Alpine.js integration does not give you control over how the script is loaded or initialized. If you require this control, consider [installing and using Alpine.js manually](https://alpinejs.dev/essentials/installation). Astro supports all officially documented Alpine.js manual setup instructions, using `<script>` tags inside of an Astro component.
**It is not currently possible to [extend Alpine.js](https://alpinejs.dev/advanced/extending) when using this component.** If you need this feature, consider following [the manual Alpine.js setup](https://alpinejs.dev/essentials/installation) instead using an Astro script tag:
@ -83,7 +83,7 @@ The Apline.js integration does not give you control over how the script is loade
## Configuration
The Apline.js integration does not support any custom configuration at this time.
The Alpine.js integration does not support any custom configuration at this time.
## Examples

View file

@ -19,7 +19,7 @@
"performance"
],
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://astro.build",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/alpinejs",
"exports": {
".": "./dist/index.js",
"./package.json": "./package.json"

View file

@ -2,9 +2,25 @@
An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Javascript and deploy to Cloudflare Pages.
In your `astro.config.mjs` use:
## Install
```js
Add the Cloudflare adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
```bash
npx astro add cloudflare
```
If you prefer to install the adapter manually instead, complete the following two steps:
1. Add the Cloudflare adapter to your project's dependencies using your preferred package manager. If youre using npm or arent sure, run this in the terminal:
```bash
npm install @astrojs/cloudflare
```
2. Add the following to your `astro.config.mjs` file:
```js title="astro.config.mjs" ins={2, 5-6}
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';

View file

@ -2,6 +2,8 @@
This adapter allows Astro to deploy your SSR site to Deno targets.
Learn how to deploy your Astro site in our [Deno Deploy deployment guide](https://docs.astro.build/en/guides/deploy/deno/).
- <strong>[Why Astro Deno](#why-astro-deno)</strong>
- <strong>[Installation](#installation)</strong>
- <strong>[Usage](#usage)</strong>
@ -21,26 +23,54 @@ If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/gui
## Installation
First, install the `@astrojs/deno` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
Add the Deno adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
```sh
npm install @astrojs/deno
```bash
npx astro add deno
```
Then, install this adapter in your `astro.config.*` file using the `adapter` property:
If you prefer to install the adapter manually instead, complete the following two steps:
__`astro.config.mjs`__
1. Install the Deno adapter to your projects dependencies using your preferred package manager. If youre using npm or arent sure, run this in the terminal:
```js
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
```bash
npm install @astrojs/deno
```
export default defineConfig({
// ...
output: 'server',
adapter: deno()
});
```
1. Update your `astro.config.mjs` project configuration file with the changes below.
```js ins={3,6-7}
// astro.config.mjs
import { defineConfig } from 'astro/config';
import deno from '@astrojs/deno';
export default defineConfig({
output: 'server',
adapter: deno(),
});
```
Next, Update your `preview` script in `package.json` with the change below.
```json del={8} ins={9}
// package.json
{
// ...
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview"
"preview": "deno run --allow-net --allow-read --allow-env ./dist/server/entry.mjs"
}
}
```
You can now use this command to preview your production Astro site locally with Deno.
```bash
npm run preview
```
## Usage

View file

@ -1,5 +1,15 @@
# @astrojs/image
## 0.5.0
### Minor Changes
- [#4511](https://github.com/withastro/astro/pull/4511) [`72c760e9b`](https://github.com/withastro/astro/commit/72c760e9b8e70dc4c8d4cc08f453d58a8928a0ee) Thanks [@DerYeger](https://github.com/DerYeger)! - feat: throw if alt text is missing
### Patch Changes
- [#4593](https://github.com/withastro/astro/pull/4593) [`56f83be92`](https://github.com/withastro/astro/commit/56f83be92a6417bb1cbb88dd58c3dcaf5177b9b6) Thanks [@tony-sull](https://github.com/tony-sull)! - Fixes a bug that broke support for local images with spaces in the filename
## 0.4.0
### Minor Changes

View file

@ -90,9 +90,9 @@ import { Image, Picture } from '@astrojs/image/components';
The included `sharp` transformer supports resizing images and encoding them to different image formats. Third-party image services will be able to add support for custom transformations as well (ex: `blur`, `filter`, `rotate`, etc).
Astros <Image /> and <Picture /> components require the alt attribute which provides descriptive text for images. A warning will be logged if "alt" text is missing, and a future release of the integration will throw an error if no alt text is provided.
Astros `<Image />` and `<Picture />` components require the `alt` attribute, which provides descriptive text for images. A warning will be logged if alt text is missing, and a future release of the integration will throw an error if no alt text is provided.
If the image is merely decorative (i.e. doesnt contribute to the understanding of the page), set alt="" so that the image is properly understood and ignored by screen readers.
If the image is merely decorative (i.e. doesnt contribute to the understanding of the page), set `alt=""` so that the image is properly understood and ignored by screen readers.
### `<Image />`
@ -126,7 +126,7 @@ For remote images, provide the full URL. (e.g. `src="https://astro.build/assets/
Defines an alternative text description of the image.
Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel).
Set to an empty string (`alt=""`) if the image is not a key part of the content (e.g. it's decoration or a tracking pixel).
#### format
@ -218,7 +218,7 @@ For remote images, provide the full URL. (e.g. `src="https://astro.build/assets/
Defines an alternative text description of the image.
Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel).
Set to an empty string (`alt=""`) if the image is not a key part of the content (e.g. it's decoration or a tracking pixel).
#### sizes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/image",
"description": "Load and transform images in your Astro site.",
"version": "0.4.0",
"version": "0.5.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
@ -41,6 +41,7 @@
"test": "mocha --exit --timeout 20000 test"
},
"dependencies": {
"@altano/tiny-async-pool": "^1.0.2",
"@squoosh/lib": "^0.4.0",
"image-size": "^1.0.2",
"magic-string": "^0.25.9",

View file

@ -1,6 +1,8 @@
import { doWork } from '@altano/tiny-async-pool';
import type { AstroConfig } from 'astro';
import { bgGreen, black, cyan, dim, green } from 'kleur/colors';
import fs from 'node:fs/promises';
import OS from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import type { SSRImageService, TransformOptions } from '../loaders/index.js';
@ -23,19 +25,26 @@ export interface SSGBuildParams {
export async function ssgBuild({ loader, staticImages, config, outDir, logLevel }: SSGBuildParams) {
const timer = performance.now();
const cpuCount = OS.cpus().length;
info({
level: logLevel,
prefix: false,
message: `${bgGreen(
black(` optimizing ${staticImages.size} image${staticImages.size > 1 ? 's' : ''} `)
black(
` optimizing ${staticImages.size} image${
staticImages.size > 1 ? 's' : ''
} in batches of ${cpuCount} `
)
)}`,
});
const inputFiles = new Set<string>();
// process transforms one original image file at a time
for (let [src, transformsMap] of staticImages) {
async function processStaticImage([src, transformsMap]: [
string,
Map<string, TransformOptions>
]): Promise<void> {
let inputFile: string | undefined = undefined;
let inputBuffer: Buffer | undefined = undefined;
@ -60,15 +69,15 @@ export async function ssgBuild({ loader, staticImages, config, outDir, logLevel
if (!inputBuffer) {
// eslint-disable-next-line no-console
warn({ level: logLevel, message: `"${src}" image could not be fetched` });
continue;
return;
}
const transforms = Array.from(transformsMap.entries());
debug({ level: logLevel, prefix: false, message: `${green('▶')} ${src}` });
debug({ level: logLevel, prefix: false, message: `${green('▶')} transforming ${src}` });
let timeStart = performance.now();
// process each transformed versiono of the
// process each transformed version
for (const [filename, transform] of transforms) {
timeStart = performance.now();
let outputFile: string;
@ -92,11 +101,14 @@ export async function ssgBuild({ loader, staticImages, config, outDir, logLevel
debug({
level: logLevel,
prefix: false,
message: ` ${cyan('└─')} ${dim(pathRelative)} ${dim(timeIncrease)}`,
message: ` ${cyan('created')} ${dim(pathRelative)} ${dim(timeIncrease)}`,
});
}
}
// transform each original image file in batches
await doWork(cpuCount, staticImages, processStaticImage);
info({
level: logLevel,
prefix: false,

View file

@ -1,5 +1,11 @@
# @astrojs/mdx
## 0.11.1
### Patch Changes
- [#4588](https://github.com/withastro/astro/pull/4588) [`db38f61b2`](https://github.com/withastro/astro/commit/db38f61b2b2dc55f03b28797d19b163b1940f1c8) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix: Add GFM and Smartypants to MDX by default
## 0.11.0
### Minor Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/mdx",
"description": "Use MDX within Astro",
"version": "0.11.0",
"version": "0.11.1",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -2,6 +2,8 @@
This adapter allows Astro to deploy your SSR site to [Netlify](https://www.netlify.com/).
Learn how to deploy your Astro site in our [Netlify deployment guide](https://docs.astro.build/en/guides/deploy/netlify/).
- <strong>[Why Astro Netlify](#why-astro-netlify)</strong>
- <strong>[Installation](#installation)</strong>
- <strong>[Usage](#usage)</strong>
@ -23,39 +25,47 @@ If you wish to [use server-side rendering (SSR)](https://docs.astro.build/en/gui
## Installation
First, install the `@astrojs/netlify` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
```sh
npm install @astrojs/netlify
Add the Netlify adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step.
```bash
npx astro add netlify
```
Then, install this adapter in your `astro.config.*` file using the `adapter` property. Note: there are two different adapters, one for Netlify Functions and one for Edge Functions. See [Edge Functions](#edge-functions) below on importing the latter.
If you prefer to install the adapter manually instead, complete the following two steps:
__`astro.config.mjs`__
1. Install the Netlify adapter to your projects dependencies using your preferred package manager. If youre using npm or arent sure, run this in the terminal:
```js
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
```bash
npm install @astrojs/netlify
```
export default defineConfig({
output: 'server',
adapter: netlify(),
});
```
1. Add two new lines to your `astro.config.mjs` project configuration file.
```js title="astro.config.mjs" ins={2, 5-6}
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
export default defineConfig({
output: 'server',
adapter: netlify(),
});
```
### Edge Functions
Netlify has two serverless platforms, Netlify Functions and Netlify Edge Functions. With Edge Functions your code is distributed closer to your users, lowering latency. You can use Edge Functions by changing the import in your astro configuration file:
Netlify has two serverless platforms, Netlify Functions and [Netlify's experimental Edge Functions](https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/#app). With Edge Functions your code is distributed closer to your users, lowering latency. You can use Edge Functions by changing the `netlify/functions` import in the Astro config file to use `netlify/edge-functions`.
```diff
import { defineConfig } from 'astro/config';
- import netlify from '@astrojs/netlify/functions';
+ import netlify from '@astrojs/netlify/edge-functions';
```js title="astro.config.mjs" ins={3} del={2}
import { defineConfig } from 'astro/config';
import netlify from '@astrojs/netlify/functions';
import netlify from '@astrojs/netlify/edge-functions';
export default defineConfig({
output: 'server',
adapter: netlify(),
});
```
export default defineConfig({
output: 'server',
adapter: netlify(),
});
```
## Usage
[Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/netlify/)

Some files were not shown because too many files have changed in this diff Show more