diff --git a/packages/vite/rolldown.config.ts b/packages/vite/rolldown.config.ts index a99b66e54a829f..5e26173dc7b722 100644 --- a/packages/vite/rolldown.config.ts +++ b/packages/vite/rolldown.config.ts @@ -147,7 +147,7 @@ const moduleRunnerConfig = defineConfig({ '@vitejs/devtools/cli-commands', ...Object.keys(pkg.dependencies), ], - plugins: [bundleSizeLimit(54), enableSourceMapsInWatchModePlugin()], + plugins: [bundleSizeLimit(55), enableSourceMapsInWatchModePlugin()], output: { ...sharedNodeOptions.output, minify: { diff --git a/packages/vite/src/module-runner/utils.ts b/packages/vite/src/module-runner/utils.ts index 576991610b4d6b..9e2ed6e435afc6 100644 --- a/packages/vite/src/module-runner/utils.ts +++ b/packages/vite/src/module-runner/utils.ts @@ -1,10 +1,16 @@ import * as pathe from 'pathe' import { isWindows } from '../shared/utils' -export const decodeBase64: typeof atob = - typeof atob !== 'undefined' - ? atob - : (str: string) => Buffer.from(str, 'base64').toString('utf-8') +const textDecoder = new TextDecoder() + +export const decodeBase64: (base64: string) => string = (() => { + if (typeof Buffer === 'function' && typeof Buffer.from === 'function') { + return (base64: string) => Buffer.from(base64, 'base64').toString('utf-8') + } + + return (base64: string) => + textDecoder.decode(Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))) +})() const CHAR_FORWARD_SLASH = 47 const CHAR_BACKWARD_SLASH = 92