Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of createRequire in core image #6488

Merged
merged 7 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lucky-shoes-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Add fallback for hosts without import.meta.url
matthewp marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 1 addition & 3 deletions packages/astro/src/assets/utils/metadata.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/create-vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export async function createVite(
// shiki is imported by Code.astro, which is no-externalized (processed by Vite).
// However, shiki's deps are in CJS and trips up Vite's dev SSR transform, externalize
// shiki to load it with node instead.
external: [...(mode === 'dev' ? ['shiki'] : []), ...astroPkgsConfig.ssr.external],
external: [...(mode === 'dev' ? ['shiki', 'image-size'] : []), ...astroPkgsConfig.ssr.external],
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/core/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down