Merge branch 'next' into feat/remove-astro-image
This commit is contained in:
commit
51f51b3920
5 changed files with 41 additions and 9 deletions
8
.changeset/heavy-walls-arrive.md
Normal file
8
.changeset/heavy-walls-arrive.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
'@astrojs/cloudflare': major
|
||||
'@astrojs/netlify': major
|
||||
'@astrojs/vercel': major
|
||||
'astro': major
|
||||
---
|
||||
|
||||
When using an adapter that supports neither Squoosh or Sharp, Astro will now automatically use an image service that does not support processing, but still provides the other benefits of `astro:assets` such as enforcing `alt`, no CLS etc to users
|
|
@ -56,6 +56,7 @@
|
|||
"./assets/image-endpoint": "./dist/assets/image-endpoint.js",
|
||||
"./assets/services/sharp": "./dist/assets/services/sharp.js",
|
||||
"./assets/services/squoosh": "./dist/assets/services/squoosh.js",
|
||||
"./assets/services/noop": "./dist/assets/services/noop.js",
|
||||
"./content/runtime": "./dist/content/runtime.js",
|
||||
"./content/runtime-assets": "./dist/content/runtime-assets.js",
|
||||
"./debug": "./components/Debug.astro",
|
||||
|
|
17
packages/astro/src/assets/services/noop.ts
Normal file
17
packages/astro/src/assets/services/noop.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import { baseService, type LocalImageService } from './service.js';
|
||||
|
||||
// Empty service used for platforms that neither support Squoosh or Sharp.
|
||||
const noopService: LocalImageService = {
|
||||
validateOptions: baseService.validateOptions,
|
||||
getURL: baseService.getURL,
|
||||
parseURL: baseService.parseURL,
|
||||
getHTMLAttributes: baseService.getHTMLAttributes,
|
||||
async transform(inputBuffer, transformOptions) {
|
||||
return {
|
||||
data: inputBuffer,
|
||||
format: transformOptions.format,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default noopService;
|
|
@ -4,8 +4,7 @@ import type {
|
|||
AstroFeatureMap,
|
||||
SupportsKind,
|
||||
} from '../@types/astro';
|
||||
import { error, type LogOptions, warn } from '../core/logger/core.js';
|
||||
import { bold } from 'kleur/colors';
|
||||
import { error, warn, type LogOptions } from '../core/logger/core.js';
|
||||
|
||||
const STABLE = 'stable';
|
||||
const DEPRECATED = 'deprecated';
|
||||
|
@ -140,9 +139,7 @@ function validateAssetsFeature(
|
|||
error(
|
||||
logging,
|
||||
'astro',
|
||||
`The currently selected adapter \`${adapterName}\` is not compatible with the service "Sharp". ${bold(
|
||||
'Your project will NOT be able to build.'
|
||||
)}`
|
||||
`The currently selected adapter \`${adapterName}\` is not compatible with the image service "Sharp".`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -151,9 +148,7 @@ function validateAssetsFeature(
|
|||
error(
|
||||
logging,
|
||||
'astro',
|
||||
`The currently selected adapter \`${adapterName}\` is not compatible with the service "Squoosh". ${bold(
|
||||
'Your project will NOT be able to build.'
|
||||
)}`
|
||||
`The currently selected adapter \`${adapterName}\` is not compatible with the image service "Squoosh".`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import type { SerializedSSRManifest } from '../core/app/types';
|
|||
import type { PageBuildData } from '../core/build/types';
|
||||
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
|
||||
import { mergeConfig } from '../core/config/index.js';
|
||||
import { info, warn, error, type LogOptions, AstroIntegrationLogger } from '../core/logger/core.js';
|
||||
import { AstroIntegrationLogger, error, info, warn, type LogOptions } from '../core/logger/core.js';
|
||||
import { isServerLikeOutput } from '../prerender/utils.js';
|
||||
import { validateSupportedFeatures } from './astroFeaturesValidation.js';
|
||||
|
||||
|
@ -221,6 +221,17 @@ export async function runHookConfigDone({
|
|||
);
|
||||
}
|
||||
}
|
||||
if (!validationResult.assets) {
|
||||
info(
|
||||
logging,
|
||||
'astro',
|
||||
`The selected adapter ${adapter.name} does not support Sharp or Squoosh for image processing. To ensure your project is still able to build, image processing has been disabled.`
|
||||
);
|
||||
settings.config.image.service = {
|
||||
entrypoint: 'astro/assets/services/noop',
|
||||
config: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
settings.adapter = adapter;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue