0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00

[ci] format

This commit is contained in:
matthewp 2022-11-08 16:16:50 +00:00 committed by fredkbot
parent d701ae074a
commit 982e446e8d
2 changed files with 17 additions and 15 deletions

View file

@ -15,7 +15,7 @@ const UNSUPPORTED_ADAPTERS = new Set([
'@astrojs/cloudflare', '@astrojs/cloudflare',
'@astrojs/deno', '@astrojs/deno',
'@astrojs/netlify/edge-functions', '@astrojs/netlify/edge-functions',
'@astrojs/vercel/edge' '@astrojs/vercel/edge',
]); ]);
interface BuildConfig { interface BuildConfig {
@ -107,8 +107,10 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
}, },
'astro:build:start': ({ buildConfig }) => { 'astro:build:start': ({ buildConfig }) => {
const adapterName = _config.adapter?.name; const adapterName = _config.adapter?.name;
if(adapterName && UNSUPPORTED_ADAPTERS.has(adapterName)) { if (adapterName && UNSUPPORTED_ADAPTERS.has(adapterName)) {
throw new Error(`@astrojs/image is not supported with the ${adapterName} adapter. Please choose a Node.js compatible adapter.`); throw new Error(
`@astrojs/image is not supported with the ${adapterName} adapter. Please choose a Node.js compatible adapter.`
);
} }
// Backwards compat // Backwards compat

View file

@ -114,25 +114,25 @@ export function createPlugin(config: AstroConfig, options: Required<IntegrationO
}); });
}, },
outputOptions(outputOptions) { outputOptions(outputOptions) {
if(resolvedConfig.build.ssr) { if (resolvedConfig.build.ssr) {
// Build the image-pool chunk to the top-level and not inside of a chunks/ // Build the image-pool chunk to the top-level and not inside of a chunks/
// folder. This is because the wasm is built at the top-level and this makes // folder. This is because the wasm is built at the top-level and this makes
// it accessible from the pool worker. // it accessible from the pool worker.
const chunkFileNames = outputOptions.chunkFileNames; const chunkFileNames = outputOptions.chunkFileNames;
outputOptions.chunkFileNames = (chunk) => { outputOptions.chunkFileNames = (chunk) => {
for(const name of Object.keys(chunk.modules)) { for (const name of Object.keys(chunk.modules)) {
if(name.endsWith('vendor/squoosh/image-pool.js')) { if (name.endsWith('vendor/squoosh/image-pool.js')) {
return '[name].[hash].mjs'; return '[name].[hash].mjs';
} }
} }
if(typeof chunkFileNames === 'function') { if (typeof chunkFileNames === 'function') {
return chunkFileNames.call(this, chunk); return chunkFileNames.call(this, chunk);
} }
return chunkFileNames!; return chunkFileNames!;
}; };
} }
}, },
async renderChunk(code) { async renderChunk(code) {
const assetUrlRE = /__ASTRO_IMAGE_ASSET__([a-z\d]{8})__(?:_(.*?)__)?/g; const assetUrlRE = /__ASTRO_IMAGE_ASSET__([a-z\d]{8})__(?:_(.*?)__)?/g;