Prevent bundling sharp (#8196)
This commit is contained in:
parent
9f1881455a
commit
632579dc20
2 changed files with 18 additions and 12 deletions
5
.changeset/spicy-stingrays-cheer.md
Normal file
5
.changeset/spicy-stingrays-cheer.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent bundling sharp as it errors in runtime
|
|
@ -1,4 +1,4 @@
|
||||||
import type { UserConfig, Plugin as VitePlugin } from 'vite';
|
import type { Plugin as VitePlugin } from 'vite';
|
||||||
import type { BuildInternals } from '../internal.js';
|
import type { BuildInternals } from '../internal.js';
|
||||||
import type { AstroBuildPlugin } from '../plugin';
|
import type { AstroBuildPlugin } from '../plugin';
|
||||||
import { normalizeEntryId } from './plugin-component-entry.js';
|
import { normalizeEntryId } from './plugin-component-entry.js';
|
||||||
|
@ -8,19 +8,20 @@ export function vitePluginInternals(input: Set<string>, internals: BuildInternal
|
||||||
name: '@astro/plugin-build-internals',
|
name: '@astro/plugin-build-internals',
|
||||||
|
|
||||||
config(config, options) {
|
config(config, options) {
|
||||||
const extra: Partial<UserConfig> = {};
|
|
||||||
const noExternal = [],
|
|
||||||
external = [];
|
|
||||||
if (options.command === 'build' && config.build?.ssr) {
|
if (options.command === 'build' && config.build?.ssr) {
|
||||||
noExternal.push('astro');
|
return {
|
||||||
external.push('shiki');
|
ssr: {
|
||||||
}
|
// Always bundle Astro runtime when building for SSR
|
||||||
|
noExternal: ['astro'],
|
||||||
extra.ssr = {
|
// Except for these packages as they're not bundle-friendly. Users with strict package installations
|
||||||
external,
|
// need to manually install these themselves if they use the related features.
|
||||||
noExternal,
|
external: [
|
||||||
|
'shiki', // For syntax highlighting
|
||||||
|
'sharp', // For sharp image service
|
||||||
|
],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return extra;
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async generateBundle(_options, bundle) {
|
async generateBundle(_options, bundle) {
|
||||||
|
|
Loading…
Reference in a new issue