mirror of
https://github.com/withastro/astro.git
synced 2025-01-13 22:11:20 -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 { slug as githubSlug } from 'github-slugger';
|
||||||
import matter from 'gray-matter';
|
import matter from 'gray-matter';
|
||||||
import type { PluginContext } from 'rollup';
|
import type { PluginContext } from 'rollup';
|
||||||
import { type ViteDevServer, normalizePath } from 'vite';
|
import type { ViteDevServer } from 'vite';
|
||||||
import xxhash from 'xxhash-wasm';
|
import xxhash from 'xxhash-wasm';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import type {
|
import type {
|
||||||
|
@ -25,6 +25,7 @@ import {
|
||||||
PROPAGATED_ASSET_FLAG,
|
PROPAGATED_ASSET_FLAG,
|
||||||
} from './consts.js';
|
} from './consts.js';
|
||||||
import { createImage } from './runtime-assets.js';
|
import { createImage } from './runtime-assets.js';
|
||||||
|
import { normalizePath } from '../core/viteUtils.js';
|
||||||
/**
|
/**
|
||||||
* Amap from a collection + slug to the local file path.
|
* Amap from a collection + slug to the local file path.
|
||||||
* This is used internally to resolve entry imports when using `getEntry()`.
|
* This is used internally to resolve entry imports when using `getEntry()`.
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { normalizePath } from 'vite';
|
import { prependForwardSlash, slash } from '../core/path.js';
|
||||||
import { prependForwardSlash } from '../core/path.js';
|
|
||||||
import type { ModuleLoader } from './module-loader/index.js';
|
import type { ModuleLoader } from './module-loader/index.js';
|
||||||
import { VALID_ID_PREFIX, resolveJsToTs, unwrapId, viteID } from './util.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
|
* Resolve the hydration paths so that it can be imported in the client
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue