Merge branch 'main' into add-minification2

This commit is contained in:
Matthew Phillips 2023-05-08 13:21:44 -04:00
commit 62568aa397
57 changed files with 913 additions and 985 deletions

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
}
}

View file

@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"@astrojs/mdx": "^0.19.0",
"@astrojs/rss": "^2.4.0",
"@astrojs/sitemap": "^1.2.2"
"@astrojs/mdx": "^0.19.1",
"@astrojs/rss": "^2.4.1",
"@astrojs/sitemap": "^1.3.0",
"astro": "^2.4.1"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
},
"peerDependencies": {
"astro": "^2.0.0-beta.0"

View file

@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
},
"devDependencies": {
"@astrojs/deno": "^4.1.0"

View file

@ -11,18 +11,18 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"preact": "^10.7.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"@astrojs/react": "^2.1.1",
"@algolia/client-search": "^4.17.0",
"@astrojs/preact": "^2.1.0",
"@algolia/client-search": "^4.13.1",
"@docsearch/css": "^3.1.0",
"@docsearch/react": "^3.1.0",
"@types/react": "^17.0.45",
"@types/node": "^18.0.0",
"@types/react-dom": "^18.0.0"
"@astrojs/react": "^2.1.3",
"@docsearch/css": "^3.3.4",
"@docsearch/react": "^3.3.4",
"@types/node": "^18.16.3",
"@types/react": "^18.2.5",
"@types/react-dom": "^18.2.3",
"astro": "^2.4.1",
"preact": "^10.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"html-escaper": "^3.0.3"

View file

@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"alpinejs": "^3.10.2",
"@astrojs/alpinejs": "^0.2.1",
"@types/alpinejs": "^3.7.0"
"@types/alpinejs": "^3.7.1",
"alpinejs": "^3.12.0",
"astro": "^2.4.1"
}
}

View file

@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"lit": "^2.7.0",
"@astrojs/lit": "^2.0.1",
"@webcomponents/template-shadowroot": "^0.2.1"
"@webcomponents/template-shadowroot": "^0.2.1",
"astro": "^2.4.1",
"lit": "^2.7.4"
}
}

View file

@ -11,17 +11,17 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"preact": "^10.7.3",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"solid-js": "^1.4.3",
"svelte": "^3.48.0",
"vue": "^3.2.37",
"@astrojs/preact": "^2.1.0",
"@astrojs/react": "^2.1.1",
"@astrojs/solid-js": "^2.1.0",
"@astrojs/svelte": "^2.1.0",
"@astrojs/vue": "^2.1.1"
"@astrojs/react": "^2.1.3",
"@astrojs/solid-js": "^2.1.1",
"@astrojs/svelte": "^2.1.1",
"@astrojs/vue": "^2.1.1",
"astro": "^2.4.1",
"preact": "^10.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"solid-js": "^1.7.4",
"svelte": "^3.58.0",
"vue": "^3.2.47"
}
}

View file

@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"preact": "^10.7.3",
"@astrojs/preact": "^2.1.0",
"@preact/signals": "^1.1.0"
"@preact/signals": "^1.1.3",
"astro": "^2.4.1",
"preact": "^10.13.2"
}
}

View file

@ -11,11 +11,11 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"@astrojs/react": "^2.1.1",
"@types/react": "^18.0.10",
"@types/react-dom": "^18.0.5"
"@astrojs/react": "^2.1.3",
"@types/react": "^18.2.5",
"@types/react-dom": "^18.2.3",
"astro": "^2.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}

View file

@ -11,8 +11,8 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"solid-js": "^1.4.3",
"@astrojs/solid-js": "^2.1.0"
"@astrojs/solid-js": "^2.1.1",
"astro": "^2.4.1",
"solid-js": "^1.7.4"
}
}

View file

@ -11,8 +11,8 @@
"astro": "astro"
},
"dependencies": {
"svelte": "^3.48.0",
"@astrojs/svelte": "^2.1.0",
"astro": "^2.3.2"
"@astrojs/svelte": "^2.1.1",
"astro": "^2.4.1",
"svelte": "^3.58.0"
}
}

View file

@ -11,8 +11,8 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"vue": "^3.2.37",
"@astrojs/vue": "^2.1.1"
"@astrojs/vue": "^2.1.1",
"astro": "^2.4.1",
"vue": "^3.2.47"
}
}

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/node": "^5.1.1",
"astro": "^2.3.2"
"@astrojs/node": "^5.1.2",
"astro": "^2.4.1"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
},
"peerDependencies": {
"astro": "^2.0.0-beta.0"

View file

@ -12,12 +12,8 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"astro": "workspace:*",
"svelte": "^3.48.0",
"@astrojs/node": "workspace:*",
"concurrently": "^7.2.1",
"unocss": "^0.15.6",
"vite-imagetools": "^4.0.4",
"@astrojs/node": "^5.1.2",
"astro": "^2.4.1",
"html-minifier": "^4.0.0"
}
}

View file

@ -1,13 +1,9 @@
/// <reference types="astro/client" />
declare global {
namespace AstroMiddleware {
interface Locals {
user: {
name: string;
surname: string;
};
}
declare namespace App {
interface Locals {
user: {
name: string;
surname: string;
};
}
}
export {};

View file

@ -63,9 +63,7 @@ const validation = defineMiddleware(async (context, next) => {
return context.redirect('/admin');
}
}
// we don't really care about awaiting the response in this case
next();
return;
return next();
});
export const onRequest = sequence(validation, minifier);

View file

@ -1,18 +0,0 @@
import { APIRoute } from 'astro';
export const post: APIRoute = async ({ request }) => {
const data = await request.formData();
const username = data.get('username');
const password = data.get('password');
return new Response(
JSON.stringify({
username,
password,
}),
{
headers: {
'content-type': 'application/json',
},
}
);
};

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
}
}

View file

@ -12,12 +12,9 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"astro": "^2.3.2",
"svelte": "^3.48.0",
"@astrojs/svelte": "^2.1.0",
"@astrojs/node": "^5.1.1",
"concurrently": "^7.2.1",
"unocss": "^0.15.6",
"vite-imagetools": "^4.0.4"
"@astrojs/node": "^5.1.2",
"@astrojs/svelte": "^2.1.1",
"astro": "^2.4.1",
"svelte": "^3.58.0"
}
}

View file

@ -11,8 +11,8 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/markdoc": "^0.1.1",
"astro": "^2.3.2",
"@astrojs/markdoc": "^0.1.2",
"astro": "^2.4.1",
"kleur": "^4.1.5"
}
}

View file

@ -11,11 +11,11 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"@astrojs/markdown-remark": "^2.1.4",
"hast-util-select": "5.0.1",
"@astrojs/markdown-remark": "^2.2.0",
"astro": "^2.4.1",
"hast-util-select": "^5.0.5",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.0.1",
"rehype-slug": "^5.1.0",
"rehype-toc": "^3.0.2",
"remark-code-titles": "^0.1.2"
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2"
"astro": "^2.4.1"
}
}

View file

@ -11,9 +11,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"preact": "^10.6.5",
"@astrojs/mdx": "^0.19.1",
"@astrojs/preact": "^2.1.0",
"@astrojs/mdx": "^0.19.0"
"astro": "^2.4.1",
"preact": "^10.13.2"
}
}

View file

@ -11,10 +11,10 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"preact": "^10.7.3",
"@astrojs/preact": "^2.1.0",
"nanostores": "^0.5.12",
"@nanostores/preact": "^0.1.3"
"@nanostores/preact": "^0.4.1",
"astro": "^2.4.1",
"nanostores": "^0.8.1",
"preact": "^10.13.2"
}
}

View file

@ -11,12 +11,12 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^0.19.0",
"@astrojs/tailwind": "^3.1.1",
"@types/canvas-confetti": "^1.4.3",
"astro": "^2.3.2",
"@astrojs/mdx": "^0.19.1",
"@astrojs/tailwind": "^3.1.2",
"@types/canvas-confetti": "^1.6.0",
"astro": "^2.4.1",
"autoprefixer": "^10.4.14",
"canvas-confetti": "^1.5.1",
"canvas-confetti": "^1.6.0",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2"
}

View file

@ -11,8 +11,8 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.2",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.3"
"astro": "^2.4.1",
"vite-plugin-pwa": "0.14.7",
"workbox-window": "^6.5.4"
}
}

View file

@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^2.3.2",
"vitest": "^0.20.3"
"astro": "^2.4.1",
"vitest": "^0.31.0"
}
}

View file

@ -1,5 +1,21 @@
# astro
## 2.4.3
### Patch Changes
- [#7034](https://github.com/withastro/astro/pull/7034) [`c00997033`](https://github.com/withastro/astro/commit/c0099703338cf81e2b381e6e754c73b442db4eab) Thanks [@bluwy](https://github.com/bluwy)! - Fix `astro:assets` SSR error
- [#7032](https://github.com/withastro/astro/pull/7032) [`157357e1f`](https://github.com/withastro/astro/commit/157357e1fb6ff2c14a717230cc485fb76a3fea03) Thanks [@raulfdm](https://github.com/raulfdm)! - fix middleware typing export for "moduleResolution: node"
## 2.4.2
### Patch Changes
- [#7009](https://github.com/withastro/astro/pull/7009) [`1d4db68e6`](https://github.com/withastro/astro/commit/1d4db68e64b7c3faf8863bf67f8332aa28e2f34b) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fix types from `astro/client` not working properly due to `client-base.d.ts` being an non-ambient declaration file
- [#7010](https://github.com/withastro/astro/pull/7010) [`e9f0dd9b4`](https://github.com/withastro/astro/commit/e9f0dd9b473c4793c958a6c81e743fd9b02b4f64) Thanks [@ematipico](https://github.com/ematipico)! - Call `next()` without return anything should work, with a warning
## 2.4.1
### Patch Changes

View file

@ -389,7 +389,7 @@ declare module '*?inline' {
}
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace App {
declare namespace App {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Locals {}
}

View file

@ -1,6 +1,6 @@
{
"name": "astro",
"version": "2.4.1",
"version": "2.4.3",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
@ -20,6 +20,9 @@
],
"app/*": [
"./dist/core/app/*"
],
"middleware": [
"./dist/core/middleware/index.d.ts"
]
}
},

View file

@ -2,6 +2,7 @@ import fs from 'node:fs';
import { basename, join } from 'node:path/posix';
import type { StaticBuildOptions } from '../core/build/types.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { warn } from '../core/logger/core.js';
import { prependForwardSlash } from '../core/path.js';
import { isLocalService, type ImageService, type LocalImageService } from './services/service.js';
import type { GetImageResult, ImageMetadata, ImageTransform } from './types.js';
@ -103,9 +104,10 @@ export async function generateImage(
try {
await fs.promises.mkdir(assetsCacheDir, { recursive: true });
} catch (err) {
console.error(
'An error was encountered while creating the cache directory. Proceeding without caching. Error: ',
err
warn(
buildOpts.logging,
'astro:assets',
`An error was encountered while creating the cache directory. Proceeding without caching. Error: ${err}`
);
useCache = false;
}
@ -160,9 +162,10 @@ export async function generateImage(
await fs.promises.writeFile(cachedFileURL, resultData.data);
await fs.promises.copyFile(cachedFileURL, finalFileURL);
} catch (e) {
console.error(
`There was an error creating the cache entry for ${filepath}. Attempting to write directly to output directory. Error: `,
e
warn(
buildOpts.logging,
'astro:assets',
`An error was encountered while creating the cache directory. Proceeding without caching. Error: ${e}`
);
await fs.promises.writeFile(finalFileURL, resultData.data);
}

View file

@ -58,6 +58,8 @@ const ONLY_DEV_EXTERNAL = [
'shiki',
// Imported by `@astrojs/prism` which exposes `<Prism/>` that is processed by Vite
'prismjs/components/index.js',
// Imported by `astro/assets` -> `packages/astro/src/core/logger/core.ts`
'string-width',
];
/** Return a common starting point for all Vite actions */

View file

@ -46,9 +46,11 @@ export async function callMiddleware<R>(
});
let nextCalled = false;
let responseFunctionPromise: Promise<R> | undefined = undefined;
const next: MiddlewareNext<R> = async () => {
nextCalled = true;
return await responseFunction();
responseFunctionPromise = responseFunction();
return responseFunctionPromise;
};
let middlewarePromise = onRequest(apiContext, next);
@ -74,8 +76,11 @@ export async function callMiddleware<R>(
/**
* Here we handle the case where `next` was called and returned nothing.
*/
const responseResult = await responseFunction();
return responseResult;
if (responseFunctionPromise) {
return responseFunctionPromise;
} else {
throw new AstroError(AstroErrorData.MiddlewareNotAResponse);
}
}
} else if (typeof value === 'undefined') {
/**

View file

@ -34,7 +34,7 @@ const third = defineMiddleware(async (context, next) => {
} else if (context.request.url.includes('/does-nothing')) {
return undefined;
}
next();
return next();
});
export const onRequest = sequence(first, second, third);

View file

@ -0,0 +1,11 @@
import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
// https://astro.build/config
export default defineConfig({
integrations: [tailwind()],
experimental: {
middleware: true,
}
});

View file

@ -0,0 +1,9 @@
{
"name": "@test/middleware-tailwind",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/tailwind": "workspace:*"
}
}

View file

@ -0,0 +1,3 @@
export const onRequest = (_, next) => {
next();
}

View file

@ -0,0 +1,7 @@
<h1 class="text-blue-500 text-2xl font-bold">Hello world</h1>
<style>
p {
color: red;
}
</style>

View file

@ -77,8 +77,6 @@ describe('Middleware in DEV mode', () => {
describe('Middleware in PROD mode, SSG', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
/** @type {import('./test-utils').PreviewServer} */
let previewServer;
before(async () => {
fixture = await loadFixture({
@ -200,3 +198,25 @@ describe('Middleware API in PROD mode, SSR', () => {
expect($('title').html()).to.not.equal('MiddlewareNoDataReturned');
});
});
describe('Middleware with tailwind', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/middleware-tailwind/',
});
await fixture.build();
});
it('should correctly emit the tailwind CSS file', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const bundledCSSHREF = $('link[rel=stylesheet][href^=/_astro/]').attr('href');
const bundledCSS = (await fixture.readFile(bundledCSSHREF.replace(/^\/?/, '/')))
.replace(/\s/g, '')
.replace('/n', '');
expect(bundledCSS.includes('--tw-content')).to.be.true;
});
});

View file

@ -38,7 +38,7 @@
"tiny-glob": "^0.2.9"
},
"peerDependencies": {
"astro": "workspace:^2.4.1"
"astro": "workspace:^2.4.3"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -33,7 +33,7 @@
"esbuild": "^0.15.18"
},
"peerDependencies": {
"astro": "workspace:^2.4.1"
"astro": "workspace:^2.4.3"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -62,7 +62,7 @@
"vite": "^4.3.1"
},
"peerDependencies": {
"astro": "workspace:^2.4.1",
"astro": "workspace:^2.4.3",
"sharp": ">=0.31.0"
},
"peerDependenciesMeta": {

View file

@ -41,7 +41,7 @@
"zod": "^3.17.3"
},
"peerDependencies": {
"astro": "workspace:^2.4.1"
"astro": "workspace:^2.4.3"
},
"devDependencies": {
"@types/chai": "^4.3.1",

View file

@ -39,7 +39,7 @@
"esbuild": "^0.15.18"
},
"peerDependencies": {
"astro": "workspace:^2.4.1"
"astro": "workspace:^2.4.3"
},
"devDependencies": {
"@netlify/edge-functions": "^2.0.0",

View file

@ -35,7 +35,7 @@
"server-destroy": "^1.0.1"
},
"peerDependencies": {
"astro": "workspace:^2.4.1"
"astro": "workspace:^2.4.3"
},
"devDependencies": {
"@types/send": "^0.17.1",

View file

@ -1,5 +1,11 @@
# @astrojs/partytown
## 1.2.1
### Patch Changes
- [#7001](https://github.com/withastro/astro/pull/7001) [`ad5c75447`](https://github.com/withastro/astro/commit/ad5c75447af9cfbdcb1f288c5c17229fbd3d6dd2) Thanks [@Waxer59](https://github.com/Waxer59)! - Fixed a code example that was wrongly closed
## 1.2.0
### Minor Changes

View file

@ -100,7 +100,7 @@ export default defineConfig({
integrations: [partytown({
// Example: Disable debug mode.
config: { debug: false },
})]
})
```

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/partytown",
"description": "Use Partytown to move scripts into a web worker in your Astro project",
"version": "1.2.0",
"version": "1.2.1",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -43,7 +43,7 @@
"vite": "^4.3.1"
},
"peerDependencies": {
"astro": "workspace:^2.4.1",
"astro": "workspace:^2.4.3",
"svelte": "^3.54.0"
},
"engines": {

View file

@ -40,7 +40,7 @@
"vite": "^4.3.1"
},
"peerDependencies": {
"astro": "workspace:^2.4.1",
"astro": "workspace:^2.4.3",
"tailwindcss": "^3.0.24"
},
"pnpm": {

View file

@ -55,7 +55,7 @@
"web-vitals": "^3.1.1"
},
"peerDependencies": {
"astro": "workspace:^2.4.1"
"astro": "workspace:^2.4.3"
},
"devDependencies": {
"@types/set-cookie-parser": "^2.4.2",

View file

@ -50,7 +50,7 @@
"vue": "^3.2.37"
},
"peerDependencies": {
"astro": "workspace:^2.4.1",
"astro": "workspace:^2.4.3",
"vue": "^3.2.30"
},
"engines": {

File diff suppressed because it is too large Load diff