Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Nov 8, 2022
1 parent d701ae0 commit 982e446
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
8 changes: 5 additions & 3 deletions packages/integrations/image/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const UNSUPPORTED_ADAPTERS = new Set([
'@astrojs/cloudflare',
'@astrojs/deno',
'@astrojs/netlify/edge-functions',
'@astrojs/vercel/edge'
'@astrojs/vercel/edge',
]);

interface BuildConfig {
Expand Down Expand Up @@ -107,8 +107,10 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
},
'astro:build:start': ({ buildConfig }) => {
const adapterName = _config.adapter?.name;
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.`);
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.`
);
}

// Backwards compat
Expand Down
26 changes: 13 additions & 13 deletions packages/integrations/image/src/vite-plugin-astro-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,25 @@ export function createPlugin(config: AstroConfig, options: Required<IntegrationO
});
},
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/
// folder. This is because the wasm is built at the top-level and this makes
// it accessible from the pool worker.
const chunkFileNames = outputOptions.chunkFileNames;
outputOptions.chunkFileNames = (chunk) => {
for(const name of Object.keys(chunk.modules)) {
if(name.endsWith('vendor/squoosh/image-pool.js')) {
return '[name].[hash].mjs';
}
}

if(typeof chunkFileNames === 'function') {
const chunkFileNames = outputOptions.chunkFileNames;
outputOptions.chunkFileNames = (chunk) => {
for (const name of Object.keys(chunk.modules)) {
if (name.endsWith('vendor/squoosh/image-pool.js')) {
return '[name].[hash].mjs';
}
}

if (typeof chunkFileNames === 'function') {
return chunkFileNames.call(this, chunk);
}

return chunkFileNames!;
};
}
return chunkFileNames!;
};
}
},
async renderChunk(code) {
const assetUrlRE = /__ASTRO_IMAGE_ASSET__([a-z\d]{8})__(?:_(.*?)__)?/g;
Expand Down

0 comments on commit 982e446

Please sign in to comment.