summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changeset/eleven-papayas-rhyme.md5
-rw-r--r--packages/astro/src/content/utils.ts3
-rw-r--r--packages/astro/src/core/viteUtils.ts12
3 files changed, 17 insertions, 3 deletions
diff --git a/.changeset/eleven-papayas-rhyme.md b/.changeset/eleven-papayas-rhyme.md
new file mode 100644
index 000000000..3b6a9bb09
--- /dev/null
+++ b/.changeset/eleven-papayas-rhyme.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fixes a case where Vite would be imported by the SSR runtime, causing bundling errors and bloat.
diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts
index 6d0627247..c0985742b 100644
--- a/packages/astro/src/content/utils.ts
+++ b/packages/astro/src/content/utils.ts
@@ -4,7 +4,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
import { slug as githubSlug } from 'github-slugger';
import matter from 'gray-matter';
import type { PluginContext } from 'rollup';
-import { type ViteDevServer, normalizePath } from 'vite';
+import type { ViteDevServer } from 'vite';
import xxhash from 'xxhash-wasm';
import { z } from 'zod';
import type {
@@ -25,6 +25,7 @@ import {
PROPAGATED_ASSET_FLAG,
} from './consts.js';
import { createImage } from './runtime-assets.js';
+import { normalizePath } from '../core/viteUtils.js';
/**
* Amap from a collection + slug to the local file path.
* This is used internally to resolve entry imports when using `getEntry()`.
diff --git a/packages/astro/src/core/viteUtils.ts b/packages/astro/src/core/viteUtils.ts
index bfe1eaadc..46c59d25d 100644
--- a/packages/astro/src/core/viteUtils.ts
+++ b/packages/astro/src/core/viteUtils.ts
@@ -1,10 +1,18 @@
import path from 'node:path';
import { fileURLToPath } from 'node:url';
-import { normalizePath } from 'vite';
-import { prependForwardSlash } from '../core/path.js';
+import { prependForwardSlash, slash } from '../core/path.js';
import type { ModuleLoader } from './module-loader/index.js';
import { VALID_ID_PREFIX, resolveJsToTs, unwrapId, viteID } from './util.js';
+const isWindows = typeof process !== 'undefined' && process.platform === 'win32';
+
+/**
+ * Re-implementation of Vite's normalizePath that can be used without Vite
+ */
+export function normalizePath(id: string) {
+ return path.posix.normalize(isWindows ? slash(id) : id);
+}
+
/**
* Resolve the hydration paths so that it can be imported in the client
*/