Merge branch 'main' into add-Minification

This commit is contained in:
wulinsheng123 2023-04-29 07:30:14 +08:00 committed by GitHub
commit 5e1970bf29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
124 changed files with 777 additions and 664 deletions

View file

@ -6,7 +6,6 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["@example/*", "@test/*"],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}

View file

@ -0,0 +1,6 @@
---
'@astrojs/telemetry': patch
'@astrojs/webapi': patch
---
Upgrade undici to v5.22.0

View file

@ -1,5 +0,0 @@
---
'@astrojs/rss': minor
---
Added extra elements to the RSS items, including categories and enclosure

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Update `experimental.assets`'s `image.service` configuration to allow for a config option in addition to an entrypoint

View file

@ -0,0 +1,5 @@
---
"@astrojs/cloudflare": patch
---
Fix missing code language in Cloudflare README

View file

@ -0,0 +1,6 @@
---
'@astrojs/tailwind': patch
'@astrojs/svelte': patch
---
Update dependencies

View file

@ -49,9 +49,6 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Status
run: git status
# Lint autofix cannot run on forks, so just skip those! See https://github.com/wearerequired/lint-action/issues/13
- name: Lint (External)
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != github.repository_owner }}
@ -79,17 +76,22 @@ jobs:
- name: Format Check
run: pnpm run format --check
# Build primes out build caches for Turbo
# Build primes out Turbo build cache and pnpm cache
build:
name: "Build: ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
timeout-minutes: 3
strategy:
matrix:
OS: [ubuntu-latest]
OS: [ubuntu-latest, windows-latest]
NODE_VERSION: [16]
fail-fast: true
steps:
# Disable crlf so all OS can share the same Turbo cache
# https://github.com/actions/checkout/issues/135
- name: Disable git crlf
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v3
@ -105,7 +107,9 @@ jobs:
- name: Install dependencies
run: pnpm install
# Only build in ubuntu as windows can share the build cache
- name: Build Packages
if: ${{ matrix.os == 'ubuntu-latest' }}
run: pnpm run build
test:
@ -126,6 +130,9 @@ jobs:
env:
NODE_VERSION: ${{ matrix.NODE_VERSION }}
steps:
- name: Disable git crlf
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v3
@ -165,6 +172,9 @@ jobs:
env:
NODE_VERSION: ${{ matrix.NODE_VERSION }}
steps:
- name: Disable git crlf
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v3
@ -198,6 +208,9 @@ jobs:
env:
NODE_VERSION: ${{ matrix.NODE_VERSION }}
steps:
- name: Disable git crlf
run: git config --global core.autocrlf false
- name: Checkout
uses: actions/checkout@v3
@ -219,10 +232,18 @@ jobs:
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
# Reset lockfile changes so that Turbo can reuse the old build cache
- name: Reset lockfile changes
run: git reset --hard
- name: Build Packages
run: pnpm run build
- name: Remove docs translations except for English and Korean
run: find smoke/docs/src/content/docs ! -name 'en' ! -name 'ko' -type d -mindepth 1 -maxdepth 1 -exec rm -rf {} +
- name: Test
run: pnpm run test:smoke
env:
SKIP_OG: 1
SKIP_OG: true
PUBLIC_TWO_LANG: true

3
.gitignore vendored
View file

@ -30,4 +30,7 @@ packages/integrations/**/.netlify/
# ignore content collection generated files
packages/**/test/**/fixtures/**/.astro/
packages/**/test/**/fixtures/**/env.d.ts
packages/**/e2e/**/fixtures/**/.astro/
packages/**/e2e/**/fixtures/**/env.d.ts
examples/**/.astro/
examples/**/env.d.ts

23
.prettierrc.cjs Normal file
View file

@ -0,0 +1,23 @@
module.exports = {
printWidth: 100,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: true,
plugins: ['./node_modules/prettier-plugin-astro'],
overrides: [
{
files: ['.*', '*.json', '*.md', '*.toml', '*.yml'],
options: {
useTabs: false,
},
},
{
files: ['**/*.astro'],
options: {
parser: 'astro',
},
},
],
};

View file

@ -1,32 +0,0 @@
// Heads up: This file should be renamed to `.cjs`, however if we did that, changesets wouldn't be able to load it
module.exports = {
printWidth: 100,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: true,
plugins: ['./node_modules/prettier-plugin-astro'],
overrides: [
{
// Changesets run Prettier using our configuration, however it uses a very old version of Prettier that does
// not support our plugin and it ends up doing more harm than good. As such, we'll disable our plugin for changelogs
files: ['CHANGELOG.md'],
options: {
plugins: [],
},
},
{
files: ['.*', '*.json', '*.md', '*.toml', '*.yml'],
options: {
useTabs: false,
},
},
{
files: ['**/*.astro'],
options: {
parser: 'astro',
},
},
],
};

View file

@ -27,7 +27,7 @@
"server-destroy": "^1.0.1"
},
"peerDependencies": {
"astro": "workspace:^2.0.18"
"astro": "workspace:^2.3.2"
},
"devDependencies": {
"@types/server-destroy": "^1.0.1",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"alpinejs": "^3.10.2",
"@astrojs/alpinejs": "^0.2.1",
"@types/alpinejs": "^3.7.0"

View file

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

View file

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

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"preact": "^10.7.3",
"@astrojs/preact": "^2.1.0",
"@preact/signals": "^1.1.0"

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"@astrojs/react": "^2.1.1",

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"solid-js": "^1.4.3",
"@astrojs/solid-js": "^2.1.0"
}

View file

@ -13,6 +13,6 @@
"dependencies": {
"svelte": "^3.48.0",
"@astrojs/svelte": "^2.1.0",
"astro": "^2.3.1"
"astro": "^2.3.2"
}
}

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"vue": "^3.2.37",
"@astrojs/vue": "^2.1.1"
}

View file

@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/node": "^5.1.1",
"astro": "^2.3.1"
"astro": "^2.3.2"
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"svelte": "^3.48.0",
"@astrojs/svelte": "^2.1.0",
"@astrojs/node": "^5.1.1",

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.1.1",
"astro": "^2.3.1",
"astro": "^2.3.2",
"kleur": "^4.1.5"
}
}

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"@astrojs/markdown-remark": "^2.1.4",
"hast-util-select": "5.0.1",
"rehype-autolink-headings": "^6.1.1",

View file

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

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"preact": "^10.6.5",
"@astrojs/preact": "^2.1.0",
"@astrojs/mdx": "^0.19.0"

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"preact": "^10.7.3",
"@astrojs/preact": "^2.1.0",
"nanostores": "^0.5.12",

View file

@ -14,10 +14,10 @@
"@astrojs/mdx": "^0.19.0",
"@astrojs/tailwind": "^3.1.1",
"@types/canvas-confetti": "^1.4.3",
"astro": "^2.3.1",
"autoprefixer": "^10.4.7",
"astro": "^2.3.2",
"autoprefixer": "^10.4.14",
"canvas-confetti": "^1.5.1",
"postcss": "^8.4.14",
"tailwindcss": "^3.0.24"
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2"
}
}

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^2.3.1",
"astro": "^2.3.2",
"vite-plugin-pwa": "0.11.11",
"workbox-window": "^6.5.3"
}

View file

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

View file

@ -8,19 +8,21 @@
},
"scripts": {
"release": "pnpm run build && changeset publish",
"build": "turbo run build --output-logs=new-only --no-deps --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"build:ci": "turbo run build:ci --output-logs=new-only --no-deps --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"build": "turbo run build --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"build:ci": "turbo run build:ci --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"build:examples": "turbo run build --filter=\"@example/*\"",
"dev": "turbo run dev --no-deps --no-cache --parallel --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"dev": "turbo run dev --parallel --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --filter=\"@benchmark/*\"",
"format": "pnpm run format:code",
"format:ci": "pnpm run format:imports && pnpm run format:code",
"format:code": "prettier -w . --cache --plugin-search-dir=.",
"format:imports": "organize-imports-cli ./packages/*/tsconfig.json ./packages/*/*/tsconfig.json",
"test": "turbo run test --output-logs=new-only --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
"test": "turbo run test --concurrency=1 --filter=astro --filter=create-astro --filter=\"@astrojs/*\"",
"test:match": "cd packages/astro && pnpm run test:match",
"test:smoke": "turbo run build --filter=\"@example/*\" --filter=\"docs\" --output-logs=new-only --concurrency=1",
"test:smoke": "pnpm test:smoke:example && pnpm test:smoke:docs",
"test:smoke:example": "turbo run build --concurrency=100% --filter=\"@example/*\"",
"test:smoke:docs": "turbo run build --filter=docs",
"test:check-examples": "node ./scripts/smoke/check.js",
"test:vite-ci": "turbo run test --filter=astro --output-logs=new-only --no-deps --concurrency=1",
"test:vite-ci": "turbo run test --filter=astro",
"test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e",
"test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match",
"benchmark": "astro-benchmark",
@ -31,13 +33,7 @@
"workspaces": [
"packages/markdown/*",
"packages/integrations/*",
"packages/*",
"examples/*",
"examples/component/demo",
"scripts",
"packages/astro/test/fixtures/component-library-shared",
"packages/astro/test/fixtures/custom-elements/my-component-lib",
"packages/astro/test/fixtures/static build/pkg"
"packages/*"
],
"engines": {
"node": ">=16.12.0",
@ -72,7 +68,7 @@
]
},
"patchedDependencies": {
"@changesets/cli@2.23.0": "patches/@changesets__cli@2.23.0.patch"
"@changesets/cli@2.26.1": "patches/@changesets__cli@2.26.1.patch"
}
},
"dependencies": {
@ -80,26 +76,22 @@
"astro-benchmark": "workspace:*"
},
"devDependencies": {
"@changesets/changelog-github": "0.4.4",
"@changesets/cli": "2.23.0",
"@octokit/action": "^3.18.1",
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.1",
"@types/node": "^18.7.21",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"del": "^7.0.0",
"esbuild": "^0.17.12",
"eslint": "^8.38.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-prettier": "^4.2.1",
"execa": "^6.1.0",
"only-allow": "^1.1.1",
"organize-imports-cli": "^0.10.0",
"prettier": "^2.8.7",
"prettier-plugin-astro": "^0.8.0",
"pretty-bytes": "^6.0.0",
"tiny-glob": "^0.2.9",
"turbo": "1.2.5",
"turbo": "^1.9.3",
"typescript": "~5.0.2"
}
}

View file

@ -1,5 +1,11 @@
# @astrojs/rss
## 2.4.0
### Minor Changes
- [#6707](https://github.com/withastro/astro/pull/6707) [`4ea716e56`](https://github.com/withastro/astro/commit/4ea716e5692d23361e9301330ce52733b3d05b01) Thanks [@philnash](https://github.com/philnash)! - Added extra elements to the RSS items, including categories and enclosure
## 2.3.2
### Patch Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/rss",
"description": "Add RSS feeds to your Astro projects",
"version": "2.3.2",
"version": "2.4.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -1,5 +1,11 @@
# astro
## 2.3.2
### Patch Changes
- [#6920](https://github.com/withastro/astro/pull/6920) [`b89042553`](https://github.com/withastro/astro/commit/b89042553ec45d5f6bc71747e0f3470ba969e679) Thanks [@bluwy](https://github.com/bluwy)! - Fix tsconfig alias baseUrl handling for "." and ".." imports
## 2.3.1
### Patch Changes

View file

@ -5,8 +5,8 @@
"dependencies": {
"@astrojs/tailwind": "workspace:*",
"astro": "workspace:*",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"tailwindcss": "^3.0.24"
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2"
}
}

View file

@ -1,6 +1,6 @@
{
"name": "astro",
"version": "2.3.1",
"version": "2.3.2",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",
@ -198,7 +198,7 @@
"sass": "^1.52.2",
"sharp": "^0.31.3",
"srcset-parse": "^1.1.0",
"undici": "^5.20.0",
"undici": "^5.22.0",
"unified": "^10.1.2"
},
"peerDependencies": {

View file

@ -2,6 +2,7 @@
"name": "@test/performance",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
"benchmark": "node ./content-benchmark.mjs"

View file

@ -335,6 +335,12 @@ export interface ViteUserConfig extends vite.UserConfig {
ssr?: vite.SSROptions;
}
export interface ImageServiceConfig {
// eslint-disable-next-line @typescript-eslint/ban-types
entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {});
config?: Record<string, any>;
}
/**
* Astro User Config
* Docs: https://docs.astro.build/reference/configuration-reference/
@ -763,26 +769,26 @@ export interface AstroUserConfig {
/**
* @docs
* @name image.service (Experimental)
* @type {'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string}
* @default `'astro/assets/services/squoosh'`
* @type {{entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string, config: Record<string, any>}}
* @default `{entrypoint: 'astro/assets/services/squoosh', config?: {}}`
* @version 2.1.0
* @description
* Set which image service is used for Astros experimental assets support.
*
* The value should be a module specifier for the image service to use:
* either one of Astros two built-in services, or a third-party implementation.
* The value should be an object with an entrypoint for the image service to use and optionally, a config object to pass to the service.
*
* The service entrypoint can be either one of the included services, or a third-party package.
*
* ```js
* {
* image: {
* // Example: Enable the Sharp-based image service
* service: 'astro/assets/services/sharp',
* service: { entrypoint: 'astro/assets/services/sharp' },
* },
* }
* ```
*/
// eslint-disable-next-line @typescript-eslint/ban-types
service: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | (string & {});
service: ImageServiceConfig;
};
/**

View file

@ -4,6 +4,8 @@ import { isRemotePath } from '../core/path.js';
import { getConfiguredImageService } from './internal.js';
import { isLocalService } from './services/service.js';
import { etag } from './utils/etag.js';
// @ts-expect-error
import { imageServiceConfig } from 'astro:assets';
async function loadRemoteImage(src: URL) {
try {
@ -31,7 +33,7 @@ export const get: APIRoute = async ({ request }) => {
}
const url = new URL(request.url);
const transform = await imageService.parseURL(url);
const transform = await imageService.parseURL(url, imageServiceConfig);
if (!transform || !transform.src) {
throw new Error('Incorrect transform returned by `parseURL`');
@ -49,7 +51,11 @@ export const get: APIRoute = async ({ request }) => {
return new Response('Not Found', { status: 404 });
}
const { data, format } = await imageService.transform(inputBuffer, transform);
const { data, format } = await imageService.transform(
inputBuffer,
transform,
imageServiceConfig
);
return new Response(data, {
status: 200,

View file

@ -1,5 +1,21 @@
import type { ImageServiceConfig } from '../@types/astro.js';
export { getConfiguredImageService, getImage } from './internal.js';
export { baseService, isLocalService } from './services/service.js';
export { type LocalImageProps, type RemoteImageProps } from './types.js';
export { emitESMImage } from './utils/emitAsset.js';
export { imageMetadata } from './utils/metadata.js';
export function sharpImageService(): ImageServiceConfig {
return {
entrypoint: 'astro/assets/services/sharp',
config: {},
};
}
export function squooshImageService(): ImageServiceConfig {
return {
entrypoint: 'astro/assets/services/squoosh',
config: {},
};
}

View file

@ -45,7 +45,10 @@ export async function getConfiguredImageService(): Promise<ImageService> {
*
* This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
*/
export async function getImage(options: ImageTransform): Promise<GetImageResult> {
export async function getImage(
options: ImageTransform,
serviceConfig: Record<string, any>
): Promise<GetImageResult> {
if (!options || typeof options !== 'object') {
throw new AstroError({
...AstroErrorData.ExpectedImageOptions,
@ -54,9 +57,11 @@ export async function getImage(options: ImageTransform): Promise<GetImageResult>
}
const service = await getConfiguredImageService();
const validatedOptions = service.validateOptions ? service.validateOptions(options) : options;
const validatedOptions = service.validateOptions
? service.validateOptions(options, serviceConfig)
: options;
let imageURL = service.getURL(validatedOptions);
let imageURL = service.getURL(validatedOptions, serviceConfig);
// In build and for local services, we need to collect the requested parameters so we can generate the final images
if (isLocalService(service) && globalThis.astroAsset.addStaticImage) {
@ -68,7 +73,9 @@ export async function getImage(options: ImageTransform): Promise<GetImageResult>
options: validatedOptions,
src: imageURL,
attributes:
service.getHTMLAttributes !== undefined ? service.getHTMLAttributes(validatedOptions) : {},
service.getHTMLAttributes !== undefined
? service.getHTMLAttributes(validatedOptions, serviceConfig)
: {},
};
}
@ -121,7 +128,11 @@ export async function generateImage(
serverRoot
)
);
const resultData = await imageService.transform(fileData, { ...options, src: originalImagePath });
const resultData = await imageService.transform(
fileData,
{ ...options, src: originalImagePath },
buildOpts.settings.config.image.service.config
);
const finalFileURL = new URL('.' + filepath, clientRoot);
const finalFolderURL = new URL('./', finalFileURL);

View file

@ -31,14 +31,17 @@ interface SharedServiceProps {
* For external services, this should point to the URL your images are coming from, for instance, `/_vercel/image`
*
*/
getURL: (options: ImageTransform) => string;
getURL: (options: ImageTransform, serviceConfig: Record<string, any>) => string;
/**
* Return any additional HTML attributes separate from `src` that your service requires to show the image properly.
*
* For example, you might want to return the `width` and `height` to avoid CLS, or a particular `class` or `style`.
* In most cases, you'll want to return directly what your user supplied you, minus the attributes that were used to generate the image.
*/
getHTMLAttributes?: (options: ImageTransform) => Record<string, any>;
getHTMLAttributes?: (
options: ImageTransform,
serviceConfig: Record<string, any>
) => Record<string, any>;
/**
* Validate and return the options passed by the user.
*
@ -47,7 +50,7 @@ interface SharedServiceProps {
*
* This method should returns options, and can be used to set defaults (ex: a default output format to be used if the user didn't specify one.)
*/
validateOptions?: (options: ImageTransform) => ImageTransform;
validateOptions?: (options: ImageTransform, serviceConfig: Record<string, any>) => ImageTransform;
}
export type ExternalImageService = SharedServiceProps;
@ -63,14 +66,15 @@ export interface LocalImageService extends SharedServiceProps {
*
* In most cases, this will get query parameters using, for example, `params.get('width')` and return those.
*/
parseURL: (url: URL) => LocalImageTransform | undefined;
parseURL: (url: URL, serviceConfig: Record<string, any>) => LocalImageTransform | undefined;
/**
* Performs the image transformations on the input image and returns both the binary data and
* final image format of the optimized image.
*/
transform: (
inputBuffer: Buffer,
transform: LocalImageTransform
transform: LocalImageTransform,
serviceConfig: Record<string, any>
) => Promise<{ data: Buffer; format: ImageOutputFormat }>;
}

View file

@ -38,7 +38,7 @@ export default function assets({
const adapterName = settings.config.adapter?.name;
if (
['astro/assets/services/sharp', 'astro/assets/services/squoosh'].includes(
settings.config.image.service
settings.config.image.service.entrypoint
) &&
adapterName &&
UNSUPPORTED_ADAPTERS.has(adapterName)
@ -70,7 +70,7 @@ export default function assets({
},
async resolveId(id) {
if (id === VIRTUAL_SERVICE_ID) {
return await this.resolve(settings.config.image.service);
return await this.resolve(settings.config.image.service.entrypoint);
}
if (id === VIRTUAL_MODULE_ID) {
return resolvedVirtualModuleId;
@ -79,8 +79,12 @@ export default function assets({
load(id) {
if (id === resolvedVirtualModuleId) {
return `
export { getImage, getConfiguredImageService, isLocalService } from "astro/assets";
export { getConfiguredImageService, isLocalService } from "astro/assets";
import { getImage as getImageInternal } from "astro/assets";
export { default as Image } from "astro/components/Image.astro";
export const imageServiceConfig = ${JSON.stringify(settings.config.image.service.config)};
export const getImage = async (options) => await getImageInternal(options, imageServiceConfig);
`;
}
},
@ -116,7 +120,10 @@ export default function assets({
}
}
const transform = await globalThis.astroAsset.imageService.parseURL(url);
const transform = await globalThis.astroAsset.imageService.parseURL(
url,
settings.config.image.service.config
);
if (transform === undefined) {
error(logging, 'image', `Failed to parse transform for ${url}`);
@ -127,7 +134,11 @@ export default function assets({
let format: string = meta.format;
if (transform) {
const result = await globalThis.astroAsset.imageService.transform(file, transform);
const result = await globalThis.astroAsset.imageService.transform(
file,
transform,
settings.config.image.service.config
);
data = result.data;
format = result.format;
}
@ -155,7 +166,7 @@ export default function assets({
>();
}
const hash = hashTransform(options, settings.config.image.service);
const hash = hashTransform(options, settings.config.image.service.entrypoint);
let filePath: string;
if (globalThis.astroAsset.staticImages.has(hash)) {

View file

@ -125,14 +125,17 @@ export const AstroConfigSchema = z.object({
),
image: z
.object({
service: z.union([
z.literal('astro/assets/services/sharp'),
z.literal('astro/assets/services/squoosh'),
z.string(),
]),
service: z.object({
entrypoint: z.union([
z.literal('astro/assets/services/sharp'),
z.literal('astro/assets/services/squoosh'),
z.string(),
]),
config: z.record(z.any()).default({}),
}),
})
.default({
service: 'astro/assets/services/squoosh',
service: { entrypoint: 'astro/assets/services/squoosh', config: {} },
}),
markdown: z
.object({

View file

@ -48,7 +48,7 @@ const getConfigAlias = (settings: AstroSettings): Alias[] | null => {
// - `baseUrl` changes the way non-relative specifiers are resolved
// - if `baseUrl` exists then all non-relative specifiers are resolved relative to it
aliases.push({
find: /^(?!\.*\/|\w:)(.+)$/,
find: /^(?!\.*\/|\.*$|\w:)(.+)$/,
replacement: `${[...normalizePath(resolvedBaseUrl)]
.map((segment) => (segment === '$' ? '$$' : segment))
.join('')}/$1`,

View file

@ -61,6 +61,7 @@ describe('Aliases with tsconfig.json', () => {
expect($('#foo').text()).to.equal('foo');
expect($('#constants-foo').text()).to.equal('foo');
expect($('#constants-index').text()).to.equal('index');
});
it('can load namespace packages with @* paths', async () => {
@ -107,6 +108,7 @@ describe('Aliases with tsconfig.json', () => {
expect($('#foo').text()).to.equal('foo');
expect($('#constants-foo').text()).to.equal('foo');
expect($('#constants-index').text()).to.equal('index');
});
it('can load namespace packages with @* paths', async () => {

View file

@ -620,7 +620,12 @@ describe('astro:image', () => {
assets: true,
},
image: {
service: fileURLToPath(new URL('./fixtures/core-image/service.mjs', import.meta.url)),
service: {
entrypoint: fileURLToPath(
new URL('./fixtures/core-image/service.mjs', import.meta.url)
),
config: { foo: 'bar' },
},
},
});
devServer = await fixture.startDevServer();
@ -641,5 +646,13 @@ describe('astro:image', () => {
const $ = cheerio.load(html);
expect($('img').attr('data-service')).to.equal('my-custom-service');
});
it('gets service config', async () => {
const response = await fixture.fetch('/');
const html = await response.text();
const $ = cheerio.load(html);
expect($('#local img').attr('data-service-config')).to.equal('bar');
});
});
});

View file

@ -4,7 +4,7 @@ import Foo from 'src/components/Foo.astro';
import StyleComp from 'src/components/Style.astro';
import Alias from '@components/Alias.svelte';
import { namespace } from '@test/namespace-package'
import { foo } from 'src/utils/constants';
import { foo, index } from 'src/utils/constants';
import '@styles/main.css';
---
<html lang="en">
@ -21,6 +21,7 @@ import '@styles/main.css';
<Alias client:load />
<p id="namespace">{namespace}</p>
<p id="constants-foo">{foo}</p>
<p id="constants-index">{index}</p>
<p id="style-red">style-red</p>
<p id="style-blue">style-blue</p>
</main>

View file

@ -1 +1,3 @@
export * from '.'
export const foo = 'foo'

View file

@ -0,0 +1 @@
export const index = 'index'

View file

@ -1,4 +1,5 @@
{
"name": "@test/astro-client-only-pkg",
"main": "index.svelte"
"main": "index.svelte",
"private": true
}

View file

@ -1,5 +1,6 @@
{
"name": "@test/astro-slot-with-client",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/preact": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/before-hydration",
"private": true,
"dependencies": {
"@astrojs/preact": "workspace:*",
"astro": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/build-assets",
"private": true,
"dependencies": {
"@astrojs/preact": "workspace:*",
"astro": "workspace:*",

View file

@ -7,8 +7,9 @@ const service = {
getURL(options) {
return squoosh.getURL(options);
},
getHTMLAttributes(options) {
getHTMLAttributes(options, serviceConfig) {
options['data-service'] = 'my-custom-service';
options['data-service-config'] = serviceConfig.foo;
return squoosh.getHTMLAttributes(options);
},
parseURL(url) {

View file

@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"@astrojs/test-font-awesome-package": "file:packages/font-awesome",
"@test/astro-font-awesome-package": "file:packages/font-awesome",
"astro": "workspace:*"
}
}

View file

@ -1,4 +1,5 @@
{
"name": "@astrojs/test-font-awesome-package",
"version": "0.0.1"
"name": "@test/astro-font-awesome-package",
"version": "0.0.1",
"private": true
}

View file

@ -6,7 +6,7 @@
font-style: normal;
font-weight: 300;
font-display: swap;
src: url('@astrojs/test-font-awesome-package/fontawesome-webfont.woff2')
src: url('@test/astro-font-awesome-package/fontawesome-webfont.woff2')
format('woff2');
}

View file

@ -7,7 +7,7 @@
font-style: normal;
font-weight: 300;
font-display: swap;
src: url('@astrojs/test-font-awesome-package/fontawesome-webfont2.woff2')
src: url('@test/astro-font-awesome-package/fontawesome-webfont2.woff2')
format('woff2');
}

View file

@ -1,5 +1,6 @@
{
"name": "@test/css-order-dynamic-import",
"private": true,
"dependencies": {
"astro": "workspace:*"
}

View file

@ -1,5 +1,6 @@
{
"name": "@test/css-order-import",
"private": true,
"dependencies": {
"@astrojs/react": "workspace:*",
"astro": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/css-order-layout",
"private": true,
"dependencies": {
"astro": "workspace:*"
}

View file

@ -1,5 +1,6 @@
{
"name": "@test/css-order",
"private": true,
"dependencies": {
"astro": "workspace:*"
}

View file

@ -1,5 +1,6 @@
{
"name": "@test/dont-delete-me",
"private": true,
"dependencies": {
"astro": "workspace:*"
}

View file

@ -1,5 +1,6 @@
{
"name": "@test/lazy-layout",
"private": true,
"dependencies": {
"astro": "workspace:*"
}

View file

@ -1,5 +1,5 @@
import one from '@astrojs/renderer-one';
import two from '@astrojs/renderer-two';
import one from '@test/astro-renderer-one';
import two from '@test/astro-renderer-two';
export default {
integrations: [one(), two()]

View file

@ -1,8 +1,9 @@
{
"name": "@test/multiple-renderers",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/renderer-one": "file:./renderers/one",
"@astrojs/renderer-two": "file:./renderers/two"
"@test/astro-renderer-one": "file:./renderers/one",
"@test/astro-renderer-two": "file:./renderers/two"
}
}

View file

@ -7,7 +7,7 @@ export default function() {
addRenderer({
name: 'renderer-one',
clientEntrypoint: null,
serverEntrypoint: '@astrojs/renderer-one/server.mjs',
serverEntrypoint: '@test/astro-renderer-one/server.mjs',
});
}
}

View file

@ -1,5 +1,6 @@
{
"name": "@astrojs/renderer-one",
"name": "@test/astro-renderer-one",
"version": "1.0.0",
"private": true,
"main": "index.mjs"
}

View file

@ -7,7 +7,7 @@ export default function() {
addRenderer({
name: 'renderer-two',
clientEntrypoint: null,
serverEntrypoint: '@astrojs/renderer-two/server.mjs',
serverEntrypoint: '@test/astro-renderer-two/server.mjs',
});
}
}

View file

@ -1,5 +1,6 @@
{
"name": "@astrojs/renderer-two",
"name": "@test/astro-renderer-two",
"version": "1.0.0",
"private": true,
"main": "index.mjs"
}

View file

@ -7,8 +7,8 @@
"@astrojs/svelte": "workspace:*",
"@astrojs/vue": "workspace:*",
"astro": "workspace:*",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"solid-js": "^1.5.6",
"svelte": "^3.48.0",
"vue": "^3.2.39"

View file

@ -1,5 +1,6 @@
{
"name": "@test/react-and-solid",
"private": true,
"dependencies": {
"@astrojs/react": "workspace:*",
"@astrojs/solid-js": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/reexport-astro-containing-client-component",
"private": true,
"dependencies": {
"@astrojs/preact": "workspace:",
"astro": "workspace:",

View file

@ -1,6 +1,7 @@
{
"name": "@test/set-html",
"version": "1.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
}

View file

@ -1,6 +1,7 @@
{
"name": "@test/static-build-ssr",
"version": "0.0.0",
"private": true,
"dependencies": {
"@astrojs/node": "workspace:*",
"@test/static-build-pkg": "workspace:*",

View file

@ -1,6 +1,7 @@
{
"name": "@test/static-build",
"version": "0.0.0",
"private": true,
"dependencies": {
"@astrojs/preact": "workspace:*",
"@test/static-build-pkg": "workspace:*",

View file

@ -5,7 +5,7 @@
"dependencies": {
"@astrojs/tailwind": "workspace:*",
"astro": "workspace:*",
"tailwindcss": "^3.2.4",
"postcss": ">=8.3.3 <9.0.0"
"tailwindcss": "^3.3.2",
"postcss": "^8.4.23"
}
}

View file

@ -6,8 +6,8 @@
"@astrojs/tailwind": "workspace:*",
"@astrojs/mdx": "workspace:*",
"astro": "workspace:*",
"autoprefixer": "^10.4.7",
"postcss": "^8.4.14",
"tailwindcss": "^3.0.24"
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2"
}
}

View file

@ -1 +1,4 @@
{}
{
"name": "@test/create-astro-not-empty",
"private": true
}

View file

@ -1,5 +1,14 @@
# @astrojs/cloudflare
## 6.2.3
### Patch Changes
- [#6222](https://github.com/withastro/astro/pull/6222) [`081b2402c`](https://github.com/withastro/astro/commit/081b2402cfb48b5eb8dbd02664d8af2f7c798edf) Thanks [@AirBorne04](https://github.com/AirBorne04)! - add option to compile unminified code
- Updated dependencies [[`b89042553`](https://github.com/withastro/astro/commit/b89042553ec45d5f6bc71747e0f3470ba969e679)]:
- astro@2.3.2
## 6.2.2
### Patch Changes

View file

@ -108,10 +108,28 @@ By default, `@astrojs/cloudflare` will generate a `_routes.json` file that lists
## Troubleshooting
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
### Meaningful error messages
Currently, errors during running your application in Wrangler are not very useful, due to the minification of your code. For better debugging, you can add `vite.build.minify = false` setting to your `astro.config.js`
```js
export default defineConfig({
adapter: cloudflare(),
output: 'server',
vite: {
build: {
minify: false
}
}
});
```
## Contributing
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/cloudflare",
"description": "Deploy your site to Cloudflare Workers/Pages",
"version": "6.2.2",
"version": "6.2.3",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
@ -38,7 +38,7 @@
"tiny-glob": "^0.2.9"
},
"peerDependencies": {
"astro": "workspace:^2.3.1"
"astro": "workspace:^2.3.2"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -103,7 +103,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
allowOverwrite: true,
format: 'esm',
bundle: true,
minify: true,
minify: _config.vite?.build?.minify !== false,
banner: {
js: SHIM,
},

View file

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

View file

@ -63,7 +63,7 @@
"vite": "^4.3.1"
},
"peerDependencies": {
"astro": "workspace:^2.3.1",
"astro": "workspace:^2.3.2",
"sharp": ">=0.31.0"
},
"peerDependenciesMeta": {

View file

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

View file

@ -1,5 +1,6 @@
{
"name": "@test/mdx-page",
"name": "@test/mdx-images",
"private": true,
"dependencies": {
"@astrojs/mdx": "workspace:*",
"astro": "workspace:*",

View file

@ -1,6 +1,7 @@
{
"name": "@test/mdx-infinite-loop",
"type": "module",
"private": true,
"dependencies": {
"@astrojs/mdx": "workspace:*",
"@astrojs/preact": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/mdx-namespace",
"private": true,
"dependencies": {
"@astrojs/mdx": "workspace:*",
"@astrojs/react": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/mdx-page",
"private": true,
"dependencies": {
"@astrojs/mdx": "workspace:*",
"astro": "workspace:*",

View file

@ -1,5 +1,6 @@
{
"name": "@test/mdx-plus-react",
"private": true,
"dependencies": {
"@astrojs/mdx": "workspace:*",
"@astrojs/react": "workspace:*",

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