File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
packages/vite-plugin-svelte/src/utils Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @sveltejs/vite-plugin-svelte ' : patch
3+ ---
4+
5+ don't try to resolve node internal modules via package.json svelte field
Original file line number Diff line number Diff line change 11import path from 'path' ;
2- import { createRequire } from 'module' ;
2+ import { builtinModules , createRequire } from 'module' ;
33import { is_common_without_svelte_field , resolveDependencyData } from './dependencies' ;
44import { VitePluginSvelteCache } from './vite-plugin-svelte-cache' ;
55
@@ -8,7 +8,12 @@ export function resolveViaPackageJsonSvelte(
88 importer : string | undefined ,
99 cache : VitePluginSvelteCache
1010) : string | void {
11- if ( importer && isBareImport ( importee ) && ! is_common_without_svelte_field ( importee ) ) {
11+ if (
12+ importer &&
13+ isBareImport ( importee ) &&
14+ ! isNodeInternal ( importee ) &&
15+ ! is_common_without_svelte_field ( importee )
16+ ) {
1217 const cached = cache . getResolvedSvelteField ( importee , importer ) ;
1318 if ( cached ) {
1419 return cached ;
@@ -28,6 +33,10 @@ export function resolveViaPackageJsonSvelte(
2833 }
2934}
3035
36+ function isNodeInternal ( importee : string ) {
37+ return importee . startsWith ( 'node:' ) || builtinModules . includes ( importee ) ;
38+ }
39+
3140function isBareImport ( importee : string ) : boolean {
3241 if (
3342 ! importee ||
You can’t perform that action at this time.
0 commit comments