File tree 2 files changed +16
-2
lines changed
packages/vite-plugin-svelte/src/utils
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 1
1
import path from 'path' ;
2
- import { createRequire } from 'module' ;
2
+ import { builtinModules , createRequire } from 'module' ;
3
3
import { is_common_without_svelte_field , resolveDependencyData } from './dependencies' ;
4
4
import { VitePluginSvelteCache } from './vite-plugin-svelte-cache' ;
5
5
@@ -8,7 +8,12 @@ export function resolveViaPackageJsonSvelte(
8
8
importer : string | undefined ,
9
9
cache : VitePluginSvelteCache
10
10
) : 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
+ ) {
12
17
const cached = cache . getResolvedSvelteField ( importee , importer ) ;
13
18
if ( cached ) {
14
19
return cached ;
@@ -28,6 +33,10 @@ export function resolveViaPackageJsonSvelte(
28
33
}
29
34
}
30
35
36
+ function isNodeInternal ( importee : string ) {
37
+ return importee . startsWith ( 'node:' ) || builtinModules . includes ( importee ) ;
38
+ }
39
+
31
40
function isBareImport ( importee : string ) : boolean {
32
41
if (
33
42
! importee ||
You can’t perform that action at this time.
0 commit comments