Remove usage of createRequire in core image (#6488)
* Add fallback for hosts without import.meta.url * Try using an import * Add image-size as external * Make image-size external * Apply suggestions from code review * leave image-size alone
This commit is contained in:
parent
dbd61c111d
commit
bfd67ea749
3 changed files with 7 additions and 3 deletions
5
.changeset/lucky-shoes-mate.md
Normal file
5
.changeset/lucky-shoes-mate.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Remove use of createRequire breaking non-Node hosts.
|
|
@ -1,9 +1,7 @@
|
||||||
import { createRequire } from 'module';
|
|
||||||
import fs from 'node:fs/promises';
|
import fs from 'node:fs/promises';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { ImageMetadata, InputFormat } from '../types.js';
|
import { ImageMetadata, InputFormat } from '../types.js';
|
||||||
const require = createRequire(import.meta.url);
|
import sizeOf from 'image-size';
|
||||||
const sizeOf = require('image-size');
|
|
||||||
|
|
||||||
export interface Metadata extends ImageMetadata {
|
export interface Metadata extends ImageMetadata {
|
||||||
orientation?: number;
|
orientation?: number;
|
||||||
|
|
|
@ -67,6 +67,7 @@ export async function sync(
|
||||||
{
|
{
|
||||||
server: { middlewareMode: true, hmr: false },
|
server: { middlewareMode: true, hmr: false },
|
||||||
optimizeDeps: { entries: [] },
|
optimizeDeps: { entries: [] },
|
||||||
|
ssr: { external: ['image-size'] },
|
||||||
logLevel: 'silent',
|
logLevel: 'silent',
|
||||||
},
|
},
|
||||||
{ settings, logging, mode: 'build', command: 'build', fs }
|
{ settings, logging, mode: 'build', command: 'build', fs }
|
||||||
|
|
Loading…
Reference in a new issue