diff options
author | 2023-08-23 17:52:53 +0800 | |
---|---|---|
committer | 2023-08-23 17:52:53 +0800 | |
commit | 632579dc2094cc342929261c89e689f0dd358284 (patch) | |
tree | 280bf40fef2f0e6a2aa926a91957a7e9ae5979f5 | |
parent | 9f1881455a5c3a6457125dafbcd342be5c4de907 (diff) | |
download | astro-632579dc2094cc342929261c89e689f0dd358284.tar.gz astro-632579dc2094cc342929261c89e689f0dd358284.tar.zst astro-632579dc2094cc342929261c89e689f0dd358284.zip |
Prevent bundling sharp (#8196)
Diffstat (limited to '')
-rw-r--r-- | .changeset/spicy-stingrays-cheer.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/build/plugins/plugin-internals.ts | 25 |
2 files changed, 18 insertions, 12 deletions
diff --git a/.changeset/spicy-stingrays-cheer.md b/.changeset/spicy-stingrays-cheer.md new file mode 100644 index 000000000..19a56cda3 --- /dev/null +++ b/.changeset/spicy-stingrays-cheer.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Prevent bundling sharp as it errors in runtime diff --git a/packages/astro/src/core/build/plugins/plugin-internals.ts b/packages/astro/src/core/build/plugins/plugin-internals.ts index a92b5ac26..6bf00f9dc 100644 --- a/packages/astro/src/core/build/plugins/plugin-internals.ts +++ b/packages/astro/src/core/build/plugins/plugin-internals.ts @@ -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 { AstroBuildPlugin } from '../plugin'; import { normalizeEntryId } from './plugin-component-entry.js'; @@ -8,19 +8,20 @@ export function vitePluginInternals(input: Set<string>, internals: BuildInternal name: '@astro/plugin-build-internals', config(config, options) { - const extra: Partial<UserConfig> = {}; - const noExternal = [], - external = []; if (options.command === 'build' && config.build?.ssr) { - noExternal.push('astro'); - external.push('shiki'); + return { + ssr: { + // Always bundle Astro runtime when building for SSR + noExternal: ['astro'], + // Except for these packages as they're not bundle-friendly. Users with strict package installations + // need to manually install these themselves if they use the related features. + external: [ + 'shiki', // For syntax highlighting + 'sharp', // For sharp image service + ], + }, + }; } - - extra.ssr = { - external, - noExternal, - }; - return extra; }, async generateBundle(_options, bundle) { |