mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
fix: ensure vite is not imported by runtime utils (#11847)
This commit is contained in:
parent
2bb72c6396
commit
45b599c4d4
3 changed files with 17 additions and 3 deletions
5
.changeset/eleven-papayas-rhyme.md
Normal file
5
.changeset/eleven-papayas-rhyme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes a case where Vite would be imported by the SSR runtime, causing bundling errors and bloat.
|
|
@ -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()`.
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue