diff --git a/.changeset/lucky-shoes-mate.md b/.changeset/lucky-shoes-mate.md new file mode 100644 index 000000000..32ddde78d --- /dev/null +++ b/.changeset/lucky-shoes-mate.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Remove use of createRequire breaking non-Node hosts. diff --git a/packages/astro/src/assets/utils/metadata.ts b/packages/astro/src/assets/utils/metadata.ts index d1bc37bad..1e96cbe97 100644 --- a/packages/astro/src/assets/utils/metadata.ts +++ b/packages/astro/src/assets/utils/metadata.ts @@ -1,9 +1,7 @@ -import { createRequire } from 'module'; import fs from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; import { ImageMetadata, InputFormat } from '../types.js'; -const require = createRequire(import.meta.url); -const sizeOf = require('image-size'); +import sizeOf from 'image-size'; export interface Metadata extends ImageMetadata { orientation?: number; diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index 914783331..82575f083 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -67,6 +67,7 @@ export async function sync( { server: { middlewareMode: true, hmr: false }, optimizeDeps: { entries: [] }, + ssr: { external: ['image-size'] }, logLevel: 'silent', }, { settings, logging, mode: 'build', command: 'build', fs }