@@ -24,7 +24,6 @@ import markdownVitePlugin from '../vite-plugin-markdown/index.js';
2424import astroScannerPlugin from '../vite-plugin-scanner/index.js' ;
2525import astroScriptsPlugin from '../vite-plugin-scripts/index.js' ;
2626import astroScriptsPageSSRPlugin from '../vite-plugin-scripts/page-ssr.js' ;
27- import { resolveDependency } from './util.js' ;
2827
2928interface CreateViteOptions {
3029 settings : AstroSettings ;
@@ -33,7 +32,7 @@ interface CreateViteOptions {
3332 fs ?: typeof nodeFs ;
3433}
3534
36- const ALWAYS_NOEXTERNAL = new Set ( [
35+ const ALWAYS_NOEXTERNAL = [
3736 // This is only because Vite's native ESM doesn't resolve "exports" correctly.
3837 'astro' ,
3938 // Vite fails on nested `.astro` imports without bundling
@@ -43,21 +42,7 @@ const ALWAYS_NOEXTERNAL = new Set([
4342 '@nanostores/preact' ,
4443 // fontsource packages are CSS that need to be processed
4544 '@fontsource/*' ,
46- ] ) ;
47-
48- function getSsrNoExternalDeps ( projectRoot : URL ) : string [ ] {
49- let noExternalDeps = [ ] ;
50- for ( const dep of ALWAYS_NOEXTERNAL ) {
51- try {
52- resolveDependency ( dep , projectRoot ) ;
53- noExternalDeps . push ( dep ) ;
54- } catch {
55- // ignore dependency if *not* installed / present in your project
56- // prevents hard error from Vite!
57- }
58- }
59- return noExternalDeps ;
60- }
45+ ] ;
6146
6247/** Return a common starting point for all Vite actions */
6348export async function createVite (
@@ -166,10 +151,7 @@ export async function createVite(
166151 dedupe : [ 'astro' ] ,
167152 } ,
168153 ssr : {
169- noExternal : [
170- ...getSsrNoExternalDeps ( settings . config . root ) ,
171- ...astroPkgsConfig . ssr . noExternal ,
172- ] ,
154+ noExternal : [ ...ALWAYS_NOEXTERNAL , ...astroPkgsConfig . ssr . noExternal ] ,
173155 // shiki is imported by Code.astro, which is no-externalized (processed by Vite).
174156 // However, shiki's deps are in CJS and trips up Vite's dev SSR transform, externalize
175157 // shiki to load it with node instead.
0 commit comments