From f1e9546c630242f491e7caab47a473b2dd6fee85 Mon Sep 17 00:00:00 2001 From: Rico Kahler Date: Fri, 3 May 2024 02:30:48 -0500 Subject: [PATCH] fix: remove unconditional external from vite build (#6554) --- packages/sanity/src/_internal/cli/server/getViteConfig.ts | 6 +++++- packages/sanity/src/core/components/DefaultDocument.tsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/sanity/src/_internal/cli/server/getViteConfig.ts b/packages/sanity/src/_internal/cli/server/getViteConfig.ts index 1a88ff5f449..13c1a4c0f36 100644 --- a/packages/sanity/src/_internal/cli/server/getViteConfig.ts +++ b/packages/sanity/src/_internal/cli/server/getViteConfig.ts @@ -119,6 +119,8 @@ export async function getViteConfig(options: ViteOptions): Promise }, } + const addImportMap = false + if (mode === 'production') { viteConfig.build = { ...viteConfig.build, @@ -128,7 +130,9 @@ export async function getViteConfig(options: ViteOptions): Promise emptyOutDir: false, // Rely on CLI to do this rollupOptions: { - external: [/^sanity(\/.*)?$/, 'react', 'react/jsx-runtime', 'styled-components'], + external: addImportMap + ? [/^sanity(\/.*)?$/, 'react', 'react/jsx-runtime', 'styled-components'] + : [], input: { sanity: path.join(cwd, '.sanity', 'runtime', 'app.js'), }, diff --git a/packages/sanity/src/core/components/DefaultDocument.tsx b/packages/sanity/src/core/components/DefaultDocument.tsx index 209f6114f0a..f2448f71eac 100644 --- a/packages/sanity/src/core/components/DefaultDocument.tsx +++ b/packages/sanity/src/core/components/DefaultDocument.tsx @@ -120,7 +120,7 @@ const EMPTY_ARRAY: never[] = [] * @beta */ export function DefaultDocument(props: DefaultDocumentProps): ReactElement { const {entryPath, css = EMPTY_ARRAY, basePath = '/'} = props - const addImportMap = true + const addImportMap = false return (